Lines Matching defs:an

2 ** This file is an amalgamation of many separate C source files from SQLite
58 ** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2
113 ** * Columns in an index
115 ** * Terms in the SET clause of an UPDATE statement
118 ** * Terms in the VALUES clause of an INSERT statement
142 ** The maximum depth of an expression tree. This is limited to
144 ** want to place more severe limits on the complexity of an
176 ** The maximum number of arguments to an SQL function.
223 ** a library that is technically incompatible with an SQLite library
225 ** with a page-size of 65536 bytes crashes, then an instance of SQLite
327 ** if it is available, it requires an #include of specific headers
357 ** Older versions of SQLite used an optional THREADSAFE macro.
396 ** will cause HeapValidate to be called. If heap validation should fail, an
449 ** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out
640 ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
653 ** string contains the date and time of the check-in (UTC) and an SHA1
687 ** sqlite3_libversion_number() function returns an integer equal to
745 ** This interface can be used by an application to make sure that the
768 ** Each open SQLite database is represented by a pointer to an instance of
769 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
770 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
774 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
834 ** pointer or an [sqlite3] object pointer obtained
854 ** that allows an application to run multiple statements of SQL
868 ** ^If an error occurs while evaluating the SQL statements passed into
880 ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
886 ** callback is an array of pointers to strings obtained as if from
887 ** [sqlite3_column_text()], one for each column. ^If an element of a
890 ** sqlite3_exec() callback is an array of pointers to strings where each
895 ** to an empty string, or a pointer that contains only whitespace and/or
923 ** Many SQLite functions return an integer result code from the set shown
936 #define SQLITE_ABORT 4 /* Callback routine requested an abort */
971 ** much information about problems as programmers might like. In an effort to
1049 ** object returns an integer which is a vector of the these
1057 ** are aligned to an address which is an integer multiple of
1088 ** of an [sqlite3_io_methods] object.
1099 ** When SQLite invokes the xSync() method of an
1129 ** An [sqlite3_file] object represents an open file in the
1133 ** for their own use. The pMethods entry is a pointer to an
1139 const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
1145 ** Every file opened by the [sqlite3_vfs.xOpen] method populates an
1147 ** [sqlite3_file] object) with a pointer to an instance of this object.
1179 ** VFS implementations to directly control an open file using the
1180 ** [sqlite3_file_control()] interface. The second "op" argument is an
1218 ** are aligned to an address which is an integer multiple of
1267 ** into an integer that the pArg argument points to. This capability
1283 ** point to an integer (type int) containing the new chunk-size to use
1312 ** by an additional 25 milliseconds with each subsequent retry. This
1315 ** within the same process. The argument is a pointer to an array of two
1332 ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
1342 ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
1366 ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
1369 ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
1372 ** pragma or NULL if the pragma has no argument. ^The handler for an
1383 ** that the VFS encountered an error while handling the [PRAGMA] and the
1384 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
1407 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
1409 ** at the internal representation of an [sqlite3_mutex]. It only
1454 ** from xFullPathname() with an optional suffix added.
1490 ** change the way it deals with files. For example, an application
1515 ** be created, and that it is an error if it already exists.
1553 ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
1618 ** the xAccess method of an [sqlite3_vfs] object. They determine
1686 ** A call to sqlite3_initialize() is an "effective" call if it is
1689 ** following a call to sqlite3_shutdown(). ^(Only an effective call
1693 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
1695 ** an effective call to sqlite3_shutdown() does any deinitialization.
1711 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
1714 ** SQLite interfaces so that an application usually does not need to
1773 ** implementation of an application-defined [sqlite3_os_init()].
1775 ** The first argument to sqlite3_config() is an integer
1796 ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code
1812 ** A pointer to an instance of this object is the argument to
1815 ** By creating an instance of this object
1817 ** during configuration, an application can specify an alternative
1825 ** also used during testing of SQLite in order to specify an alternative
1865 ** SQLite will never invoke xInit() more than once without an intervening
1872 void *(*xRealloc)(void*,int); /* Resize an allocation */
1873 int (*xSize)(void*); /* Return the size of an allocation */
1937 ** <dd> ^(This option takes a single argument which is a pointer to an
1945 ** <dd> ^(This option takes a single argument which is a pointer to an
1970 ** scratch memory. There are three arguments: A pointer an 8-byte
1975 ** The first argument must be a pointer to an 8-byte aligned buffer
1987 ** This configuration should not be used if an application-define page
1996 ** argument should point to an allocation of at least sz*N bytes of memory.
2002 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
2017 ** The first pointer (the memory pointer) must be aligned to an 8-byte
2023 ** <dd> ^(This option takes a single argument which is a pointer to an
2035 ** <dd> ^(This option takes a single argument which is a pointer to an
2059 ** an [sqlite3_pcache_methods2] object. This object specifies the interface
2064 ** <dd> ^(This option takes a single argument which is a pointer to an
2078 ** [sqlite3_log()] call and is intended to be a [result code] or an
2150 ** must be aligned to an 8-byte boundary. ^If the second argument to
2164 ** The first argument is an integer which is 0 to disable FK enforcement,
2166 ** unchanged. The second parameter is a pointer to an integer into which
2174 ** The first argument is an integer which is 0 to disable triggers,
2176 ** The second parameter is a pointer to an integer into which
2200 ** ^Each entry in an SQLite table has a unique 64-bit signed
2202 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
2214 ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
2231 ** ^For the purposes of this routine, an [INSERT] is considered to
2258 ** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
2262 ** caused by an INSERT, DELETE, or UPDATE statement. Rows that
2310 ** count does not include rows of views that fire an [INSTEAD OF trigger],
2340 ** ^If an SQL operation is very nearly finished at the time when
2341 ** sqlite3_interrupt() is called, then it might not have an opportunity
2345 ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
2346 ** that is inside an explicit transaction, then the entire transaction
2405 ** an attempt is made to open a database table that another thread
2428 ** to promote to an exclusive lock. The first process cannot proceed
2445 ** cache will be left in an inconsistent state and so the error
2448 ** forces an automatic rollback of the changes. See the
2477 ** ^Calling this routine with an argument less than or equal to zero
2502 ** A result table is an array of pointers to zero-terminated UTF-8 strings.
2513 ** ^(As an example of the result table format, suppose a query result
2526 ** in an array names azResult. Then azResult holds this content:
2586 ** first two parameters is reversed from snprintf().)^ This is an
2620 ** One can use this text in an SQL statement as follows:
2642 ** This second example is an SQL syntax error. As a general rule you should
2712 ** is always aligned to at least an 8 byte boundary, or to a
2791 ** ^This routine registers an authorizer callback with a particular
2802 ** rejected with an error. ^If the authorizer callback returns
2805 ** the authorizer will fail with an error message.
2810 ** authorizer will fail with an error message explaining that
2815 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
2825 ** return can be used to deny an untrusted user access to individual
2832 ** SQL statements from an untrusted source, to ensure that the SQL statements
2835 ** example, an application may allow a user to enter arbitrary
2845 ** in addition to using an authorizer.
2886 #define SQLITE_DENY 1 /* Abort the SQL statement with an error */
2887 #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
2894 ** second parameter to the callback is an integer code that specifies
2950 ** various times when an SQL statement is being run by [sqlite3_step()].
2959 ** the original statement text and an estimate of wall-clock time
3007 ** ^These routines open an SQLite database file as specified by the
3011 ** returned in *ppDb, even if an error occurs. The only exception is that
3015 ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The
3017 ** an English language description of the error following a failure of any
3024 ** Whether or not an error occurs when it is opened, resources
3039 ** already exist, an error is returned.</dd>)^
3044 ** case the database must already exist, otherwise an error is returned.</dd>)^
3082 ** ^If the filename is an empty string, then a private, temporary
3099 ** URI filenames are parsed according to RFC 3986. ^If the URI contains an
3100 ** authority, then it must be either an empty string or the string
3101 ** "localhost". ^If the authority is not an empty string or "localhost", an
3107 ** then it is interpreted as an absolute path. ^If the path does not begin
3110 ** ^On windows, the first component of an absolute path
3122 ** an empty string the default VFS object is used. ^Specifying an unknown
3123 ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is
3128 ** "rwc". Attempting to set it to any other value is an error)^.
3136 ** used, it is an error to specify a value for the mode parameter that is
3150 ** ^Specifying an unknown parameter in the query component of a URI is not an
3186 ** specifying an octet value. ^Before the path or query components of a
3189 ** corresponding octet. If this process generates an invalid UTF-8 encoding,
3228 ** a pointer to an empty string.
3243 ** exist. If the value of P is something other than an integer, then
3286 ** If an interface fails with SQLITE_MISUSE, that means the interface
3355 ** created by an untrusted script can be contained using the
3376 ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
3380 ** result set of a [SELECT] or the maximum number of columns in an index
3381 ** or in an ORDER BY or GROUP BY clause.</dd>)^
3391 ** used to implement an SQL statement. This limit is not currently
3408 ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
3430 ** To execute an SQL query, it must first be compiled into a byte-code
3448 ** performance advantage to be gained by passing an nByte parameter that
3459 ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set
3460 ** to NULL. ^If the input text contains no SQL (if the input is an empty
3467 ** otherwise an [error code] is returned.
3485 ** ^When an error occurs, [sqlite3_step()] will return one of the detailed
3501 ** or [GLOB] operator or if the parameter is compared to an indexed column
3554 ** ^(For example, if an application defines a function "eval()" that
3606 ** will accept either a protected or an unprotected sqlite3_value.
3612 ** sqlite3_value object but no mutex is held for an unprotected
3637 ** The context in which an SQL function executes is stored in an
3638 ** sqlite3_context object. ^A pointer to an sqlite3_context object
3665 ** In the templates above, NNN represents an integer literal,
3666 ** and VVV represents an alphanumeric identifier.)^ ^The values of these
3675 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3713 ** (just an integer to hold its size) while it is being processed.
3729 ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
3780 ** ^The first host parameter has an index of 1, not 0.
3797 ** ^Return the index of an SQL parameter given its name. ^The
3823 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3824 ** statement that does not return data (for example an [UPDATE]).
3852 ** that column, if there is an AS clause. If there is no AS clause
3883 ** ^If the Nth column returned by the statement is an expression or
3916 ** returned result set of that [SELECT] is a table column (not an
3918 ** column is returned.)^ ^If the Nth column of the result set is an
3965 ** or occurs outside of an explicit transaction, then you can retry the
3966 ** statement. If the statement is not a [COMMIT] and occurs within an
4000 ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from
4004 ** break because any application that ever receives an SQLITE_MISUSE error
4139 ** ^The object returned by [sqlite3_column_value()] is an
4292 ** [prepared statement] S indicated an error, then
4293 ** [sqlite3_reset(S)] returns an appropriate [error code].
4315 ** function is to be added. ^If an application uses more than one database
4346 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
4351 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
4353 ** parameters. ^An aggregate SQL function requires an implementation of xStep
4354 ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
4462 ** The 3rd parameter to these callbacks is an array of pointers to
4468 ** Any attempt to use these routines on an [unprotected sqlite3_value]
4473 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
4481 ** numeric affinity to the value. This means that an attempt is
4482 ** made to convert the value to an integer or floating point. If
4524 ** an aggregate query, the xStep() callback of the aggregate function
4653 ** an application-defined function to be the BLOB whose content is pointed
4662 ** an application-defined function to be a floating point value specified
4666 ** cause the implemented SQL function to throw an exception.
4669 ** as the text of an error message. ^SQLite interprets the error
4683 ** returned by SQLite as a result of an error in a function. ^By default,
4687 ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
4690 ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
4742 ** ^A [protected sqlite3_value] object may always be used where an
4792 ** on an even byte address.
4794 ** ^The fourth argument, pArg, is an application data pointer that is passed
4807 ** by the eTextRep argument. The collating function must return an
4813 ** must give an equivalent answer when invoked with equivalent strings.
4874 ** [database connection] to be invoked whenever an undefined collation
4908 ** Specify the key for an encrypted database. This routine should be
4920 ** Change the key on an open database. If the current database is not
4977 ** is a NULL pointer, then SQLite performs a search for an appropriate
5016 ** an error is to use this function.
5047 ** will be an absolute pathname, even if the filename used
5071 ** [sqlite3_next_stmt(D,S)] must refer to an open database
5115 ** rolled back if an explicit "ROLLBACK" statement is executed, or
5116 ** an error or constraint causes an implicit rollback to occur.
5144 ** ^In the case of an update, this is the [rowid] after the update takes place.
5150 ** is not invoked when duplication rows are deleted because of an
5186 ** ^Cache sharing is enabled and disabled for an entire process.
5212 ** pages to improve performance is an example of non-essential memory.
5245 ** an [SQLITE_NOMEM] error. In other words, the soft heap limit
5249 ** the soft heap limit prior to the call, or negative in the case of an
5308 ** (i.e. "main", "temp", or an attached database) containing the specified
5337 ** ^If the specified table is actually a view, an [error code] is returned.
5339 ** ^If the specified column is "rowid", "oid" or "_rowid_" and an
5353 ** ^(This function may load one or more schemas from database files. If an
5355 ** cannot be found, an [error code] is returned and an error message left
5376 ** ^This interface loads an SQLite extension library from the named file.
5378 ** ^The sqlite3_load_extension() interface attempts to load an
5386 ** ^If an error occurs and pzErrMsg is not 0, then the
5394 ** otherwise an error will be returned.
5441 ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
5442 ** point to an appropriate error message (obtained from [sqlite3_mprintf()])
5443 ** and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg
5446 ** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],
5449 ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
5557 ** and makes other simplifications to the WHERE clause in an attempt to
5581 ** ^The estimatedCost value is an estimate of the cost of doing the
5617 ** an operator that is part of a constraint term in the wHERE clause of
5639 ** parameter is an arbitrary client data pointer that is passed through
5677 ** ^Virtual tables methods can set an error message by assigning a
5734 ** of the new function always causes an exception to be thrown. So
5755 ** An instance of this object represents an open BLOB on which
5778 ** ^It is not possible to open a column that is part of an index or primary
5789 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
5797 ** ^(If the row that a BLOB handle points to is modified by an
5803 ** an expired BLOB handle fail with a return code of [SQLITE_ABORT].
5815 ** to create an empty, zero-filled blob in which to read or write using
5834 ** ^This function is used to move an existing blob handle so that it points
5838 ** remain the same. Moving an existing blob handle to a new row can be
5844 ** it does not contain a blob or text value, or if another error occurs, an
5847 ** [sqlite3_blob_reopen()] on an aborted blob handle immediately return
5848 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
5858 ** ^Closes an open [BLOB handle].
5872 ** an error code, the BLOB is still closed.)^
5897 ** ^(This function is used to read data from an open [BLOB handle] into a
5907 ** ^An attempt to read from an expired [BLOB handle] fails with an
5911 ** Otherwise, an [error code] or an [extended error code] is returned.)^
5925 ** ^This function is used to write data into an open [BLOB handle] from a
5941 ** ^An attempt to write to an expired [BLOB handle] fails with an
5949 ** Otherwise, an [error code] or an [extended error code] is returned.)^
5963 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
5979 ** ^To make an existing VFS into the default VFS, register it again
5982 ** VFS is registered with a name that is NULL or an empty string,
6030 ** will unwind its stack and return an error. ^(The argument
6084 ** mutex must be exited an equal number of times before another thread
6093 ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
6123 ** creates and populates an instance of this structure to pass
6125 ** Additionally, an instance of this structure can be used as an
6160 ** (i.e. it is acceptable to provide an implementation that segfaults if
6196 ** never uses these routines except inside an assert() and applications
6284 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6296 ** purposes. ^The first parameter is an operation code that determines
6344 ** highwater marks. ^The first argument is an integer code for
6470 ** is an integer constant, taken from the set of
6583 ** an index.
6588 ** is an integer code for a specific [SQLITE_STMTSTATUS counter]
6615 ** A non-zero value in this counter may indicate an opportunity to
6621 ** A non-zero value in this counter may indicate an opportunity to
6664 ** register an alternative page cache implementation by passing in an
6669 ** custom page cache using this API, an application can better control
6675 ** The alternative page cache mechanism is an
6679 ** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an
6707 ** ^SQLite will never invoke xInit() more than once without an intervening
6724 ** false if it is used for an in-memory database. The cache implementation
6747 ** an sqlite3_pcache_page object associated with that page, or a NULL pointer.
6795 ** previously contains an entry associated with newKey, it must be
6860 ** The sqlite3_backup object records state information about an ongoing
6905 ** an [ATTACH] statement for an attached database.
6911 ** an error.
6913 ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
6914 ** returned and an error code and error message are stored in the
6919 ** ^A successful call to sqlite3_backup_init() returns a pointer to an
6934 ** ^If an error occurs while running sqlite3_backup_step(B,N),
6935 ** then an [error code] is returned. ^As well as [SQLITE_OK] and
6937 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
6945 ** <li> the destination database is an in-memory database and the
6966 ** ^The first call to sqlite3_backup_step() obtains an exclusive lock
6974 ** through the backup process. ^If the source database is modified by an
6997 ** ^If an out-of-memory condition or IO error occurred during any prior
7066 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
7082 ** has locked the required resource is stored internally. ^After an
7083 ** application receives an SQLITE_LOCKED error, it may call the
7110 ** The unlock-notify callback is not reentrant. If an application invokes
7111 ** any sqlite3_xxx API functions from within an unlock-notify callback, a
7119 ** When an unlock-notify callback is registered, the application provides a
7122 ** it an array of void* context pointers. The first argument passed to
7123 ** an unlock-notify callback is a pointer to an array of void* pointers,
7127 ** more than one blocked connection that has registered for an unlock-notify
7131 ** specified by the blocked connections bundled together into an array.
7132 ** This gives the application an opportunity to prioritize any actions
7137 ** Assuming that after registering for an unlock-notify callback a
7149 ** a deadlocked state if connection A has registered for an unlock-notify
7151 ** B has itself registered for an unlock-notify callback when connection
7154 ** registered for an unlock-notify callback on the conclusion of connection
7168 ** or "DROP INDEX" query, an infinite loop might be the result.
7171 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7204 ** nothing to prevent an application from calling sqlite3_log(), doing so
7233 ** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
7237 ** The callback function should normally return [SQLITE_OK]. ^If an error
7240 ** to report an error, though the commit will have still occurred. If the
7259 ** CAPI3REF: Configure an auto-checkpoint
7289 ** on [database connection] D to be [checkpointed]. ^If X is NULL or an
7338 ** If no values are available because of an error, they are both set to -1
7341 ** All calls obtain an exclusive "checkpoint" lock on the database file. If
7360 ** an SQLITE_BUSY error is encountered when processing one or more of the
7363 ** error occurs while processing an attached database, processing is abandoned
7368 ** If database zDb is the name of an attached database that is not in WAL
7400 ** If this interface is invoked outside the context of an xConnect or
7420 ** where X is an integer. If X is zero, then the [virtual table] whose
7454 ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The
7476 /* #define SQLITE_ABORT 4 // Also an error code */
7518 ** Register a geometry callback named zGeom that can be used as part of an
7576 /* A complete hash table is an instance of the following structure.
7607 /* Each element in the hash table is an instance of the following
7854 ** The "file format" number is an integer that is incremented whenever
7961 ** table or index. This is an unsigned integer type. For 99.9% of
8011 ** Assert that the pointer X is aligned to an 8-byte boundary. This
8062 ** an array.
8107 ** implementation of an SQL aggregate step callback may not use the
8234 #define BTREE_MEMORY 2 /* This is an in-memory DB */
8277 ** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored
8294 ** to constants so that the offset of the corresponding field in an
8434 ** or VDBE. The VDBE implements an abstract machine that runs a
8442 ** A single VDBE is an opaque structure named "Vdbe". Only routines
8457 ** A single instruction of the virtual machine has an opcode
8459 ** as an instance of the following structure:
8465 u8 p5; /* Fifth parameter is an unsigned character */
8533 #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */
8745 #define OPFLG_IN1 0x0004 /* in1: P1 is an input */
8746 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
8747 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
8748 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
8749 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
8894 ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
9061 ** Every page in the cache is controlled by an instance of the following
9157 /* Increment the reference count of an existing page */
9379 ** process that requests an EXCLUSIVE lock may actually obtain a PENDING
9380 ** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to
9433 ** is set high so that we don't have to allocate an unused page except
9525 ** to all source files. We break it out in an effort to keep the code
9591 ** Each database file to be accessed by the system is an instance
9711 ** Each database connection is an instance of the following structure.
9810 ** tried to do recently failed with an SQLITE_LOCKED error due to locks
9884 ** Each SQL function is defined by an instance of the following
9945 ** Used to create an aggregate function definition implemented by
9992 ** Each SQLite module (virtual table definition) is defined by an
10004 ** information about each column of an SQL table is held in an instance
10022 ** A "Collating Sequence" is defined by an instance of the following
10033 ** The CollSeq.pUser member variable is an extra parameter that passed in
10039 ** collating sequence is undefined. Indices built on an undefined
10079 ** The SQLITE_AFF_MASK values masks off the significant bits of an
10085 ** Additional bit values that can be ORed with an affinity without
10113 ** When an sqlite3_prepare() operation is required to access the virtual
10118 ** When an in-memory Table object is deleted (for example when the
10126 ** Refer to comments above function sqlite3VtabUnlockList() for an
10127 ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect
10145 ** Each SQL table is represented in memory by an instance of the
10153 ** pointer to an array of Column structures, one for each column.
10155 ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of
10228 ** Each foreign key constraint is an instance of the following structure.
10242 ** Each REFERENCES clause generates an instance of the following structure
10270 ** the operation in progress stops and returns an error code. But prior
10321 ** A record is an object that contains one or more fields of data.
10323 ** the key of an index. A blob encoding of a record is created by
10341 #define UNPACKED_INCRKEY 0x01 /* Make this key an epsilon larger */
10346 ** Each SQL index is represented in memory by an
10360 ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].
10361 ** The second column to be indexed (c1) has an index of 0 in
10368 ** algorithm to employ whenever an attempt is made to insert a non-unique
10412 ** Each token coming out of the lexer is an instance of
10413 ** this structure. Tokens are also used as part of an expression.
10484 ** Each node of an expression in the parse tree is an instance
10488 ** as opcodes here. For example, the parser defines TK_GE to be an integer
10493 ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,
10496 ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),
10502 ** Expr.x.pList is a list of arguments if the expression is an SQL function,
10503 ** a CASE expression or an IN expression of the form "<lhs> IN (<y>, <z>...)".
10504 ** Expr.x.pSelect is used if the expression is a sub-select or an expression of
10513 ** expression is used as a result in an aggregate SELECT, then the
10517 ** If the expression is an unbound variable marker (a question mark
10521 ** If the expression is a subquery then Expr.iColumn holds an integer
10534 ** help reduce memory requirements, sometimes an Expr object will be
10540 ** an Expr object is truncated. When EP_Reduced is set, then all
10599 #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
10617 ** flag on an expression structure. This flag is used for VV&A only. The
10638 ** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
10639 ** and an Expr struct with the EP_TokenOnly flag set.
10655 ** list of "ID = expr" items in an UPDATE. A list of expressions can
10675 ** the parse tree for an expression and the span of input text for an
10693 ** column names after a table name in an INSERT statement. In the statement
10728 ** is modified by an INSERT, DELETE, or UPDATE statement. In standard SQL,
10857 #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
10981 #define SRT_Union 1 /* Store result as keys in an index */
10991 #define SRT_Set 7 /* Store results as keys in an index */
10992 #define SRT_Table 8 /* Store result as data with an automatic rowid */
11034 ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
11089 u8 checkSchema; /* Causes schema cookie check after an error */
11096 u8 mayAbort; /* True if statement may throw an ABORT exception */
11173 ** Return true if currently inside an sqlite3_declare_vtab() call.
11195 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
11196 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
11201 * Each trigger present in the database schema is stored as an instance of
11221 IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger,
11230 ** A trigger is either a BEFORE or an AFTER trigger. The following constants
11254 * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then
11257 * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
11259 * pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ...
11425 ** FTS4 is really an extension for FTS3. It is enabled using the
11427 ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
12146 ** sqlite3MemdebugSetType() sets the "type" of an allocation to one of
12158 ** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means
12270 ** Bit 0x40 is set if the character non-alphanumeric and can be used in an
12273 ** part of an identifier is 0x46.
12392 ** 0x40000000 results in an incompatible database file format!
12850 ** executed by a virtual machine. Each instruction is an instance
12873 ** Every cursor that the virtual machine has open is represented by an
12890 Bool isIndex; /* True if an index containing keys only - no data */
12900 /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or
13000 ** If the MEM_Null flag is set, then the value is an SQL NULL value.
13011 #define MEM_Int 0x0004 /* Value is an integer */
13027 #define MEM_Ephem 0x1000 /* Mem.z points to an ephemeral string */
13028 #define MEM_Agg 0x2000 /* Mem.z points to an agg function context */
13069 ** The "context" argument for a installable function. A pointer to an
13108 ** is really a pointer to an instance of this structure.
13124 Mem *pResultSet; /* Pointer to an array of results */
13143 u8 errorAction; /* Recovery action to do in case of an error */
13166 FILE *trace; /* Write an execution trace here, if not NULL */
13367 ** This implementation assumes that reading or writing an aligned
13368 ** 32-bit integer is an atomic operation. If that assumption is not true,
13423 ** Return an approximation for the amount of memory currently used
13445 ** *pCurrent gets an accurate estimate of the amount of memory used
13488 ** *pCurrent gets an accurate estimate of the amount of memory used
13672 ** A missing specifier is not considered an error.
13950 ** already, check for an MSVC build environment that provides
14005 ** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
14078 ** is in a system call (i.e. localtime()), then an error message is written
14079 ** to context pCtx. If the error is an unrecognized modifier, no error is
14926 ** ability to simulate a malloc failure, so that the handling of an
15046 ** abandons the current operation and returns an error code (usually
15208 ** If an equivalent interface exists by
15346 ** Like realloc(). Resize an allocation previously obtained from
15604 ** Given an allocation, find the MemBlockHdr for that allocation.
15623 ** to rounding up to an 8 byte boundary to ensure
15792 ** Change the size of an existing memory allocation.
15836 ** Set the "type" of an allocation.
15851 ** This routine is designed for use within an assert() statement, to
15852 ** verify the type of an allocation. For example:
15873 ** This routine is designed for use within an assert() statement, to
15874 ** verify the type of an allocation. For example:
16054 ** the chunk. In this way, the first chunk has an index of 1.
16096 ** True if we are evaluating an out-of-memory callback.
16220 ** Called when we are unable to satisfy an allocation of nBytes.
16288 ** or same size hash. In other words, *pRoot is an entry in either
16356 ** Look for an entry of the correct size in either the small
16418 ** Free an outstanding memory allocation.
16460 ** Return the size of an outstanding allocation, in bytes. The
16506 ** Change the size of an existing memory allocation
16726 ** that an application can, at any time, verify this constraint.
16736 ** A minimum allocation is an instance of the following structure.
16737 ** Larger allocations are an array of these structures where the
16814 ** Assuming mem5.zPool is divided up into an array of Mem5Link
16874 ** Return the size of an outstanding allocation, in bytes. The
16977 ** Free an outstanding memory allocation.
17059 ** Change the size of an existing memory allocation.
17066 ** of two. If nBytes==0 that means that an oversize allocation
17067 ** (an allocation larger than 0x40000000) was requested and this
17280 ** and uninitialized so that we can assert() if there is an attempt to
17390 ** is not currently entered. If a NULL pointer is passed as an argument
17564 ** mutex must be exited an equal number of times before another thread
17651 ** Each recursive mutex is an instance of the following structure.
17677 ** SQLite will unwind its stack and return an error. The argument
17839 ** mutex must be exited an equal number of times before another thread
17937 ** Each recursive mutex is an instance of the following structure.
17959 ** not an atomic operation, then these routines might delivery
17989 ** will unwind its stack and return an error. The argument
18102 ** mutex must be exited an equal number of times before another thread
18274 ** Each recursive mutex is an instance of the following structure.
18296 ** Here is an interesting observation: Win95, Win98, and WinME lack
18399 ** will unwind its stack and return an error. The argument
18487 ** mutex must be exited an equal number of times before another thread
18514 ** is used it is merely an optimization. So it is OK for it to always
18646 ** (so that a range test can be used to determine if an allocation
18888 ** signed integer value might cause an integer overflow inside of the
18919 ** case by setting scratchAllocOut to 1 when an allocation
18932 ** structures that would not normally fit on the stack of an
19093 ** Change the size of an existing memory allocation
19186 ** This is an important assumption. There are many places in the
19371 ** an historical reference. Most of the "enhancements" have been backed
19409 ** An "etByte" is an 8-bit unsigned value.
19415 ** by an instance of the following structure
20130 ** Reset an StrAccum string. Reclaim all malloced memory.
20193 ** to modify an existing string. For example:
20408 ** number generator) not as an encryption device.
20634 ** * This routine accepts an infinite number of different UTF8 encodings
20684 ** desiredEnc. It is an error if the string is already of the desired
20921 ** NULL is returned if there is an allocation error.
21093 ** this implementation is provided as an alternative.
21101 ** which depend on an exact implementation of IEEE or ISO
21151 ** %d Insert an integer
21179 ** Add an error message to pParse->zErrMsg and increment pParse->nErr.
21184 ** %d Insert an integer
21189 ** compiling an SQL statement (i.e. within sqlite3_prepare()). The
21213 ** Convert an SQL-style quoted string into a normal string by removing
21286 ** The string z[] is an text representation of a real number.
21321 *pResult = 0.0; /* Default return value, in case of an error */
21573 ** If zNum represents an integer that will fit in 32-bits, then set
21617 ** string is not an integer, just return 0.
21959 /* For following code (kept for historical record only) shows an
22038 ** Translate a single byte of Hex into an integer.
22077 ** Log an error that is an API call on a connection pointer that should
22100 ** used as an argument to sqlite3_errmsg() or sqlite3_close().
22136 ** Return 0 on success. Or if the operation would have resulted in an
22367 /* This function (for internal use only) locates an element in an
22431 /* Attempt to locate an element of the hash table pH with a key
22451 /* Insert an element into the hash table pH. The key is pKey,nKey
22714 ** OS layer for an embedded system, if you use this file as an example,
23064 ** Truncate an open file to a specified size
23074 ** file so that it consists of an integer number of chunks (i.e. the
23200 APIRET res = NO_ERROR; /* Result of an OS/2 lock call */
23282 /* Acquire an EXCLUSIVE lock
23663 ** Structure used internally by this VFS to record the state of an
23757 ** Find an os2ShmNode in global list or allocate a new one, if not found.
23934 ** If an error occurs, an error code is returned and *pp is set to NULL.
24140 ** If any sibling already holds an exclusive lock, go ahead and return
24222 ** This vector defines all the methods that can operate on an
24266 /* It's odd to simulate an io-error here, but really this is just
24529 /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
24583 * symbol with an extra underscore, that might be needed depending
24734 ** strerror_r() on unix). After an error is returned by an OS
24748 ** Not supplying an error message will have no adverse effect
24749 ** on SQLite. It is fine to have an implementation that never
24750 ** returns an error message:
24757 ** However if an error message is supplied, it will be incorporated
24908 ** on an older machine (ex: RedHat 6.0). If you compile on RedHat 7.2
25008 ** structure are used to store the file descriptor while waiting for an
25790 ** A pointer to an instance of the following structure can be used as a
25874 /* Search for an existing entry that matching the canonical name.
25936 ** an exclusive lock on fd1, then try to get an exclusive lock
25961 ** The sqlite3_file structure for POSIX is no longer just an integer file
25969 ** file is unlocked. cnt==-1 means the file has an exclusive lock.
25975 ** a locked and an unlocked state.
25983 ** When an attempt is made to close an unixFile, if there are
26030 ** structure contains a pointer to an instance of this object and this
26063 ** It is invoked after an error occurs in an OS function and errno has been
26098 ** strerror_r(), which always writes an error message into aErr[].
26101 ** available, the error message will often be an empty string. Not a
26138 ** So we don't even try to recover from an EINTR. Just log the error
26196 ** return value might be uninitialized if an error occurs.
26201 ** Return an appropriate error code.
26229 /* On OS X on an msdos filesystem, the inode number is reported
26234 ** an ASCII 'S' character which also happens to be the first byte
26288 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
26335 ** ever obtained is an exclusive lock, and it is obtained exactly once
26502 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
26560 /* We are trying for an exclusive lock but another thread in this
26642 ** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED
26746 ** process is holding an incompatible lock. If it does, this
26750 ** an assert to fail). */
26770 /* Decrement the shared lock counter. Release the lock using an
26933 ** Nevertheless, a dotlock is an appropriate locking mode for use if no
26938 ** The existance of a lock directory implies an EXCLUSIVE lock. All other
26952 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27029 /* grab an exclusive lock */
27125 ** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite
27152 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27177 /* unlock failed with an error */
27249 /* grab an exclusive lock */
27293 /* shared can just be set because we always have an exclusive */
27342 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27461 /* shared can just be set because we always have an exclusive */
27537 ** This is a utility for setting or clearing a bit-range lock on an
27586 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27719 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
27771 /* We are trying for an exclusive lock but another thread in this
27789 /* Acquire an EXCLUSIVE lock */
27908 /* Decrement the shared lock counter. Release the lock using an
28248 ** unix systems. The following procedure is an attempt to make
28254 ** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash
28266 ** as far as SQLite is concerned, an fdatasync() is always adequate.
28308 /* If the FULLFSYNC failed, fall back to attempting an fsync().
28311 ** isn't supported for this file system. So, attempt an fsync
28341 ** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM
28342 ** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined
28444 ** Truncate an open file to a specified size
28453 ** file so that it consists of an integer number of chunks (i.e. the
28539 ** or an error number on failure". See the manpage for details. */
28589 ** Information and control of an open file handle.
28687 ** Object used to represent an shared memory buffer.
28734 ** Structure used internally by this VFS to record the state of an
28876 ** Another approach to is to use files in /dev/shm or /dev/tmp or an
28885 ** option results in an incompatible build of SQLite; builds of SQLite
28896 ** that means that an exclusive lock is held on the database file and
28915 /* Check to see if a unixShmNode object already exists. Reuse an existing
28925 ** a new *-shm file is created, an attempt will be made to create it
29037 ** If an error occurs, an error code is returned and *pp is set to NULL.
29223 ** If any sibling already holds an exclusive lock, go ahead and return
29708 /* If an error occured in findInodeInfo(), close the file descriptor
29862 /* It's odd to simulate an io-error here, but really this is just
29901 ** Search for an unused file descriptor that was opened on the database
29919 /* Do not search for an unused file descriptor on vxworks. Not because
29922 ** not to risk breaking vxworks support for the sake of such an obscure
29928 ** almost certain that an open() call on the same path will also fail.
29929 ** For this reason, if an error occurs in the stat() call here, it is
29931 ** descriptor on the same path, fail, and return an error to SQLite.
29962 ** written to *pMode. If an IO error occurs, an SQLite error code is
29966 ** an indication to robust_open() to create the file using
30407 /* It's odd to simulate an io-error here, but really this is just
30668 ** shared range is taken for an EXCLUSIVE lock):
30734 ** by taking an sqlite-style shared lock on the conch file, reading the
30740 ** host ID and/or proxy path, then the lock is escalated to an exclusive
30755 ** The shared lock and an open file descriptor are maintained until
31033 ** Takes an open conch file, copies the contents to a new path and then moves
31225 do { /* in case we need to try again for an :auto: named lock file */
31277 /* We are trying for an exclusive lock but another thread in this
31522 ** Takes an already filled in unix file and alters it so all file locking
31684 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
31832 ** The following macro defines an initializer for an sqlite3_vfs object.
31848 ** database file and tries to choose an locking method appropriate for
32188 BOOL bExclusive; /* Indicates an exclusive lock has been obtained */
32563 ** an ANSI string regardless of the _UNICODE setting */
32846 ** Here is an interesting observation: Win95, Win98, and WinME lack
32912 ** Change the size of an existing memory allocation
32940 ** Return the size of an outstanding allocation, in bytes.
33101 ** Convert an ANSI string to Microsoft Unicode, based on the
33268 ** This routine is invoked after an error occurs in an OS function.
33321 ** to give up with an error.
33541 /* Wanting an exclusive lock? */
33605 /* Releasing a reader lock or an exclusive lock */
33607 /* Did we have an exclusive lock? */
33706 ** whether an error has actually occured, it is also necessary to call
33725 ** It is reported that an attempt to close a handle might sometimes
33730 ** giving up and returning an error.
33862 ** Truncate an open file to a specified size
33874 ** file so that it consists of an integer number of chunks (i.e. the
34159 /* Acquire an EXCLUSIVE lock
34457 ** Structure used internally by this VFS to record the state of an
34619 /* Look to see if there is an existing winShmNode that can be used.
34797 ** If any sibling already holds an exclusive lock, go ahead and return
34871 ** If an error occurs, an error code is returned and *pp is set to NULL.
35011 ** This vector defines all the methods that can operate on an
35074 /* It's odd to simulate an io-error here, but really this is just
35375 ** up and returning an error.
35450 /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
35536 /* It's odd to simulate an io-error here, but really this is just
35758 ** strerror_r() on Unix). After an error is returned by an OS
35772 ** Not supplying an error message will have no adverse effect
35773 ** on SQLite. It is fine to have an implementation that never
35774 ** returns an error message:
35781 ** However if an error message is supplied, it will be incorporated
35853 ** This file implements an object that represents a fixed-length
35905 ** (an arbitrary prime)in the hash function provided
35913 ** A bitmap is an instance of the following structure.
35994 ** Set the i-th bit. Return 0 on success and an error code if
35999 ** that can go wrong with an insert, assuming p and i are valid.
36134 ** Let V[] be an array of unsigned characters sufficient to hold
36135 ** up to N bits. Let I be an integer between 0 and N. 0<=I<N.
36144 ** This routine runs an extensive test of the Bitvec code.
36146 ** The input is an array of integers that acts as a program
36169 ** an error is returned. If they are the same, zero is returned.
36267 ** A complete page cache is an instance of this structure.
36300 ** is not, either fail an assert or return zero. Otherwise, return
36376 ** being used for an in-memory database, this function is a no-op.
36811 ** Return the number of references to the page supplied as an argument.
36900 ** pages when they are under memory pressure. A PGroup is an instance of
36929 /* Each page cache is an instance of the following object. Every
36932 ** is an instance of this object.
36962 ** Each cache entry is represented by an instance of the following
37006 ** (2) even if an incorrect value is read, no great harm is done since this
37007 ** is really just an optimization. */
37030 ** verb to sqlite3_config(). Parameter pBuf points to an allocation large
37098 ** Free an allocated buffer obtained from pcache1Alloc().
37212 ** Free an allocated buffer obtained from sqlite3PageMalloc().
37327 ** Remove the page supplied as an argument from the hash table
37538 ** For a non-purgeable cache (a cache used as the storage for an in-memory
37598 /* Step 1: Search the hash table for an existing entry. */
37613 ** local variable here. Delaying the initialization of pGroup is an
37712 /* It is an error to call this function if the page is already
37815 ** already provided an alternative.
37905 ** This module implements an object we call a "RowSet".
37908 ** are inserted into the RowSet in an arbitrary order. Inserts
37926 ** TEST checks to see if an element is already in the RowSet. SMALLEST
37930 ** allocated in chunks so most INSERTs do no allocation. There is an
37936 ** in the batch number. In other words, if an INSERT occurs between
37945 ** The cost of an INSERT is roughly constant. (Sometime new memory
37946 ** has to be allocated on an INSERT.) The cost of a TEST with a new
37952 ** There is an added cost of O(N) when switching between TEST and
37969 ** Each entry in a RowSet is an instance of the following object.
37989 ** A RowSet in an instance of the following structure.
38012 ** an assertion fault occurs.
38014 ** If N is larger than the minimum, use the surplus as an initial
38194 ** list contains too few elements, then construct an incomplete tree
38403 ** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and
38424 /* Return an integer that records the current (uncommitted) write
38455 /* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)
38517 ** (3) Writes to the database file are an integer multiple of the page size
38521 ** an integer multiple of the page size in length or are taken from the
38582 ** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file
38675 ** If the connection is running with locking_mode=exclusive, an attempt
38676 ** is made to obtain an EXCLUSIVE lock on the database file.
38731 ** commit the transaction. If an error did occur, the caller will need
38736 ** The ERROR state is entered when an IO or disk-full error (including
38744 ** For example, if an IO error occurs while performing a rollback,
38745 ** the contents of the page-cache may be left in an inconsistent state.
38751 ** instead of READER following such an error.
38754 ** to read or write data returns an error. Eventually, once all
38782 ** automatically attempt a rollback, as it assumes that an error in a
38783 ** read-only statement cannot leave the pager in an internally inconsistent
38789 ** * The pager is not an in-memory pager.
38820 ** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY
38829 ** This is usually safe. If an xUnlock fails or appears to fail, there may
38837 ** fails at this point and the pager is left holding an EXCLUSIVE lock, this
38843 ** return true because the caller itself is holding an EXCLUSIVE lock (but
38845 ** a hot-journal may be mistaken for a journal being created by an active
38854 ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
38881 ** such a system. This is currently an undocumented limit.
38911 ** A open page cache is an instance of struct Pager. A description of
38941 ** can only happen if an exclusive lock is held on the database file.
38942 ** It is cleared (set to false) whenever an exclusive lock is
38972 ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the
38997 ** is opened as an in-memory journal file. If false, then in-memory
39012 ** is not an integer multiple of the page-size, the value stored in
39169 ** file after power is restored. If an attempt is then made
39171 ** sanity checking data is an attempt to discover the garbage in the
39181 ** garbage data came from an obsolete journal file, the checksums might
39202 ** The macro MEMDB is true if we are dealing with an in-memory database.
39271 ** as if it has an exclusive lock on the database file. It never updates
39283 /* Check that MEMDB implies noSync. And an in-memory journal. Since
39284 ** this means an in-memory pager performs no IO at all, it cannot encounter
39288 ** is therefore not possible for an in-memory pager to enter the ERROR
39389 ** containing the state of the Pager object passed as an argument. This
39390 ** is intended to be used within debuggers. For example, as an alternative
39468 ** that is read in *pRes. Return SQLITE_OK if everything worked, or an
39490 ** on success or an error code is something goes wrong.
39505 ** UNKNOWN_LOCK for an explanation of this.
39531 ** See the comment above the #define of UNKNOWN_LOCK for an explanation
39558 ** an error to call this function if pPager is opened on an in-memory
39614 ** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES
39615 ** is defined, and NDEBUG is not defined, an assert() statement checks
39654 ** If an error occurs while reading from the journal file, an SQLite
39740 ** If an IO error occurs, abandon processing and return the IO error code.
39908 ** cannot be read from the journal file an error code is returned.
39935 ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise,
39950 ** of the transaction. Return an error code if anything goes wrong.
40070 ** an error occurs, return the error code to the caller.
40217 ** above the #define for UNKNOWN_LOCK for an explanation of why this
40253 ** This function is called whenever an IOERR or FULL error that requires
40289 ** after rollback of a hot-journal, or if an error occurs while opening
40307 ** Journal file descriptor is simply closed. This destroys an
40330 ** SQLITE_OK is returned if no error occurs. If an error occurs during
40343 /* Do nothing if the pager does not have an open write transaction
40351 ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE
40387 ** the database file, it will do so using an in-memory journal.
40449 ** If the pager has not already entered the ERROR state, but an IO or
40477 ** Each byte is interpreted as an 8-bit unsigned integer.
40479 ** Changing the formula used to compute this checksum results in an
40533 ** and played back, then SQLITE_OK is returned. If an IO error occurs
40547 ** allocated by this function. If this is the case and an allocation fails,
40577 ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback
40586 ** file. Return an error code to the caller if an IO error occurs.
40634 ** and a page is moved during an incremental vacuum then the page may
40653 ** database file without an entry in the rollback journal that can
40708 ** The solution is to add an in-memory page to the cache containing
40727 ** of an internal error resulting in an automatic call to
40742 ** back as part of a savepoint (or statement) rollback from an
40805 ** If an IO error within this function, an error code is returned. This
40806 ** function allocates memory by calling sqlite3Malloc(). If an allocation
40922 ** If successful, return SQLITE_OK. If an IO error occurs while modifying
41027 ** Each entry in the journal is an instance of the 8th item.
41050 ** If an I/O or malloc() error occurs, the journal-file is not deleted
41051 ** and an error code is returned.
41085 ** TODO: Technically the following is an error because it assumes that
41104 ** pager_playback_one_page() call returns SQLITE_DONE or an IO error
41208 /* If this playback is happening automatically as a result of an IO or
41258 ** If an IO error occurs, then the IO error is returned to the caller.
41298 ** For an encrypted database, the situation is more complex: bytes
41324 ** This is an unconditional update. See also the pager_incr_changecounter()
41353 ** return an SQLite error code. Otherwise, SQLITE_OK.
41512 ** in pages is stored in *pnPage. Otherwise, an error code (perhaps
41530 ** of the database file is not an integer multiple of the page-size,
41569 ** Return SQLITE_OK or an error code.
41572 ** function. Because an EXCLUSIVE lock on the db file is required to delete
41574 ** between the xAccess() below and an xDelete() being executed by some
41778 ** that an inopertune power failure could leave the journal
41795 ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL
41801 ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an
41887 ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE
41918 ** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).
41927 ** * the database is either not an in-memory database or it is
41928 ** an in-memory database that currently consists of zero pages.
41949 ** At one point this function returned an error if the pager was in
42064 ** the Pager object. There has not been an opportunity to transition
42103 ** Return SQLITE_OK on success and an error code if we cannot obtain
42186 ** an SQLite error code.
42208 ** This function always succeeds. If a transaction is active an attempt
42209 ** is made to roll it back. If an error occurs during the rollback
42230 ** If this is not done, then an unsynced portion of the open journal
42234 ** If an error occurs while trying to sync the journal, shift the pager
42290 ** * If the journal file is an in-memory journal file, no action need
42313 ** page currently held in memory before returning SQLITE_OK. If an IO
42335 /* This block deals with an obscure problem. If the last connection
42431 ** be NULL, representing an empty list. In this case this function is
42436 ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,
42455 ** If everything is successful, SQLITE_OK is returned. If an IO error
42456 ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
42567 ** This function returns SQLITE_OK if everything is successful, an IO
42613 ** (cast as a void*). The pager is always 'purgeable' (not an in-memory
42624 ** SQLITE_OK returned. If an IO error occurs while trying to make the
42644 ** Spilling is also prohibited when in an error state since that could
42735 ** This can be used to implement an in-memory database.
42750 ** the new pager object. If an error occurs, *ppPager is set to NULL
42768 int memDb = 0; /* True if this is an in-memory file */
42781 ** is the maximum space required for an in-memory journal file handle
42793 /* Set the output variable to NULL in case an error occurs. */
42803 /* Compute and store the full pathname in an allocated buffer pointed
42941 ** This branch is also run for an in-memory database. An in-memory
42943 ** disk and uses an in-memory rollback journal.
42960 /* If an error occurred in either of the blocks above, free the
43049 ** exists, that is probably an old journal left over from a prior
43063 ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying
43138 ** its has a zero header, that might be due to an I/O error, or
43143 ** with it under an EXCLUSIVE lock where we do not need to
43166 ** on the database file), then an attempt is made to obtain a
43176 ** then an attempt is made to clear the error state by discarding
43180 ** If everything is successful, SQLITE_OK is returned. If an IO error
43218 /* Get an EXCLUSIVE lock on the database file. At this point it is
43272 ** an inconsistent cache. Sync the hot journal before playing
43289 /* This branch is taken if an error occurs while trying to open
43290 ** or roll back a hot-journal while holding an EXCLUSIVE lock. The
43294 ** UNKNOWN_LOCK above for an explanation).
43331 ** detected. The chance of an undetected change is so small that
43406 ** choose not to allocate a new page object and may reuse an existing
43438 ** an appropriate error code is returned and *ppPage is set to NULL.
43444 ** has to go to disk, and could also playback an old journal if necessary.
43464 /* If the pager is in the error state, return an error immediately.
43473 /* Either the call to sqlite3PcacheFetch() returned an error or the
43483 /* In this case the pcache already contains an initialized copy of
43607 ** an IO error code if opening or writing the journal file fails.
43619 ** an error state. */
43681 ** an EXCLUSIVE lock. If such a lock is already held, no locking
43685 ** within this transaction will be opened as an in-memory file. This
43689 ** sub-journal is implemented in-memory if pPager is an in-memory database,
43703 /* If the pager is configured to use locking_mode=exclusive, and an
43715 ** PAGER_RESERVED state. Otherwise, return an error code to the caller.
43722 ** is true, then immediately upgrade this to an EXCLUSIVE lock. The
43736 ** when it has an open transaction, but never to DBMOD or FINISHED.
43780 /* If an error has been previously detected, report the same error
43796 ** an error might occur and the pager would end up in WRITER_LOCKED state
43814 /* The transaction journal now exists and we have a RESERVED or an
43834 /* Even if an IO or diskfull error occurs while journalling the
43838 ** in the database file. And if an IO error occurs while doing so,
43907 ** If an error occurs, SQLITE_NOMEM or an IO error code is returned
43937 ** an integer power of 2. It sets variable pg1 to the identifier
44044 ** See also the pager_write_changecounter() routine that does an
44055 ** by writing an updated version of page 1 using a call to the
44133 ** function returns SQLITE_OK. Otherwise, an IO error code is returned.
44153 ** Otherwise, if the connection does not already have an EXCLUSIVE lock on
44154 ** the database file, an attempt is made to obtain one.
44158 ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is
44193 ** passed to an sqlite3PagerCommitPhaseOne() call.
44224 /* If this is an in-memory db, or no pages have been written to, or this
44399 ** If an error occurs, an IO error code is returned and the pager
44445 ** state if an error occurs.
44504 /* If an error occurs during a ROLLBACK, we can no longer trust the pager
44591 ** Return true if this is an in-memory pager.
44603 ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error
44604 ** occurs while opening the sub-journal file, then an IO error code is
44678 ** In any case, all savepoints with an index greater than iSavepoint
44683 ** or an IO error code if an IO error occurs while rolling back a
44710 /* Only truncate if it is an in-memory sub-journal. */
44817 ** This function may return SQLITE_NOMEM or an IO error code if an error
44832 /* In order to be able to rollback, an in-memory database must journal
44893 /* Do not discard pages from an in-memory database since we might
44905 /* For an in-memory database, make sure the original page continues
45031 /* Do allow the journalmode of an in-memory database to be set to
45063 ** here is an optimization only.
45136 ** uses it opaquely as an argument to sqlite3BackupRestart() and
45145 ** Unless this is an in-memory or temporary database, clear the pager cache.
45186 ** Attempt to take an exclusive lock on the database file. If a PENDING lock
45205 ** exclusive-locking mode when this function is called, take an EXCLUSIVE
45225 ** (e.g. due to malloc() failure), return an error code.
45243 ** file (not a temp file or an in-memory database), and the WAL file
45244 ** is not already open, make an attempt to open it now. If successful,
45245 ** return SQLITE_OK. If an error occurs or the VFS used by the pager does
45246 ** not support the xShmXXX() methods, return an error code. *pbOpen is
45287 ** Before closing the log file, this function attempts to take an
45288 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
45314 /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on
45386 ** transferred back into the database file in an operation called a
45438 ** an even number of unsigned 32-bit integers: x[0] through x[N]. The
45501 ** use an architecture-specific format; it does not have to be cross-platform.
45510 ** The wal-index consists of a header region, followed by an one or
45525 ** that allows readers to query an index block for a specific page number.
45526 ** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE
45550 ** prior to finding a match is 1. Each entry of the hash table is an
45551 ** 1-based index of an entry in the mapping section of the same
45565 ** reached) until an unused hash slot is found. Let the first unused slot
45568 ** the search is guaranteed to eventually hit an unused entry. Let
45594 ** slots in the hash table and so the first reader will get an answer as
45698 ** is holding an exclusive lock on WAL_READ_LOCK(K). Thus, the value of
45706 ** largest value and will increase an unused aReadMark[] to mxFrame if there
45707 ** is not already an aReadMark[] equal to mxFrame. The exception to the
45752 ** file are calculated by treating all data as an array of 32-bit
45768 ** An open write-ahead log file is represented by an instance of the
45814 ** an array of HASHTABLE_NSLOT elements of the following type.
45819 ** This structure is used to implement an iterator that loops through
45828 ** walIteratorNext() - Step an iterator,
45829 ** walIteratorFree() - Free an iterator.
45875 ** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,
45876 ** then an SQLite error code is returned and *ppPage is set to 0.
45946 ** Generate or extend an 8 byte checksum based on the data in
46109 ** a part of an ordinary build.
46328 ** Set an entry in the wal-index that will map database page number
46413 ** This routine first tries to establish an exclusive lock on the
46427 /* Obtain an exclusive lock on all byte in the locking range not already
46563 /* If more than one frame was recovered from the log file, report an
46582 ** Close an open wal-index.
46608 ** *ppWal is set to point to a new WAL handle. If an error occurs,
46609 ** an SQLite error code is returned and *ppWal is left unmodified.
46638 /* Allocate an instance of struct Wal to return. */
46862 ** Free an iterator allocated by walIteratorInit().
46874 ** return SQLITE_OK. Otherwise, return an error code. If this routine
46875 ** returns an error, the value of *pp is undefined.
46986 ** in response to an sqlite3_wal_checkpoint() request or the equivalent.
47135 /* If this is an SQLITE_CHECKPOINT_RESTART operation, and the entire wal
47160 ** it to exactly nMax bytes. If an error occurs while doing so, ignore it.
47189 /* If an EXCLUSIVE lock can be obtained on the database file (using the
47268 ** meaning it is possible that an inconsistent snapshot is read
47314 ** Otherwise an SQLite error code.
47322 ** wal-index header) is mapped. Return early if an error occurs here.
47388 ** On success return SQLITE_OK. On a permanent failure (such an
47389 ** I/O error or an SQLITE_BUSY because another process is running
47396 ** wal-index header has changed, *pChanged is set to 1 (as an indication
47404 ** race conditions after multiple WAL_RETRY returns, and after an excessive
47430 ** so it takes care to hold an exclusive lock on the corresponding
47454 ** is more of a scheduler yield than an actual delay. But on the 10th
47455 ** an subsequent retries, the delays start becoming longer and longer,
47548 /* There was once an "if" here. The extra "{" is to preserve indentation. */
47591 ** log-wrap (either of which would require an exclusive lock on
47672 ** in this case as an optimization. Likewise, if pWal->readLock==0,
47681 /* Search the hash table or tables for an entry matching page number
47848 ** Otherwise, if the callback function does not return an error, this
47868 ** (b) has an outstanding reference, then xUndo is either a no-op
47887 ** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32
47902 ** the values in the aWalData[] array. aWalData must point to an array
47942 ** if an error occurs.
48140 ** an out-of-order write following a WAL restart could result in
48395 ** upgrade to exclusive-mode following such an error.
48506 ** bytes are stored on overflow pages. The payload for an entry
48516 ** Each page can be either a btree page, a freelist page, an overflow
48562 ** payload is spilled to overflow pages. Once an overflow page is allocated,
48725 ** As each page of the file is loaded into memory, an instance of the following
48790 ** A database connection contains a pointer to an instance of
48912 #define BTS_EXCLUSIVE 0x0020 /* pWriter has an exclusive lock */
48933 ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
48976 u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */
49002 ** A unrecoverable error (an I/O error or a malloc failure) has occurred
49004 ** cursor. The error has left the cache in an inconsistent state.
49054 ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
49085 ** within an expression that is an argument to another macro
49407 ** Including a description of file format and an overview of operation.
49428 ** Extract a 2-byte big-endian integer from an array of unsigned bytes.
49492 **** This function is only used as part of an assert() statement. ***
49502 ** When writing to an index that resides in a sharable database, the
49516 int isIndex, /* True if iRoot is the root of an index b-tree */
49533 /* If the client is reading or writing an index and the schema is
49623 /* If requesting a write-lock, then the Btree must have an open write
49625 ** must be an open write transaction on the file itself.
49635 /* If some other connection is holding an exclusive lock, the
49706 /* First search the list for an existing lock on this table. */
49746 ** This function assumes that Btree p has an open read or write
49885 ** The BtShared.pHasContent bitvec exists to work around an obscure
49968 /* If this is an intKey table, then the above call to BtreeKeySize()
49970 ** all that is required. Otherwise, if pCur is not open on an intKey
50041 const void *pKey, /* Packed key if the btree is an index */
50102 ** This routine returns an error code if something goes wrong. The
50146 ** Write an entry into the pointer map.
50152 ** a no-op. If an error occurs, the appropriate error code is written
50201 ** Read an entry from the pointer map.
50331 ** way will result in an incompatible file format.
50374 ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of
50431 ** to an overflow page, insert an entry into the pointer-map
50535 ** an error code (usually SQLITE_CORRUPT).
50990 ** If an error occurs, then the value *ppPage is set to is undefined. It
50991 ** may remain unchanged, or it may be set to an invalid value.
51049 /* pPage might not be a btree page; it might be an overflow page
51074 ** then an ephemeral database is created. The ephemeral database might
51079 ** If zFilename is ":memory:" then an in-memory database is created
51086 ** and we are in shared cache mode, then the open will fail with an
51106 /* True if opening an ephemeral, temporary database */
51109 /* Set the variable isMemdb to true for an in-memory database, or
51149 ** If this Btree is a candidate for shared cache, try to find an
51250 /* If the magic name ":memory:" will create an in-memory database, then
51341 ** default value. Except, when opening on an existing shared pager-cache,
51396 ** Make sure pBt->pTmpSpace points to an allocation of
51414 ** Close an open database and invalidate all cursors.
51481 ** an abrupt power failure when synchronous is off, the database
51482 ** could be left in an inconsistent and unrecoverable state.
51815 ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow
51859 ** If pBt points to an empty file then convert that empty file
51923 ** If an initial attempt to acquire the lock fails because of lock contention
52044 /* If the db-size header field is incorrect (as it may be if an old
52125 ** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow
52128 ** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next
52222 ** If pDbPage is an overflow page, then the first 4 bytes may store a
52268 ** Perform a single step of an incremental-vacuum. If successful,
52278 ** it returns SQLITE_DONE or an error, and that nFin is the
52388 ** It performs a single unit of work towards an incremental vacuum.
52392 ** SQLITE_OK is returned. Otherwise an SQLite error code.
52416 ** is commited for an auto-vacuum database.
52579 ** Normally, if an error occurs while the pager layer is attempting to
52580 ** finalize the underlying journal file, this function returns an error and
52585 ** functions return code. So, even if an error occurs in the pager layer,
52693 ** in an error.
52754 ** A statement sub-transaction is implemented as an anonymous savepoint. The
52771 ** an index greater than all savepoints created explicitly using
52822 ** the caller is assumed to have an open write transaction.
52840 ** 4: There must be an active transaction.
52942 ** The cache is initialized to zero, indicating an invalid cache.
53090 ** to return an integer result code for historical reasons.
53101 ** Given the page number of an overflow page in the database (parameter
53106 ** If an error occurs an SQLite error code is returned. Otherwise:
53185 ** SQLITE_OK is returned on success, otherwise an error code.
53227 ** Once an overflow page-list cache has been allocated, it may be
53230 ** mode, the following events may invalidate an overflow page-list cache.
53234 ** * Creating a table (may require moving an overflow page).
53262 /* Trying to read or write past the end of the data is an error */
53410 ** Return SQLITE_OK on success or an error code if anything goes
53427 ** Return SQLITE_OK on success or an error code if anything goes
53459 ** This routine is an optimization. It is common for the entire key
53548 ** if an intkey page appears to be the parent of a non-intkey page, or
53579 ** Page pParent is an internal (non-leaf) tree page. This function
53649 ** structure the flags byte is set to 0x02 or 0x0A, indicating an index
53688 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
53690 ** return an SQLITE_CORRUPT error. */
53839 /* Move the cursor so that it points to an entry near the key
53846 ** If an exact match is not found, then the cursor is always
53848 ** were present. The cursor might point to an entry that comes
53856 ** *pRes<0 The cursor is left pointing at an entry that
53860 ** *pRes==0 The cursor is left pointing at an entry that
53863 ** *pRes>0 The cursor is left pointing at an entry that
53955 ** the maximum number of record bytes stored on an index B-Tree
54049 ** Return TRUE if the cursor is not pointing at an entry of the table.
54057 ** have been deleted? This API will need to change to return an error code
54207 ** an error. *ppPage and *pPgno are undefined in the event of an error.
54208 ** Do not invoke sqlite3PagerUnref() on *ppPage if an error is returned.
54211 ** locate a page close to the page number "nearby". This can be used in an
54537 /* If the database supports auto-vacuum, write an entry in the pointer-map
54656 /* 0 is not a legal page number and page 1 cannot be an
54669 /* There is no reason any cursor should have an outstanding reference
54670 ** to an overflow page belonging to a cell that is being deleted/updated.
54672 ** must not really be an overflow page and the database must be corrupt.
54783 ** overflow page is being allocated, add an entry to the pointer-map
54917 ** nSkip is non-zero, then pCell may not point to an invalid memory location
54948 ** malformed cell from a leaf page to an interior page, if the cell size
54999 /* The cell may contain a pointer to an overflow page. If so, write
55121 /* If this is an auto-vacuum database, update the pointer map
55123 ** cell on the page to an overflow page. If either of these
55127 ** be marked as dirty. Returning an error code will cause a
55262 /* If this is an auto-vacuum database, update the pointer-map entries
55282 ** one or two in an effort to keep pages nearly full but not over full.
55304 ** size of a cell stored within an internal node is always less than 1/4
55585 ** This adjustment is more than an optimization. The packing above might
55763 ** Note that this can never happen in an SQLite data file, as all
55798 ** If this is an auto-vacuum database, the call to copyNodeContent()
55855 ** sibling page j. If the siblings are not leaf pages of an
55879 ** sibling page k. If the siblings are not leaf pages of an
55888 ** an overflow cell, or if the cell was located on a different sibling
55912 ** cause an assert() statement to fail. */
55944 ** page is then overwritten to make it an empty page with the right-child
55954 ** to call releasePage() on *ppChild exactly once. If an error occurs,
55955 ** an error code is returned and *ppChild is set to 0.
56133 ** For an INTKEY table, only the nKey value of the key is used. pKey is
56139 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
56140 ** a positive value if pCur points at an etry that is larger than
56154 int appendBias, /* True if this is likely an append */
56178 ** expecting an index b-tree, then the caller should be inserting blob
56179 ** keys with no associated data. If the cursor was opened expecting an
56184 /* If this is an insert into a table b-tree, invalidate any incrblob
56250 /* If no error has occured and pPage has an overflow cell, call balance()
56262 ** multiple records into an intkey b-tree using a single cursor (as can
56263 ** happen while processing an "INSERT INTO ... SELECT" statement), it
56266 ** entry in the table, and the next row inserted has an integer key
56353 ** by the child-page of the cell that was just deleted from an internal
56380 ** Otherwise, if the entry deleted was on an internal node page, then
56436 /* Creating a new table may probably require moving an existing database
56438 ** out to be an overflow page, delete all overflow page-map caches
56470 ** the new table (assuming an error did not occur). But we were
56616 ** If pnChange is not NULL, then table iTable must be an intkey table. The
56670 ** root page. If an open cursor was using this page a problem would
56795 /* If auto-vacuum is disabled in this build and this is an auto-vacuum
56840 ** Otherwise, if an error is encountered (i.e. an IO error or database
56841 ** corruption) an SQLite error code is returned.
56853 /* Unless an error occurs, the following loop runs one iteration for each
56860 /* If this is a leaf page or the tree is not an int-key tree, then
56904 /* An error has occurred. Return an error code. */
56949 ** reference to the page, add an error message to pCheck->zErrMsg.
56971 ** page iParent, pointer type ptrType. If not, append an error message
57001 ** Check the integrity of the freelist or of an overflow page list.
57303 ** an array of pages numbers were each page number is the root page of
57310 ** allocation errors, an error message held in memory obtained from
57395 ** This is an internal consistency check; an integrity check
57456 ** Return SQLITE_LOCKED if this or any other connection has an open
57525 ** btree as the argument handle holds an exclusive lock on the
57566 ** Argument pCsr must be a cursor opened for writing on an
57595 ** (e) the cursor points at a valid row of an intKey table.
57744 ** a NULL pointer and write an error message to pErrorDb.
57747 ** function. If an error occurs while doing so, return 0 and write an
57793 ** Create an sqlite3_backup process to copy the contents of zSrcDb from
57797 ** If an error occurs, NULL is returned and an error code and error message
57846 /* One (or both) of the named databases did not exist or an OOM
57865 ** Argument rc is an SQLite error code. Return true if this error is
57897 /* Catch the case where the destination is an in-memory database and the
57960 ** Return SQLITE_OK if everything is successful, or an SQLite error
57961 ** code if an error occurs.
58204 ** Release all resources associated with an sqlite3_backup* handle.
58306 ** detects that the database has been modified by an external database
58348 /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set
58362 ** within a single call (unless an error occurs). The assert() statement
58364 ** or an error code.
58398 ** stores a single value in the VDBE. Mem is an opaque structure visible
58404 ** If pMem is an object with a valid string representation, this routine
58521 ** If the given Mem* has a zero-filled tail, turn it into an ordinary
58578 ** user and the later is an internal programming error.
58617 ** Memory cell pMem contains the context of an aggregate function.
58621 ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK
58646 ** invoking an external callback, free it now. Calling this function
58668 ** Release any memory held by the Mem. This may leave the Mem in an
58686 ** there are reports that windows throws an expection
58711 ** a very large positive number to an integer results in a very large
58723 ** at representing the value that *pMem describes as an integer.
58724 ** If pMem is an integer, then the value is exact. If pMem is
58726 ** If pMem is a string or blob, then we make an attempt to convert
58727 ** it into a integer and return that. If pMem represents an
58728 ** an SQL-NULL value, return 0.
58754 ** double. If pMem is already a double or an integer, return its
58788 /* Only mark the value as an integer if
58930 ** Delete any previous value and set the value of pMem to be an
58994 ** Make an shallow copy of pFrom into pTo. Prior contents of
59037 ** pFrom contains an SQL NULL when this routine returns.
59080 /* If z is a NULL pointer, set pMem to contain an SQL NULL. */
59276 ** to read from the disk) then the pMem is left in an inconsistent state.
59332 ** If that is the case, then the result must be aligned on an even byte
59502 ** Change the string value of an sqlite3_value object
59515 ** Free an sqlite3_value object
59553 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
59644 ** If an out-of-memory error occurs while resizing the array, return
59672 ** Use the sqlite3VdbeResolveLabel() function to fix an address and
59719 ** Add an opcode that includes the p4 value as a pointer.
59736 ** Add an OP_ParseSchema opcode. This routine is broken out from
59751 ** Add an opcode that includes the p4 value as an integer.
59759 int p4 /* The P4 operand as an integer */
59767 ** Create a new symbolic label for an instruction that has yet to be
59769 ** label can be used as the P2 value of an operation. Later, when
59886 ** throw an ABORT exception (causing the statement, but not entire transaction
59897 ** Then check that the value of Parse.mayAbort is true if an
59900 ** part of an assert statement in the compiler. Similar to:
59943 ** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by
60267 /* Note: this cast is safe, because the origin data point was an int
60363 ** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as
60391 ** Compute a string that describes the P4 parameter for an opcode.
60519 ** that may be accessed by the VM passed as an argument. In doing so it also
60600 ** Release an array of N Mem elements
60616 /* This block is really an inlined version of sqlite3VdbeMemRelease()
60712 ** commandeer the 9th cell to use as storage for an array of pointers
60769 /* When an OP_Program opcode is encounter (the only opcode that has
60875 ** Print an IOTRACE message showing SQL content.
60995 ** the Vdbe becomes an independent entity and the Parse object can be
61041 ** an array to marshal SQL function arguments in.
61221 ** be called on an SQL statement before sqlite3_step().
61281 int nTrans = 0; /* Number of databases with an active write-transaction */
61295 ** required, as an xSync() callback may add an attached database
61303 ** one database file has an open write transaction, a master journal
61304 ** file is required for an atomic commit.
61346 ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
61415 ** master journal file. If an error occurs at this point close
61457 ** an error occurs here, do not delete the master journal file.
61494 ** may be lying around. Returning an error code won't help matters.
61518 ** This is an internal self-check only - it is not an essential processing
61550 ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned.
61559 ** is that an IO error may have occured, causing an emergency rollback.
61609 ** handle associated with the VM passed as an argument is about to be
61615 ** an error message to it. Then return SQLITE_ERROR.
61639 ** Return an error code. If the commit could not complete because of
61658 ** Then the internal cache might have been left in an inconsistent
61696 ** file as part of an effort to free up cache space (see function
61739 ** or hit an 'OR FAIL' constraint and there are no deferred foreign
61772 ** do so. If this operation returns an error, and the current statement
61790 /* If this was an INSERT, UPDATE or DELETE and no statement transaction
61880 /* If the VM did not run to completion or if it encountered an
61940 ** Clean up and delete a VDBE after execution. Return an integer which is
62003 ** Delete an entire VDBE.
62026 ** was last positioned. Return an error code if an OOM fault or I/O error
62077 ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned
62080 ** In an SQLite index record, the serial type is stored directly before
62165 ** If we are on an architecture with mixed-endian floating
62172 ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems
62180 ** Developers using SQLite on an ARM7 should compile and run their
62379 ** This routine is used to allocate sufficient space for an UnpackedRecord
62390 ** If an OOM error occurs, NULL is returned.
62578 ** pCur points at an index entry created using the OP_MakeRecord opcode.
62580 ** Return SQLITE_OK if everything works, or an error code otherwise.
62620 /* The last field of the index should be an integer - the ROWID.
62621 ** Verify that the last entry really is an integer. */
62720 ** sequences, or changing an authorization function are the types of
62738 ** Return a pointer to an sqlite3_value structure containing the value bound
62739 ** parameter iVar of VM v. Except, if the value is an SQL NULL, return
62796 ** Return TRUE (non-zero) of the statement supplied as an argument needs
62800 ** collating sequences are registered or if an authorizer function is
62811 ** an error and return true if it has been finalized (or is otherwise
62833 ** the sqlite3_compile() routine. The integer returned is an SQLITE_
62865 ** Terminate the current execution of an SQL statement and reset it
63070 /* Force an SQLITE_TOOBIG error. */
63109 ** statement is completely executed or an error occurs.
63126 ** This "automatic-reset" change is not technically an incompatibility,
63127 ** since any application that receives an SQLITE_MISUSE is broken by
63228 /* If this statement was prepared using sqlite3_prepare_v2(), and an
63269 /* This case occurs after failing to recompile an sql statement.
63317 ** The following is the implementation of an SQL function that always
63318 ** fails with an error message stating that the function is used in the
63477 ** value SQL NULL. Even though the Mem structure contains an element
63480 ** instead of an 8-byte one. This all works fine, except that when
63482 ** that a Mem structure is located on an 8-byte boundary. To prevent
63506 ** This function is called after invoking an sqlite3_value_XXX function on a
63507 ** column value (i.e. a value returned by evaluating an SQL expression in the
63525 /* If malloc() failed during an encoding conversion within an
63623 ** If the result is not a simple column reference (if it is an expression
63700 ** NULL is returned if the result column is an expression or constant or
63701 ** anything else which is not an unabiguous reference to a database column.
63716 ** NULL is returned if the result column is an expression or constant or
63717 ** anything else which is not an unabiguous reference to a database column.
63732 ** NULL is returned if the result column is an expression or constant or
63733 ** anything else which is not an unabiguous reference to a database column.
63839 ** Bind a blob value to an SQL statement variable.
64018 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
64382 ** In the external interface, an "sqlite3_stmt*" is an opaque pointer
64388 ** a linear sequence of operations. Each operation has an opcode
64390 ** is a null-terminated string. Operand P5 is an unsigned character.
64395 ** either an integer, a null-terminated string, a floating point
64436 ** field of the sqlite3 structure is set in order to simulate an interrupt.
64439 ** in an ordinary build.
64508 ** This routine converts an ephemeral string into a dynamically allocated
64510 ** converts an MEM_Ephem string into an MEM_Dyn string.
64636 ** Try to convert pRec to an integer representation or a
64637 ** floating-point representation if an integer representation
64640 ** an integer representation is more space efficient on disk.
64654 /* Only attempt the conversion to TEXT if there is an integer or real
64935 ** This function is only called from within an assert() expression. It
64954 ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
64978 ** If an attempt is made to open a locked database, then this routine
64982 ** If an error occurs, an error message is written to memory obtained
65006 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65122 } an;
65236 int res; /* Result of an sqlite3BtreeLast() */
65499 /* Check to see if we need to simulate an interrupt. This only happens
65534 ** an undefined integer. Opcodes will either fill in the integer
65594 ** opcode and the opcodes.c file is filled with an array of strings where
65700 ** If P4 is not null then it is an error message string.
65702 ** There is an implied "Halt 0 0 0" instruction inserted at the very end of
65719 ** an IGNORE exception. In this case jump to the address specified
65789 ** into an OP_String before it is executed for the first time.
65899 ** left holding a NULL. It is an error for register ranges
65984 ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
66031 ** and have an assigned type. The results are de-ephemeralized as
66330 ** user function may have called an sqlite3_result_XXX() function
66338 /* If the function returned an error, throw an exception */
66447 ** The result is always an integer.
66449 ** To force any register to be an integer, just add 0.
66461 ** Force the value in register P1 to be an integer. If the value
66462 ** in P1 is not an integer and cannot be converted into an integer
66464 ** raise an SQLITE_MISMATCH exception.
66485 ** If register P1 holds an integer convert it to a real value.
66550 ** Force the value in register P1 to be numeric (either an
66552 ** If the value is text or blob, try to convert it to an using the
66567 ** Force the value in register P1 to be an integer. If
66569 ** If the value is text or blob, try to convert it to an integer using the
66586 ** If The value is currently an integer, convert it.
66587 ** If the value is text or blob, try to convert it to an integer using the
66611 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
66921 ** Interpret the content of register P1 as an integer. Store the
67031 #if 0 /* local variables moved into u.an */
67055 #endif /* local variables moved into u.an */
67058 u.an.p1 = pOp->p1;
67059 u.an.p2 = pOp->p2;
67060 u.an.pC = 0;
67061 memset(&u.an.sMem, 0, sizeof(u.an.sMem));
67062 assert( u.an.p1<p->nCursor );
67064 u.an.pDest = &aMem[pOp->p3];
67065 memAboutToChange(p, u.an.pDest);
67066 u.an.zRec = 0;
67068 /* This block sets the variable u.an.payloadSize to be the total number of
67071 ** u.an.zRec is set to be the complete text of the record if it is available.
67074 ** might be available in the u.an.pC->aRow cache. Or it might not be.
67075 ** If the data is unavailable, u.an.zRec is set to NULL.
67080 u.an.pC = p->apCsr[u.an.p1];
67081 assert( u.an.pC!=0 );
67083 assert( u.an.pC->pVtabCursor==0 );
67085 u.an.pCrsr = u.an.pC->pCursor;
67086 if( u.an.pCrsr!=0 ){
67088 rc = sqlite3VdbeCursorMoveto(u.an.pC);
67090 if( u.an.pC->nullRow ){
67091 u.an.payloadSize = 0;
67092 }else if( u.an.pC->cacheStatus==p->cacheCtr ){
67093 u.an.payloadSize = u.an.pC->payloadSize;
67094 u.an.zRec = (char*)u.an.pC->aRow;
67095 }else if( u.an.pC->isIndex ){
67096 assert( sqlite3BtreeCursorIsValid(u.an.pCrsr) );
67097 VVA_ONLY(rc =) sqlite3BtreeKeySize(u.an.pCrsr, &u.an.payloadSize64);
67100 ** payload size, so it is impossible for u.an.payloadSize64 to be
67102 assert( (u.an.payloadSize64 & SQLITE_MAX_U32)==(u64)u.an.payloadSize64 );
67103 u.an.payloadSize = (u32)u.an.payloadSize64;
67105 assert( sqlite3BtreeCursorIsValid(u.an.pCrsr) );
67106 VVA_ONLY(rc =) sqlite3BtreeDataSize(u.an.pCrsr, &u.an.payloadSize);
67109 }else if( ALWAYS(u.an.pC->pseudoTableReg>0) ){
67110 u.an.pReg = &aMem[u.an.pC->pseudoTableReg];
67111 assert( u.an.pReg->flags & MEM_Blob );
67112 assert( memIsValid(u.an.pReg) );
67113 u.an.payloadSize = u.an.pReg->n;
67114 u.an.zRec = u.an.pReg->z;
67115 u.an.pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr;
67116 assert( u.an.payloadSize==0 || u.an.zRec!=0 );
67119 u.an.payloadSize = 0;
67122 /* If u.an.payloadSize is 0, then just store a NULL. This can happen because of
67124 if( u.an.payloadSize==0 ){
67125 MemSetTypeFlag(u.an.pDest, MEM_Null);
67129 if( u.an.payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
67133 u.an.nField = u.an.pC->nField;
67134 assert( u.an.p2<u.an.nField );
67139 u.an.aType = u.an.pC->aType;
67140 if( u.an.pC->cacheStatus==p->cacheCtr ){
67141 u.an.aOffset = u.an.pC->aOffset;
67143 assert(u.an.aType);
67144 u.an.avail = 0;
67145 u.an.pC->aOffset = u.an.aOffset = &u.an.aType[u.an.nField];
67146 u.an.pC->payloadSize = u.an.payloadSize;
67147 u.an.pC->cacheStatus = p->cacheCtr;
67150 if( u.an.zRec ){
67151 u.an.zData = u.an.zRec;
67153 if( u.an.pC->isIndex ){
67154 u.an.zData = (char*)sqlite3BtreeKeyFetch(u.an.pCrsr, &u.an.avail);
67156 u.an.zData = (char*)sqlite3BtreeDataFetch(u.an.pCrsr, &u.an.avail);
67159 ** save the payload in the u.an.pC->aRow cache. That will save us from
67163 assert( u.an.avail>=0 );
67164 if( u.an.payloadSize <= (u32)u.an.avail ){
67165 u.an.zRec = u.an.zData;
67166 u.an.pC->aRow = (u8*)u.an.zData;
67168 u.an.pC->aRow = 0;
67173 ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
67174 u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
67176 /* Make sure a corrupt database has not given us an oversize header.
67177 ** Do this now to avoid an oversize memory allocation.
67185 if( u.an.offset > 98307 ){
67190 /* Compute in u.an.len the number of bytes of data we need to read in order
67191 ** to get u.an.nField type values. u.an.offset is an upper bound on this. But
67192 ** u.an.nField might be significantly less than the true number of columns
67193 ** in the table, and in that case, 5*u.an.nField+3 might be smaller than u.an.offset.
67194 ** We want to minimize u.an.len in order to limit the size of the memory
67195 ** allocation, especially if a corrupt database file has caused u.an.offset
67198 ** On systems that cannot tolerate large memory allocations, u.an.nField*5+3
67199 ** will likely be much smaller since u.an.nField will likely be less than
67203 u.an.len = u.an.nField*5 + 3;
67204 if( u.an.len > (int)u.an.offset ) u.an.len = (int)u.an.offset;
67212 if( !u.an.zRec && u.an.avail<u.an.len ){
67213 u.an.sMem.flags = 0;
67214 u.an.sMem.db = 0;
67215 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, 0, u.an.len, u.an.pC->isIndex, &u.an.sMem);
67219 u.an.zData = u.an.sMem.z;
67221 u.an.zEndHdr = (u8 *)&u.an.zData[u.an.len];
67222 u.an.zIdx = (u8 *)&u.an.zData[u.an.szHdr];
67224 /* Scan the header and use it to fill in the u.an.aType[] and u.an.aOffset[]
67225 ** arrays. u.an.aType[u.an.i] will contain the type integer for the u.an.i-th
67226 ** column and u.an.aOffset[u.an.i] will contain the u.an.offset from the beginning
67227 ** of the record to the start of the data for the u.an.i-th column
67229 for(u.an.i=0; u.an.i<u.an.nField; u.an.i++){
67230 if( u.an.zIdx<u.an.zEndHdr ){
67231 u.an.aOffset[u.an.i] = u.an.offset;
67232 if( u.an.zIdx[0]<0x80 ){
67233 u.an.t = u.an.zIdx[0];
67234 u.an.zIdx++;
67236 u.an.zIdx += sqlite3GetVarint32(u.an.zIdx, &u.an.t);
67238 u.an.aType[u.an.i] = u.an.t;
67239 u.an.szField = sqlite3VdbeSerialTypeLen(u.an.t);
67240 u.an.offset += u.an.szField;
67241 if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
67242 u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
67246 /* If u.an.i is less that u.an.nField, then there are less fields in this
67248 ** table. Set the u.an.offset for any extra columns not present in
67252 u.an.aOffset[u.an.i] = 0;
67255 sqlite3VdbeMemRelease(&u.an.sMem);
67256 u.an.sMem.flags = MEM_Null;
67264 if( (u.an.zIdx > u.an.zEndHdr) || (u.an.offset > u.an.payloadSize)
67265 || (u.an.zIdx==u.an.zEndHdr && u.an.offset!=u.an.payloadSize) ){
67271 /* Get the column information. If u.an.aOffset[u.an.p2] is non-zero, then
67272 ** deserialize the value from the record. If u.an.aOffset[u.an.p2] is zero,
67277 if( u.an.aOffset[u.an.p2] ){
67279 if( u.an.zRec ){
67280 VdbeMemRelease(u.an.pDest);
67281 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67283 u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67284 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67285 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
67289 u.an.zData = u.an.sMem.z;
67290 sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest);
67292 u.an.pDest->enc = encoding;
67295 sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
67297 MemSetTypeFlag(u.an.pDest, MEM_Null);
67303 ** dynamically allocated space over to the u.an.pDest structure.
67306 if( u.an.sMem.zMalloc ){
67307 assert( u.an.sMem.z==u.an.sMem.zMalloc );
67308 assert( !(u.an.pDest->flags & MEM_Dyn) );
67309 assert( !(u.an.pDest->flags & (MEM_Blob|MEM_Str)) || u.an.pDest->z==u.an.sMem.z );
67310 u.an.pDest->flags &= ~(MEM_Ephem|MEM_Static);
67311 u.an.pDest->flags |= MEM_Term;
67312 u.an.pDest->z = u.an.sMem.z;
67313 u.an.pDest->zMalloc = u.an.sMem.zMalloc;
67316 rc = sqlite3VdbeMemMakeWriteable(u.an.pDest);
67319 UPDATE_MAX_BLOBSIZE(u.an.pDest);
67320 REGISTER_TRACE(pOp->p3, u.an.pDest);
67356 ** in an index. The OP_Column opcode can decode the record later.
67488 ** Store the number of entries (an integer value) in the table or index
67512 ** on the value of P1. To open a new savepoint, P1==0. To release (commit) an
67513 ** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.
67584 /* Find the named savepoint. If there is no such savepoint, then an
67585 ** an error is returned to the user. */
67702 ** still running, and a transaction is active, return an error indicating
67712 ** return an error indicating that the other VMs must complete first.
67756 ** transaction might also be rolled back if an error is encountered.
67768 ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained
67773 ** throw an ABORT exception), a statement transaction may also be opened.
67777 ** VDBE to be rolled back after an error without having to roll back the
67836 ** must be started or there must be an open cursor) before
67860 ** Write the content of register P3 (interpreted as an integer)
67913 ** Either a transaction needs to have been started or an OP_Open needs
67941 ** If virtual-tables are in use, this is not just an optimization.
67966 ** database. Give the new cursor an identifier of P1. The P1
67968 ** It is an error for P1 to be negative.
67973 ** There will be a read lock on the database whenever there is an
67979 ** to get a read lock but fails, the script terminates with an
67982 ** The P4 value may be either an integer (P4_INT32) or a pointer to
67985 ** sequence of the index being opened. Otherwise, if P4 is an integer
67996 ** The P4 value may be either an integer (P4_INT32) or a pointer to
67999 ** sequence of the index being opened. Otherwise, if P4 is an integer
68145 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
68173 ** tables using an external merge-sort algorithm.
68197 ** register P2. In other words, cursor P1 becomes an alias for the
68237 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68239 ** to an SQL index, then P3 is the first in an array of P4 registers
68240 ** that are used as an unpacked index key.
68250 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68252 ** to an SQL index, then P3 is the first in an array of P4 registers
68253 ** that are used as an unpacked index key.
68263 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68265 ** to an SQL index, then P3 is the first in an array of P4 registers
68266 ** that are used as an unpacked index key.
68276 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68278 ** to an SQL index, then P3 is the first in an array of P4 registers
68279 ** that are used as an unpacked index key.
68314 ** blob, or NULL. But it needs to be an integer before we can do
68321 /* If the P3 value could not be converted into an integer without
68335 /* The P3 value is too large in magnitude to be expressed as an
68443 ** P1 is an open table cursor and P2 is a rowid integer. Arrange
68473 ** P4>0 then register P3 is the first of P4 registers that form an unpacked
68476 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
68483 ** P4>0 then register P3 is the first of P4 registers that form an unpacked
68486 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
68488 ** does contain an entry whose prefix matches the P3/P4 record then control
68559 ** Cursor P1 is open on an index b-tree - that is to say, a btree which
68564 ** The P3 register contains an integer record number. Call this record
68566 ** that make up an unpacked index key that can be used with cursor P1.
68574 ** Otherwise, this instruction checks if cursor P1 contains an entry
68648 ** Use the content of register P3 as an integer key. If a record
68654 ** operation assumes the key is an integer and that P1 is a table whereas
68656 ** P1 is an index.
68691 /* This happens when an attempt to open a read cursor on the
68726 ** an SQLITE_FULL error is generated. The P3 register is updated with the '
68734 int res; /* Result of an sqlite3BtreeLast() */
68813 assert( (u.bg.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
68833 ** an AUTOINCREMENT table. */
68869 ** Write an entry into the table of cursor P1. A new entry is
68870 ** created if it doesn't already exist or the data for an existing
68885 ** has already positioned the cursor correctly. This is an optimization
68888 ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
68890 ** is part of an INSERT operation. The difference is only important to
68988 ** a record from within an Next loop.
69022 /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or
69190 ** Store in register P2 an integer which is the key of the table entry that
69193 ** P1 can be either an ordinary table or a virtual table. There used to
69297 ** it increments an undocumented global variable used for testing.
69434 ** Register P2 holds an SQL index key made using the
69439 ** insert is likely to be an append.
69486 ** an unpacked index key. This opcode removes that entry from the
69523 ** Write into register P2 an integer which is the last entry in the record at
69560 ** The P4 register values beginning with P3 form an unpacked index
69567 ** If P5 is non-zero then the key value is increased by an epsilon
69574 ** The P4 register values beginning with P3 form an unpacked index
69581 ** If P5 is non-zero then the key value is increased by an epsilon prior
69627 ** Delete an entire database table or index whose root page in the database
69695 ** If the P3 value is non-zero, then the table referred to must be an
69696 ** intkey table (an SQL table, not an index). In this case the row change
69727 ** auxiliary database file if P1==1 or in an attached database if
69731 ** The difference between a table and an index is this: A table must
69733 ** has an arbitrary key but no data.
69740 ** auxiliary database file if P1==1 or in an attached database if
69856 ** the index named P4 in database P1. This is called after an index
69881 ** Do an analysis of the currently open database. Store in
69882 ** register P1 the text of an error message describing any problems.
69947 ** An assertion fails if P2 is not an integer.
70021 ** delete it now and initialize P1 with an empty rowset
70053 ** cell in an array of values used as arguments to the sub-program. P2
70054 ** contains the address to jump to if the sub-program throws an IGNORE
70240 ** This instruction throws an error if the memory cell is not initially
70241 ** an integer.
70270 ** not contain an integer. An assertion fault will result if you try.
70286 ** not contain an integer. An assertion fault will result if you try.
70299 ** The register P1 must contain an integer. Add literal P3 to the
70303 ** not contain an integer. An assertion fault will result if you try.
70317 ** Execute the step function for an aggregate. The
70382 ** Execute the finalizer function for an aggregate. P1 is
70420 ** completes into mem[P3+2]. However on an error, mem[P3+1] and
70523 ** as an intermediate */
70593 ** fails with an error code of SQLITE_SCHEMA if it is ever executed
70621 ** used to generate an error message if the lock cannot be obtained.
70643 ** P4 may be a pointer to an sqlite3_vtab structure. If so, call the
70690 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70730 ** P1 is a cursor opened using VOpen. P2 is an address to jump to if
70847 ** do this regardless of whether or not an error occurred to ensure any
70888 ** underlying implementation to return an error if one occurs during
70889 ** xNext(). Instead, if an error occurs, true is returned (indicating that
70912 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70944 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70950 ** The xUpdate method will do a DELETE or an INSERT or both.
71141 ** an error of some kind.
71243 ** If an error occurs, or if the specified row does not exist or does not
71245 ** blob handle was opened, then an error code is returned and *pzErr may
71246 ** be set to point to a buffer containing an error message. It is the
71250 ** If an error does occur, then the b-tree cursor is closed. All subsequent
71327 ** After seeking the cursor, the vdbe executes an OP_ResultRow.
71341 /* One of the following two instructions is replaced by an OP_Noop. */
71422 /* Check that the column is not part of an FK child key definition. It
71494 ** always return an SQL NULL. This is useful because it means
71631 ** Move an existing blob handle to point to a different row of the same
71634 ** If an error occurs, or if the specified row does not exist or does not
71635 ** contain a blob or text value, then an error code is returned and the
71709 ** The aIter[] array contains an iterator for each of the PMAs being merged.
71782 ** The following type is an iterator for a PMA. It caches the current key in
71823 ** no error occurs, or an SQLite error code if one does.
71841 /* This is an EOF condition */
71875 ** SQLITE_OK if successful, or an SQLite error code if some error occurs.
71899 ** successful, or an SQLite error code if some error occurs.
71905 ** set to the integer value read. If an error occurs, the final values of
71964 ** used by the comparison. If an error occurs, return an SQLite error code.
71974 ** has been allocated and contains an unpacked record that is used as key2.
72122 ** Otherwise, set *ppFile to 0 and return an SQLite error code.
72169 ** if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if an error
72208 ** SQLITE_OK if successful, or an SQLite error code otherwise.
72258 /* This assert verifies that unless an error has occurred, the size of
72403 ** initialize an iterator for each of them and break out of the loop.
72535 ** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).
72575 ** the caller specifies a buffer size for an in-memory buffer to
72588 ** as an open file handle for journal files.
72618 /* If an error occurred while writing to the file, close it before
72817 ** This file contains code use to implement an in-memory rollback journal.
72862 ** is an instance of this class.
72997 ** Syncing an in-memory journal is a no-op. And, in fact, this routine
73050 ** Return true if the file-handle passed as an argument is
73051 ** an in-memory journal
73078 ** an SQL statement.
73085 ** Walk an expression tree. Invoke the callback once for each node
73124 ** an abort request is seen.
73183 ** there is an abort request.
73185 ** If the Walker does not have an xSelectCallback() then this routine
73224 ** Turn the pExpr expression into an alias for the iCol-th column of the
73228 ** makes an exact copy. But for any other kind of expression, this
73254 Expr *pExpr, /* Transform this into an alias to the result set */
73345 ** If the name cannot be resolved unambiguously, leave an error message
73497 ** might refer to an result-set alias. This happens, for example, when
73555 ** more matches. Either way, we have an error.
73613 ** Allocate and return a pointer to an expression to load the column iCol
73725 int is_agg = 0; /* True if is an aggregate function */
73820 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
73823 ** this routine return an integer between 1 and N where N is the number of
73852 ** pE is a pointer to an expression which is a single term in the
73857 ** ORDER BY term is not an integer index into the result set. That
73862 ** as an indication to the caller that it should sort by the i-th column.
73867 ** If there is no match, return 0. Return -1 if an error occurs.
73899 /* Try to match the ORDER BY expression against an expression
73900 ** in the result set. Return an 1-based index of the matching
73914 ** Generate an ORDER BY or GROUP BY term out-of-range error.
73932 ** ORDER BY terms that are already an integer between 1 and N are
73934 ** 1 through N generate an error. ORDER BY terms that are expressions
74029 ** If any errors are detected, add an error message to pParse and
74065 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
74069 ** This routine resolves each term of the clause into an expression.
74070 ** If the order-by term is an integer I between 1 and N (where N is the
74073 ** the order-by term is an identify that corresponds to the AS-name of
74079 ** an appropriate error message might be left in pParse. (OOM errors
74101 /* If an AS-name match is found, mark this ORDER BY column as being
74109 /* The ORDER BY term is an integer constant. Again, set the column
74120 /* Otherwise, treat the ORDER BY term as an ordinary expression */
74155 ** an expression, sqlite3ResolveExprNames() will be called without a
74175 ** are not allowed to refer to any names, so pass an empty NameContext.
74314 ** This routine walks an expression tree and resolves references to
74323 ** the symbolic name assigned to an ATTACH-ed database.
74340 ** size of an AS clause in the result-set of a SELECT. The Z expression
74353 ** If the function is an aggregate function, then the pNC->hasAgg is
74355 ** If an expression contains aggregate functions then the EP_Agg
74447 ** If pExpr is a column, a reference to a column via an 'AS' alias,
74453 ** have an affinity:
74486 ** Set the explicit collating sequence for an expression to the
74554 ** pExpr is an operand of a comparison operator. aff2 is the
74604 ** idx_affinity is the affinity of an indexed column. Return true
74691 ** expression depth allowed. If it is not, leave an error message in
74744 ** Set the Expr.nHeight variable in the structure passed as an
74765 ** leave an error in pParse.
74774 ** by the select statement passed as an argument.
74904 ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed,
74923 ** Join two expressions using an AND operator. If either expression is
74958 ** Assign a variable number to an expression that encodes a wildcard
74966 ** the SQL statement comes from an external source.
74990 /* Wildcard of the form "?nnn". Convert "nnn" to an integer and
75042 ** Recursively delete an expression tree.
75078 ** to store a copy of an expression or expression tree. They differ in
75408 ** Add a new element to the end of an expression list. If pList is
75456 ** pList might be NULL following an OOM error. But pName should never be
75481 ** pList might be NULL following an OOM error. But pSpan should never be
75504 ** leave an error message in pParse.
75520 ** Delete an entire expression list.
75538 ** to an integer. These routines are checking an expression to see
75596 ** Walk an expression tree. Return 1 if the expression is constant
75608 ** Walk an expression tree. Return 1 if the expression is constant
75611 ** an ON or USING clause.
75618 ** Walk an expression tree. Return 1 if the expression is constant
75633 ** in *pValue. If the expression is not an integer or if it is too big
75639 /* If an expression is an integer literal that fits in a signed 32-bit
75672 ** This routine is used as an optimization, to skip OP_IsNull opcodes
75677 ** will likely result in an incorrect answer. So when in doubt, return
75697 ** Generate an OP_IsNull instruction that tests register iReg and jumps
75808 ** Code an OP_Once instruction and allocate space for its flag. Return the
75837 ** through the set members, skipping any duplicates. In this case an
75839 ** to be unique - either because it is an INTEGER PRIMARY KEY or it
75843 ** for fast set membership tests. In this case an epheremal table must
75844 ** be used unless <column> is an INTEGER PRIMARY KEY or an index can
75848 ** needs to know whether or not the structure contains an SQL NULL
75880 /* Check to see if an existing table or index can be used to
75900 /* Code an OP_VerifyCookie and OP_TableLock for <table>. */
75922 /* The collation sequence used by the comparison. If an index is to
75961 /* Could not found an existing table or index to use as the RHS b-tree.
75962 ** We will have to generate an ephemeral table to do the job.
76000 ** to some integer key column of a table B-Tree. In this case, use an
76004 ** If rMayHaveNull is non-zero, that means that the operation is an IN
76017 ** result. For IN operators or if an error occurs, the return value is 0.
76036 ** * The right-hand side is an expression list containing variables
76069 /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
76113 ** For each expression, build an index key from the evaluation and
76176 ** of the memory cell in iColumn. If this is an EXISTS, write
76177 ** an integer 0 (not exists) or 1 (exists) into a memory cell
76223 ** Generate code for an IN expression.
76229 ** is an array of zero or more values. The expression is true if the LHS is
76291 /* In this case, the RHS is an index b-tree.
76356 ** Duplicate an 8-byte value
76368 ** Generate an instruction that will put the floating point
76390 ** Generate an instruction that will put the integer describe by
76475 /* Find an empty slot and replace it */
76597 ** There must be an open cursor to pTab in iTable when this routine
76640 ** Record the fact that an affinity change has occurred on iCount
77140 ** The expression is implemented using an OP_Param opcode. The p1
77141 ** parameter is set to 0 for an old.rowid reference, or to (i+1)
77174 /* If the column has REAL affinity, it may currently be stored as an
77306 ** Generate code to evaluate an expression and store the results
77383 ** Generate a human-readable explanation of an expression tree.
77614 ** Generate a human-readable explanation of an expression list.
77640 ** Return TRUE if pExpr is an constant expression that is appropriate
77651 ** We could factor them out, but then we would end up adding an
77681 ** up generating an OP_SCopy to move the value to the destination
78137 ** this routine is used, it does not hurt to get an extra 2 - that
78139 ** an incorrect 0 or 1 could lead to a malfunction.
78257 ** Make an entry for the column in pAggInfo->aCol[] if there
78258 ** is not an entry there already.
78296 /* There is now an entry for pExpr in pAggInfo->aCol[] (either
78387 ** Call sqlite3ExprAnalyzeAggregates() for every expression in an
78390 ** If an error is found, the analysis is cut short.
78529 /* Ran out of input before finding an opening bracket. Return NULL. */
78554 ** This C function implements an SQL user function that is used by SQL code
78796 ** pTab->zName if this function is being called to code part of an
78843 ** If the table is a system table, this function leaves an error message
78876 VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
78895 ** in database iDb. If so, this is an error.
79083 ** This function is called after an "ALTER TABLE ... ADD" statement
79124 ** for an SQL NULL default below.
79201 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
79237 /* Make sure this is not an attempt to ALTER a view. */
79251 ** the name by adding an "sqlite_altertab_" prefix. By adding this
79252 ** prefix, we insure that the name will not collide with an existing
79359 ** about the distribution of keys within an index. The index is identified by
79364 ** The sqlite_stat2 entries for an index that have sampleno between 0 and 9
79382 ** The sqlite_stat3 is an enhancement to sqlite_stat2. A new name is
79406 ** There can be an arbitrary number of sqlite_stat3 entries per index.
79509 ** share an instance of the following structure to hold their state
79721 ** Generate code to do an analysis of all indices associated with
79847 ** initialized to contain an SQL NULL.
80011 ** Generate code that will do an analysis of an entire database
80034 ** Generate code that will do an analysis of a single table in
80059 ** when it recognizes an ANALYZE command.
80078 /* Read the database schema. If an error occurs, leave an error message
80361 ** If an OOM error occurs, this function always sets db->mallocFailed.
80440 ** Resolve an expression that was part of an ATTACH or DETACH statement. This
80475 ** An SQL user-function registered to do the work of an ATTACH statement. The
80476 ** three arguments to the function come directly from an attach statement:
80482 ** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the
80656 /* Return an error if we get here */
80665 ** An SQL user-function registered to do the work of an DETACH statement. The
80780 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
80816 ** Called by the parser to compile an ATTACH statement.
80870 ** These routines are used to make sure that an index, trigger, or
80874 ** to an object in a different database, an error message is added to
80995 ** API. This facility is an optional feature of the library. Embedded
81044 ** will return with an error. SQLITE_IGNORE means that the SQL statement
81065 ** Write an error message into pParse->zErrMsg that explains that the
81066 ** user-supplied authorization function returned an illegal value.
81075 ** table zTab in database zDb. This function assumes that an authorization
81079 ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
81080 ** is treated as SQLITE_DENY. In this case an error is left in pParse.
81113 ** then generate an error.
81167 ** Do an authorization check using the code and arguments given. Return
81204 ** Push an authorization context. After this routine is called, the
81220 ** Pop an authorization context that was previously pushed
81327 ** Code an OP_TableLock instruction for each table locked by the
81355 ** Note that if an error occurred, it might be the case that
81520 ** database containing the table. Return NULL if not found. Also leave an
81524 ** routine leaves an error message in pParse->zErrMsg where
81535 /* Read the database schema. If an error occurs, leave an error message
81585 ** Reclaim the memory used by an index
81840 ** of a database ("main", "temp" or the name of an attached db). This
81861 ** "temp" or the name of an attached db). This routine returns the
82030 /* Make sure the new table name does not collide with an existing
82031 ** index or table name in the same database. Issue an error message if
82033 ** to an sqlite3_declare_vtab() call. In that case only the column names
82053 sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
82149 /* If an error occurs, we jump here */
82318 ** Default value expressions must be constant. Raise an exception if this
82355 ** a primary key (and this is the second primary key) then create an
82364 ** If the key is not an INTEGER PRIMARY KEY, then create a unique
82411 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
82468 ** then an index may have been created on this column before the
82493 ** another error occurs, NULL is returned and an error message written into
82498 ** and generates an error message.
82563 ** The first parameter is a pointer to an output buffer. The second
82564 ** parameter is a pointer to an integer that contains the offset at
82571 ** characters, does not begin with a digit and is not an SQL keyword,
82838 /* Check to see if we need to create an sqlite_sequence table for
82970 ** of errors. If an error is seen leave an error message in pParse->zErrMsg.
83131 ** erasing iTable (this can happen with an auto-vacuum database).
83139 /* OP_Destroy stores an in integer r1. If this integer
83159 ** is also added (this can happen with an auto-vacuum database).
83174 ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the
83542 ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED
83561 ** content of an index in response to a REINDEX command.
83679 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
83681 ** be NULL for a primary key or an index that is created to satisfy a
83712 Token nullId; /* Fake token for an empty ID list */
83845 /* Check for authorization to create an index.
83881 /* Either pColl!=0 or there was an OOM failure. But if an OOM
83933 ** load the column indices into the Index structure. Report an error
83939 ** same column more than once cannot be an error because that would
83961 ** must exist or else there must have been an OOM error. But if there
83962 ** was an OOM error, we would never reach this point. */
83988 /* This routine has been called to create an automatic index as a
83996 ** Either way, check to see if the table already has such an index. If
84031 ** ON CONFLICT clauses this is an error. Otherwise, use the
84101 /* A named index with an explicit CREATE INDEX statement */
84112 /* Add an entry in sqlite_master for this index
84124 /* Fill the index with data and reparse the schema. Code an OP_Expire
84136 /* When adding an index to the list of indices for a table, make
84176 ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the
84178 ** first column of the index. aiRowEst[2] is an estimate of the number
84207 ** This routine will drop an existing named index. This routine
84275 ** pArray is a pointer to an array of objects. Each object in the
84342 ** Delete an IdList.
84438 ** A SrcList is returned, or NULL if there is an OOM error. The returned
84440 ** a new one. If an OOM error does occurs, then the prior value of pList
84443 ** If pDatabase is not null, it means that the table has an optional
84519 ** Delete an entire SrcList including all its substructure.
84595 ** Add an INDEXED BY or NOT INDEXED clause to the most recently added
84617 ** Shifts all join operators from left to right for an entire FROM
84701 ** release or rollback an SQL savepoint.
84761 ** The first time this routine is called, we code an OP_Goto that
84817 ** Generate VDBE code that prepares for doing an operation that
84840 ** If an abort occurs after some of these writes have completed, then it will
84860 ** particular, it prevents us from writing an effective
84870 ** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT
84967 /* Read the database schema. If an error occurs, leave an error message
85017 ** pointer. If an error occurs (out of memory or missing collation
85164 ** an equivalent collating sequence that uses a text encoding different
85185 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
85189 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
85245 ** if necessary and generates an error message if the collating sequence
85428 /* If the createFlag parameter is true and the search did not reveal an
85527 ** the name of a single table, as one might find in an INSERT, DELETE,
85529 ** return a pointer. Set an error message and return NULL if the table
85556 ** writable, generate an error message and return 1. If it is
85568 ** In either case leave an error message in pParse and return non-zero.
85592 ** Evaluate a view and store its result in an ephemeral table. The
85593 ** pWhere argument is an optional WHERE clause that restricts the
85631 ** Generate an expression tree to implement the WHERE, ORDER BY,
85654 /* Check that there isn't an ORDER BY without a LIMIT clause.
85762 ** put in an SrcList structure because some of the subroutines we
85764 ** an SrcList* parameter instead of just a Table* parameter.
85893 ** because deleting an item can change the scan order. */
86111 ** Generate code that will assemble an index key and put it in register
86112 ** regOut. The key with be for index pIdx which is an index on pTab.
86301 ** abs(X) throws an integer overflow error since there is no
86467 ** raise an SQLITE_TOOBIG exception and return NULL.
86873 ** Otherwise, return an error.
86921 /* IMP: R-48699-48617 This function is an SQL wrapper around the
86937 /* IMP: R-24470-31136 This function is an SQL wrapper around the
86959 ** The result is an integer that identifies if the compiler option
87011 ** EXPERIMENTAL - This is not an official function. The interface may
87406 ** SUM might return an integer if it never encounters a floating point
87407 ** value. TOTAL never fails, but SUM might through an exception if
87408 ** it overflows an integer.
87641 ** pExpr points to an expression which implements a function. If
87801 ** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT
87811 ** time a statement is executed that removes an existing violation from
87859 ** If a delete caused by OR REPLACE violates an FK constraint, an exception
87867 ** and the statement transaction is rolled back. An exception is an INSERT
87869 ** instead of using a counter, an exception is thrown immediately if the
87871 ** an INSERT does not open a statement transaction.
87880 ** Before coding an UPDATE or DELETE row operation, the code-generator
87886 ** coding an INSERT operation. The functions used by the UPDATE/DELETE
87898 ** sqlite3FkDelete() - Delete an FKey structure.
87924 ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY
87930 ** Otherwise, it is set to point to an allocated array of size N, where
87955 ** into pParse. If an OOM error occurs, non-zero is returned and the
87986 ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly
88021 ** map to an explicit list of columns in table pParent. Check if this
88067 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
88129 /* Invoke MustBeInt to coerce the child key value to an integer (i.e.
88138 ** to increment the constraint-counter (i.e. this is an INSERT operation),
88164 ** to increment the constraint-counter (i.e. this is an INSERT operation),
88199 /* Special case: If this is an INSERT statement that will insert exactly
88222 ** code for an SQL UPDATE operation, this function may be called twice -
88270 /* Create an Expr object representing an SQL expression like:
88337 ** clause. If the constraint is not deferred, throw an exception for
88364 ** Calling this function with table "t1" as an argument returns a pointer
88438 ** violations, halt the VDBE and return an error at this point, before
88458 ** first register in an array of (pTab->nCol+1) registers containing the
88463 ** For an INSERT operation, regOld is passed zero and regNew is passed the
88464 ** first register of an array of (pTab->nCol+1) registers containing the new
88467 ** For an UPDATE operation, this function is called twice. Once before
88506 ** schema items cannot be located, set an error in pParse and return
88520 ** If the parent table of an FK constraint on the current table is
88567 ** If the parent does not exist, removing the child row resolves an
88588 /* Inserting a single row into a parent table cannot cause an immediate
88615 ** on the parent table of this FK, then throw an exception
88660 ** parameter aChange is passed a NULL value. For an UPDATE, aChange points
88661 ** to an array of size N, where N is the number of columns in table pTab.
88684 /* This is an UPDATE. Foreign key processing is only required if the
88718 ** This function is called when an UPDATE or DELETE operation is being
88720 ** If the current operation is an UPDATE, then the pChanges parameter is
88939 ** refer to table pTab. If there is an action associated with the FK
89170 ** Locate or create an AutoincInfo structure associated with table pTab
89222 AutoincInfo *p; /* Information about an AUTOINCREMENT */
89257 ** Update the maximum rowid for an autoincrement calculation.
89273 ** Every statement that might do an INSERT into an autoincrement
89460 int appendFlag = 0; /* True if the insert is likely to be an append */
89558 /* If this is an AUTOINCREMENT table, look up the sequence number in the
89699 /* If the INSERT statement included an IDLIST term, then make sure
89703 ** If the table has an INTEGER PRIMARY KEY column and that column
89737 /* If there is no IDLIST term but the table has an integer primary
89811 /* build the NEW.* reference row. Note that if there is an INTEGER
89858 /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
89877 ** except when the table has an INTEGER PRIMARY KEY column, in which
90063 ** Generate code to do constraint checks prior to an INSERT or an UPDATE.
90080 ** is false, indicating an INSERT statement, then a non-zero rowidChng
90083 ** computed automatically in an insert or that the rowid value is not
90084 ** modified by an update.
90114 ** the stack and there is an immediate jump
90124 ** CHECK REPLACE Illegal. The results in an exception.
90146 int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
90230 /* If we have an INTEGER PRIMARY KEY, make sure the primary key
90232 ** is an UPDATE and the primary key is not changing, that is OK.
90334 /* Find out what action to take in case there is an indexing conflict */
90430 int appendBias, /* True if this is likely to be an append */
90541 ** for index pDest in an insert transfer optimization. The rules
90595 ** an unoptimized transfer. This routine also returns FALSE if there
90618 KeyInfo *pKey; /* Key information for an index */
90649 return 0; /* SELECT may not have an ORDER BY clause */
90652 ** there is no ORDER BY, we will get an error. */
90864 ** codes. Also write an error message into memory obtained from
91024 ** an SQLite instance. Shared libraries that intend to be loaded
91255 ** (part of the main SQLite library - not an extension) so that
91823 ** Attempt to load an SQLite extension library contained in the file
91830 ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with
92062 ** If anything goes wrong, set an error in the database connection.
92117 ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or
92171 ** Interpret the given string as an auto-vacuum mode value.
92330 ** compiler (eg. count_changes). So add an opcode to expire all
92451 /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS
92547 /* Malloc may fail when setting the page-size, as there is an internal
92592 ** change. The only purpose is to provide an easy way to test
92763 ** as an auto-vacuum capable db.
92770 ** that this really is an auto-vacuum capable database.
93196 /* Pragma "quick_check" is an experimental reduced version of
93234 /* Do an integrity check on each database file */
93247 /* Do an integrity check of the B-Tree
93370 ** is created. If an existing main database file is opened, then the
93692 ** Fill the InitData structure with an error message that indicates
93777 /* If the SQL column is blank it means this is an index that
93786 /* This can occur if there exists an index on a TEMP table which
93928 ** For an attached db, it is an error if the encoding is not the same
93940 /* If opening an attached database, the encoding much match ENC(db) */
94033 /* Jump here for an error that occurs after successfully allocating
94034 ** curMain and calling sqlite3BtreeEnter(). For an error that occurs
94053 ** created using ATTACH statements. Return a success code. If an
94054 ** error occurs, write an error message into *pzErrMsg.
94427 ** and the statement is automatically recompiled if an schema change
94507 ** and the statement is automatically recompiled if an schema change
94650 ** type of join. Return an integer constant that expresses that type
94662 ** If an illegal or unsupported join type is seen, then still return
94663 ** a join type, but put an error in the pParse structure.
94785 int isOuterJoin, /* True if this is an OUTER join */
94816 ** The EP_FromJoin property is used on terms of an expression to tell
94885 "an ON or USING clause", 0);
94910 ** an AND operator.
94922 ** Report an error if any column mentioned in the USING clause is
95043 ** Generate an error message when a SELECT is used within a subexpression
95057 "a SELECT that is part of an expression");
95122 /* If the destination is an EXISTS(...) expression, the actual
95189 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
95220 /* If this is a scalar select that is part of an expression, then
95281 ** Given an expression list, generate a KeyInfo structure that records
95284 ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting
95292 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
95340 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
95374 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
95527 ** declaration type for a ROWID field is INTEGER. Exactly when an expression
95718 /* If this is an EXPLAIN, skip this step */
95771 ** Given a an expression list (which is really the list of expressions
95802 /* Get an appropriate name for the column
95808 /* If the column contains an "AS <name>" phrase, use <name> as the name */
95948 ** If an error occurs, return NULL and leave a message in pParse.
96017 pParse->nMem++; /* Allocate an extra register for limit+offset */
96114 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
96162 /* Compound SELECTs that have an ORDER BY clause are handled separately.
96451 ** Code an output subroutine for a coroutine implementation of a
96502 /* Suppress the the first OFFSET entries if there is an OFFSET clause
96525 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
96542 #if 0 /* Never occurs on an ORDER BY query */
96552 /* If this is a scalar select that is part of an expression, then
96609 ** is an ORDER BY clause.
96655 ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA
96656 ** causes an immediate jump to EofA and an EOF on B following nextB causes
96657 ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or
97162 ** (2) The subquery is not an aggregate or the outer query is not a join.
97202 ** (16) The outer query is not an aggregate or the subquery does
97211 ** * is not an aggregate or DISTINCT query, and
97218 ** operators have an implied DISTINCT which is disallowed by
97229 ** an ORDER BY clause. Ticket #3773. We could relax this constraint
97311 ** not used as the right operand of an outer join. Examples of why this
97334 ** effectively converts the OUTER JOIN into an INNER JOIN.
97622 ** Analyze the SELECT statement passed as an argument to see if it
97653 ** The select statement passed as the first argument is an aggregate query.
97687 ** If the source-list item passed as an argument was augmented with an
97690 ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate
97760 ** an entry of the FROM clause is a subquery instead of a table or view,
97978 ** If anything goes wrong, an error message is written into pParse.
98082 ** intermediate results while calculating an aggregate. This
98130 ** Update the accumulator memory cells for an aggregate based on
98195 ** values to an OP_Copy.
98267 ** SRT_EphemTab Create an temporary table pDest->iParm and store
98285 ** encountered, then an appropriate error message is left in
98309 int addrSortIndex; /* Address of an OP_OpenEphemeral instruction */
98310 int addrDistinctIndex; /* Address of an OP_OpenEphemeral instruction */
98380 ** an exact limit.
98393 /* Generate a subroutine that will fill an ephemeral table with
98463 /* If there is both a GROUP BY and an ORDER BY clause and they are
98466 ** an optimization - the correct answer should result regardless.
98475 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
98488 ** BY and DISTINCT, and an index or separate temp-table for the other.
98499 /* If there is an ORDER BY clause, then this sorting
98502 ** OP_OpenEphemeral instruction will be changed to an OP_Noop once
98558 ** into an OP_Noop.
98584 /* Change the OP_OpenEphemeral coded earlier to an OP_Integer. The
98718 ** This might involve two separate loops with an OP_Sort in between, or
98719 ** it might be a single loop that uses an index to extract information
98903 ** is better to execute the op on an index, as indexes are almost
98917 ** there is such an index, and it has less columns than the table
98924 ** (2011-04-15) Do not do a full scan of an unordered index.
98956 ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause.
99021 /* If there is an ORDER BY clause, then we need to sort the results
99038 /* Control jumps to here if an error is encountered above, or upon
99182 char *zErrMsg; /* Error message text, if an error occurs */
99217 /* If this is the first row, then generate an extra row containing
99436 IdList *pColumns, /* column list if this is an UPDATE OF trigger */
99514 ** drop so the trigger cannot be dropped. This results in an
99656 /* Make an entry in the sqlite_master table */
99717 ** If an OOM error occurs, NULL is returned and db->mallocFailed is set.
99738 ** Build a trigger step out of an INSERT statement. Return a pointer
99741 ** The parser calls this routine when it sees an INSERT inside the
99773 ** Construct a trigger step that implements an UPDATE statement and return
99775 ** sees an UPDATE statement inside the body of a CREATE TRIGGER.
99970 ** pEList is the SET clause of an UPDATE statement. Each entry
99972 ** in pEList have an <id> which matches an identifier in pIdList,
99989 ** one trigger that must be fired when an operation of type 'op' is
99990 ** performed on the table, and, if that operation is an UPDATE, if at
99997 ExprList *pChanges, /* Columns that change in an UPDATE statement */
100069 ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use
100146 ** (trigger program). If an error has occurred, transfer error information
100184 ** are freed if an error occurs, link them into the Parse.pTriggerPrg
100244 /* Insert an OP_Halt at the end of the sub-program. */
100289 ** process of being coded). If this is the case, then an entry with
100291 ** in the Parse.pTriggerPrg list. Search for such an entry. */
100297 /* If an existing TriggerPrg could not be located, create a new one. */
100344 ** This is called to code the required FOR EACH ROW triggers for an operation
100347 ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then
100353 ** The reg argument is the address of the first in an array of registers
100373 ** are never accessed, and so are not allocated by the caller. So, for an
100381 ** raises an IGNORE exception.
100390 int reg, /* The first in an array of registers (see above) */
100425 ** old.* record into memory when executing an UPDATE or DELETE command.
100428 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
100431 ** with an index greater than 32 may be accessed, 0xffffffff is returned.
100508 ** The most recently coded instruction was an OP_Column to retrieve the
100514 ** was created, or added later to the table definition by an ALTER TABLE
100521 ** Column definitions created by an ALTER TABLE command may only have
100532 ** If parameter iReg is not negative, code an OP_RealAffinity instruction
100533 ** on register iReg. This is used when an equivalent integer value is
100534 ** stored in place of an 8-byte floating point value in order to save
100559 ** Process an UPDATE statement.
100583 ** an expression for the i-th column of the table.
100869 /* If there are triggers on this table, populate an array of registers
101057 ** Generate code for an UPDATE of a virtual table.
101059 ** The strategy is that we create an ephemerial table that contains
101172 ** Finalize a prepared statement. If there was an error, store the
101185 ** Execute zSql on database db. Return an error code.
101318 /* A VACUUM cannot change the pagesize of an encrypted database. */
101332 /* Begin a transaction and take an exclusive lock on the main database
101379 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
101423 ** transaction by sqlite3BtreeCopyFile() and the other by an explicit
101432 ** are an increment to apply to the meta value after the vacuum.
101475 /* Currently there is an SQL level transaction open on the vacuum
101518 ** sqlite3.pVtabCtx member variable is set to point to an instance of
101600 ** If an unlock is omitted, resources leaks will occur.
101657 ** above function sqlite3VtabUnlockList() for an explanation of why
101659 ** database connection that may have an entry in the p->pVTable list.
101865 ** The VM register number pParse->regRowid holds the rowid of an
101893 ** the first time the virtual table is used in an SQL statement. This
101914 ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
101924 ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
102045 ** of the virtual table pTab. If an error occurs, an error code is returned
102046 ** and an error left in pParse.
102116 ** If an error occurs, *pzErr is set to point an an English language
102117 ** description of the error and an SQLITE_XXX error code is returned.
102134 ** invoke it now. If the module has not been registered, return an
102281 ** sqlite3DbFree() containing an error message, if one is available.
102371 ** virtual tables that currently have an open transaction. Pass iSavepoint
102377 ** an open transaction is invoked.
102379 ** If any virtual table method returns an error code other than SQLITE_OK,
102421 ** table implementation have an opportunity to overload the function.
102492 ** array so that an OP_VBegin will get generated for it. Add pTab to the
102520 ** within an xUpdate method.
102611 ** The query generator uses an array of instances of this structure to
102821 #define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */
102823 #define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */
102833 #define WHERE_TEMP_INDEX 0x20000000 /* Uses an ephemeral index */
102974 ** Initialize an expression mask set (a WhereMaskSet object)
103007 ** This routine walks (recursively) an expression tree and generates
103071 ** allowed for an indexable WHERE clause term. The allowed operators are
103074 ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
103185 /* Figure out the collation sequence required from an index for
103259 ** be the name of an indexed column with TEXT affinity. */
103387 ** term that is an equivalent IN expression. In other words, if the term
103406 ** A subterm is also indexable if it is an AND of two or more
103412 ** potentially be used with an index if an appropriate index exists.
103537 ** that there is no possibility of transforming the OR clause into an
103545 ** might be possible to form an IN operator with either table1.column
103561 ** such table and column. Set okToChngToIN if an appropriate table
103578 ** or follwed by an inverted copy (t2.b==t1.a). Skip this term
103627 ** pTerm converted into an IN operator.
103671 ** The input to this routine is an WhereTerm structure with only the
103730 extraRight = x-1; /* ON clause terms may not be used with an index
103790 ** skipped. Or, if the children are satisfied by an index, the original
103817 ** an OR operator.
103928 /* When sqlite_stat3 histogram data is available an operator of the
103930 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
103969 ** an index for tables to the left of the join.
103995 ** for an expression of type TK_COLUMN that refers to the same column and
104000 ** If such an expression is found, its index in pList->a[] is returned. If
104112 /* If any of the expressions is an IPK column on table iBase, then return
104155 ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the
104157 ** the table has a cursor number of "base". pIdx is an index on pTab.
104193 ** or an index structure allocated on the stack by bestBtreeIndex() to
104215 /* Can not use an index sort on anything that is not a column in the
104238 /* If an index column that is constrained by == fails to match an
104246 /* If an index column fails to match and is not constrained by ==
104316 ** Two routines for printing the content of an sqlite3_index_info
104367 ** This routine attempts to find an scanning strategy that can be used
104368 ** to optimize an 'OR' expression that is part of a WHERE clause.
104438 /* If there is an ORDER BY clause, increase the scan cost to account
104465 ** could be used with an index to access pSrc, assuming an appropriate
104507 /* There is no point in building an automatic index for a single scan */
104559 ** Generate code to construct the Index object for an automatic index
104580 int regRecord; /* Register holding an index record */
104616 ** covering index. A "covering index" is an index that contains all
104710 ** Allocate and populate an sqlite3_index_info structure. It is the
104821 ** If an error occurs, pParse is populated with an error message and a
104825 ** Whether or not an error is returned, it is the responsibility of the
104854 "table %s: xBestIndex returned an invalid plan", pTab->zName);
104899 ** wsFlags in an uninitialized state, the caller may behave unpredictably.
104923 ** be a pointer to an sqlite3_vtab structure. Otherwise
104945 ** For each attempt at picking an index, the order of tables in the
104982 /* If there is an ORDER BY clause, and the selected virtual table index
105011 ** to optimize an OR expression within the WHERE clause.
105019 ** Estimate the location of a particular key among all keys in an
105181 ** an sqlite3_value structure containing the same value, with affinity
105187 ** is an SQL variable that currently has a non-NULL value bound to it,
105188 ** create an sqlite3_value structure containing this value, again with
105193 ** If an error occurs, return an error code. Otherwise, SQLITE_OK.
105216 ** by scanning an index for a range of values. The range may have an upper
105243 ** The returned value is an integer divisor to reduce the estimated
105322 ** an equality constraint x=VALUE and where that VALUE occurs in
105324 ** column of an index and sqlite_stat3 histogram data is available
105329 ** If unable to make an estimate, leave *pnRow unchanged and return
105372 ** an IN constraint where the right-hand side of the IN operator
105378 ** If unable to make an estimate, leave *pnRow unchanged and return
105418 ** The lowest cost plan wins. The cost is an estimate of the amount of
105430 ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in
105466 ** use an index to satisfy IS NULL constraints on that table. This is
105530 ** The "in-multiplier". This is an estimate of how many seek operations
105536 ** SQLite must perform 9 lookups on an index on (a, b), so nInMul is
105563 ** Boolean. True if there is an ORDER BY clause that will require an
105572 ** used by the SELECT statement are present in the index (such an
105622 /* If the index being considered is UNIQUE, and there is an equality
105659 /* If there is an ORDER BY clause and the index being considered will
105661 ** in wsFlags. Otherwise, if there is an ORDER BY clause but the index
105681 /* If currently calculating the cost of using an index (not the IPK
105703 ** Estimate the number of rows of output. For an "x IN (SELECT...)"
105742 ** records being an important factor. Both moves and searches are
105755 ** We add an additional 4x penalty to full table scans. This causes
105756 ** the cost function to err on the side of choosing an index over
105757 ** choosing a full scan. This 4x full-scan penalty is an arguable
105767 /* For an index lookup followed by a table lookup:
105812 ** the notReady mask. When computing an "optimal" index, the notReady
105817 ** might be selected even when there exists an optimal index that has
105885 /* If there was an INDEXED BY clause, then only that one index is
105898 ** SQLite outputs rows in in the absence of an ORDER BY clause. */
105969 ** of the join. Disabling is an optimization. When terms are satisfied
105992 ** Code an OP_Affinity opcode to apply the column affinity string zAff
105995 ** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the
106097 ** Generate code that will evaluate all == and IN constraints for an
106103 ** example, the third "c" value is an inequality. So only two
106117 ** this routine allocates an additional nEq memory cells for internal
106153 /* This module is only called on query plans that use an index. */
106212 ** pStr holds the text of an expression that we are building up one term
106232 ** of the subset of table rows scanned by the strategy in the form of an
106239 ** is run and there is an index on (a, b), then this function returns a
106281 ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
106282 ** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single
106406 ** When there is an IN operator, we also have a "addrNxt" label that
106469 /* Case 1: We can directly reference a single row using an
106489 /* Case 2: We have an inequality comparison against the ROWID field.
106566 /* Case 3: A scan using an index.
106573 ** the right-most column can be an inequality - the rest must
106594 ** constraints but an index is selected anyway, in order
106595 ** to force the output order to conform to an ORDER BY.
106613 int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
106664 ** and store the values of those terms in an array of registers
106673 /* If we are doing a reverse order scan on an ascending index, or
106891 ** equivalent to an empty rowset.
106898 ** fall through to the next instruction, just as an OP_Next does if
106899 ** called on an uninitialized cursor.
107097 ** The return value is a pointer to an opaque structure that contains
107102 ** If an error occurs, this routine returns NULL.
107138 ** entire tables. Thus a three-way join is an O(N^3) operation. But if
107172 ** is called from an UPDATE or DELETE statement, then ppOrderBy is NULL.
107174 ** If an index can be used so that the natural output order of the table
107176 ** *ppOrderBy is set to NULL. This is an optimization that prevents an
107177 ** unnecessary sort of the result set if an index appropriate for the
107224 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
107225 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
107254 ** subexpression is separated by an AND operator.
107355 Bitmask notIndexed; /* Mask of tables that cannot use an index */
107367 ** to choose from. The first test looks for an "optimal" scan. In
107368 ** this context an optimal scan is one that uses the same strategy
107378 ** Note that the WhereCost.nRow parameter for an optimal scan might
107442 /* If an INDEXED BY clause is present, then the plan must use that
107458 ** the full-table-scan is an "optimal" plan as defined above.
107460 ** (3) All tables have an INDEXED BY clause or this table lacks an
107463 ** that a best-so-far is always selected even if an impossible
107519 /* Check that if the table scanned by this loop iteration had an
107522 ** Return an error.
107530 /* If an INDEXED BY clause is used, the bestIndex() function is
107532 ** if it find an index at all. */
107549 /* If the caller is an UPDATE or DELETE statement that is requesting
107777 /* If this scan uses an index, make code substitutions to read data
107929 /* Construct an expression node for a unary postfix operator
107954 /* Construct an expression node for a unary prefix operator
108072 ** functions that take a state number and lookahead value and return an
108597 ** the parse is retried before an error is thrown.
108692 /* The state of the parser is completely contained in an instance of
110492 /* When doing a nested parse, one can include terms in an expression
111134 ** <li> A pointer to the parser (an opaque structure.)
111155 int yyerrorhit = 0; /* True if yymajor has invoked an error */
111207 ** The response to an error depends upon whether or not the
111208 ** grammar defines an error token "ERROR".
111275 ** * Report an error message, and throw away the input token.
111312 ** This file contains C code that splits an SQL input string up into
111321 ** an upper-to-lower case map. On EBCDIC machines we also need
111352 ** The sqlite3KeywordCode function looks up an identifier to determine if
111371 ** or not a given identifier is really an SQL keyword. The same thing
111640 ** If X is a character that can be used in an identifier then
111644 ** allowed in an identifier. For 7-bit characters,
111953 ** passed in. An SQLITE_ status code is returned. If an error occurs
111954 ** then an and attempt is made to write an error message into
111966 int mxSqlLen; /* Max length of an SQL string */
112161 ** (1) START At the beginning or end of an SQL statement. This routine
112201 ** is look for a semicolon that is not part of an string or comment.
112520 ** returns an integer equal to SQLITE_VERSION_NUMBER.
112638 ** the pInitMutex mutex. Return an error in either case. */
112800 /* Specify an alternative mutex implementation */
112813 /* Specify an alternative malloc implementation */
112848 /* now an error */
112854 /* Specify an alternative page cache implementation */
112890 ** ENABLE_MEMSYS5 is defined, return an error.
113030 ** Configuration settings for an individual database connection
113196 ** Close an existing SQLite database
113367 /* SQLITE_OK */ "not an error",
113415 ** an integer number of milliseconds passed in as the first
113460 ** This routine is called when an operation failed with a lock.
113462 ** returns 0, the operation aborts with an SQLITE_BUSY error.
113477 ** This routine sets the busy callback for an Sqlite database to the
113495 ** This routine sets the progress callback for an Sqlite database to the
113545 ** that if a malloc() fails in sqlite3_create_function(), an error code
113599 /* Check if an existing function is being overridden or deleted. If so,
113622 /* If an older version of the function with a configured destructor is
113724 ** When virtual tables intend to provide an overloaded function, they
113846 ** is greater than sqlite3.pWalArg cast to an integer (the value configured by
113865 ** Configure an sqlite3_wal_hook() callback to automatically checkpoint
113927 /* Initialize the output variables to -1 in case an error occurs. */
113972 ** an error occurs while running the checkpoint, an SQLite error code is
113980 ** checkpointed. If an error is encountered it is returned immediately -
114118 ** Return the most recent error code generated by an SQLite routine. If NULL is
114172 /* Check if this call is removing or replacing an existing collation
114273 ** If an invalid limit index is supplied, report -1.
114337 ** If an error occurs, then an SQLite error code is returned and *pzErrMsg
114338 ** may be set to point to a buffer containing an English language error
114572 ** Throw an error if any non-sense combination is used. If we
114969 ** This function is now an anachronism. It used to be used to recover from a
115104 ** 2. The table is not a view and the column name identified an
115125 ** to whatever their local counterparts contain. If an error did occur,
115247 ** is an array of integers that defines the test. Return -1 on a
115248 ** memory allocation error, 0 on success, or non-zero for an error.
115282 ** an incompatible database file format. Changing the PENDING byte
115654 ** Register an unlock-notify callback.
115657 ** but has received an SQLITE_LOCKED error because another connection
115798 ** This is a difficult situation to handle. Returning an error
115799 ** code to the caller is insufficient, as even if an error code
115803 ** indefinitely for an unlock-notify callback that will never
115848 ** This is called when the database connection passed as an argument is
115874 ** This is an SQLite module implementing full-text search.
115880 ** * The FTS3 module is being built as an extension
115949 ** memory. A "position" is an index of a token in the token stream
115974 ** A bare doclist omits the position information, becoming an
116026 ** SegmentWriter creates new leaf nodes, or when an interior node
116043 ** Here, optional { X } means an optional element, while array { X }
116072 ** This could be either a leaf node or an interior node. If the top
116144 ** write an empty doclist (varint(docid) varint(POS_END)), for updates
116175 ** FTS4 is really an extension for FTS3. It is enabled using the
116177 ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
116222 ** an sqlite3_tokenizer_module containing pointers to the callback
116223 ** functions that make up an implementation.
116225 ** When an fts3 table is created, it passes any arguments passed to
116228 ** implementation. The xCreate() function in turn returns an
116232 ** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()
116233 ** method is called. It returns an sqlite3_tokenizer_cursor object
116260 ** This method should return either SQLITE_OK (0), or an SQLite error
116273 ** Destroy an existing tokenizer. The fts3 module calls this method
116279 ** Create a tokenizer cursor to tokenize an input buffer. The caller
116290 ** Destroy an existing tokenizer cursor. The fts3 module calls this
116299 ** the end of the buffer has been reached, or an SQLite error code.
116380 /* A complete hash table is an instance of the following structure.
116400 /* Each element in the hash table is an instance of the following
116491 ** Macro to return the number of elements in an array. SQLite has a
116493 ** a collision when building an amalgamation with built-in FTS3.
116519 ** It is considered impossible for an index to use more than 1024 levels. In
116611 ** A connection to a fulltext index is an instance of the following
116612 ** structure. The xCreate and xConnect methods create an instance
116654 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
116656 ** is an index of prefixes of a specific length.
116681 ** virtual table cursor (an instance of the following structure) using
116787 ** matchinfo data. If it is not NULL, it points to an array of size nCol*3,
117045 ** Convert an SQL-style quoted string into a normal string by removing
117195 ** Otherwise, return an SQLite error code.
117207 ** Otherwise, if an error occurs, an SQLite error code is stored in *pRc
117249 ** If the p->bHasDocsize boolean is true (indicating that this is an
117250 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
117317 ** Otherwise, if an error occurs, an SQLite error code is stored in *pRc
117377 ** Append the output of a printf() style formatting to an existing string.
117439 ** being returned directly each column of text data is passed to an SQL
117450 ** a NULL pointer is returned). Otherwise, if an OOM error is encountered
117497 ** is preceded by zFunc and an open bracket, and followed by a closed
117507 ** a NULL pointer is returned). Otherwise, if an OOM error is encountered
117539 ** Only decimal digits ('0'..'9') may be part of an integer value.
117560 ** This function is called to allocate an array of Fts3Index structures
117571 ** array. If an error does occur, an SQLite error code is returned.
117573 ** Regardless of whether or not an error is returned, it is the responsibility
117615 ** This function is called when initializing an FTS4 table that uses the
117629 ** *pazCol: Set to point to an array of *pnCol strings. Each string is
117635 ** If the table cannot be found, an error code is returned and the output
117636 ** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is
117783 /* Check if it is an FTS4 special argument. */
117995 /* If this is an xCreate call, create the underlying tables in the
118070 /* By default use a full table scan. This is an expensive option,
118096 ** it would lead to an "unable to use function MATCH in the requested
118150 /* Allocate a buffer large enough for an Fts3Cursor structure. If the
118181 ** compose and prepare an SQL statement of the form:
118186 ** it. If an error occurs, return an SQLite error code.
118252 ** If an OOM error occurs, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.
118275 ** varints from the buffer) does not risk an overread. If zNode is a
118355 ** The buffer pointed to by argument zNode (size nNode bytes) contains an
118373 ** If an error occurs, an error code other than SQLITE_OK is returned.
118451 /* The end of a position list is marked by a zero encoded as an FTS3
118516 ** Value used to signify the end of an position-list. This is safe because
118552 ** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by
118660 ** If isSaveLeft is 0, an entry is added to the output position list for
118779 ** position lists correspond to the left and right phrases of an expression
118917 ** This function does an "OR" merge of two doclists (output contains all
118923 ** If no error occurs, *paOut is set to point at an sqlite3_malloc'd buffer
118927 ** If an error occurs, an SQLite error code is returned. The output values
119077 ** of the entries from pList at position 0, and terminated by an 0x00 byte.
119128 ** If an OOM error occurs, return SQLITE_NOMEM. In this case it is
119174 ** as the first argument. The merge is an "OR" merge (see function
119183 ** This function returns SQLITE_OK if the merge is successful, or an
119184 ** SQLite error code (SQLITE_NOMEM) if an error occurs.
119266 ** This function returns SQLITE_OK if successful, or an SQLite error code
119286 ** made by an fts4aux module, not an FTS table. In this case calling
119363 /* "isScan" is only set to true by the ft4aux module, an ordinary
119378 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
119393 ** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,
119397 ** an SQLite error code.
119402 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
119403 ** Output parameter *ppSegcsr is set to 0 if an error occurs.
119418 int bFound = 0; /* True once an index has been found */
119460 ** Free an Fts3MultiSegReader allocated by fts3TermSegReaderCursor().
119552 ** subsequently to determine whether or not an EOF was hit.
119725 /* This call is a request for the "docid" column. Since "docid" is an
119849 ** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error
119941 ** where 't' is the name of an FTS3 table.
120031 ** Implementation of FTS3 xRename method. Rename an fts3 table.
120042 ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction
120150 ** This function is registered as the module destructor (called when an
120273 ** Allocate an Fts3MultiSegReader for each token in the expression headed
120278 ** Fts3SegReader objects internally to provide an interface to seek or scan
120284 ** and merged incrementally. Otherwise, it has to be merged into an in-memory
120385 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120421 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120520 ** function has been called successfully on an Fts3Phrase, it may be
120527 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120622 ** If an error occurs, return an SQLite error code. Otherwise, return
120706 ** If an error occurs within this function, *pRc is set to an SQLite error
120755 ** This function is used to populate an allocated Fts3TokenAndCost array.
120758 ** Otherwise, if an error occurs during execution, *pRc is set to an
120807 ** an SQLite error code.
120811 ** of data that will fit on a single leaf page of an intkey table in
120873 ** called on each token to defer. Otherwise, an SQLite error code is
121124 ** If an error occurs, *pRc is set to an SQLite error code. Otherwise, if
121148 ** is advanced to the next row that contains an instance of "A * C",
121361 ** If an error occurs during execution of this function, *pRc is set to
121531 ** a no-op. If an error occurs within this function, *pRc is set to an
121613 ** populated. Otherwise, if an error occurs, an SQLite error code is returned.
121766 ** compression and is terminated by either an 0x01 or 0x00 byte. For example,
121929 /* The user should specify a single argument - the name of an fts3 table. */
122296 ** if successful or an error code if sqlite3_create_module() fails.
122367 ** than an implicit AND. When using the new, both implicity and explicit
122441 ** is defined to accept an argument of type int, its behaviour when passed
122442 ** an integer that falls outside of the range of the unsigned char type
122444 ** is defined to accept an argument of type char, and always returns 0 for
122493 ** and other information (column names etc.) in pParse. Create an Fts3Expr
122571 ** Enlarge a memory allocation. If an out-of-memory allocation occurs,
122584 ** that appeared as part of an fts3 query expression. Neither quote character
122586 ** input buffer and create an Fts3Expr structure of type FTSQUERY_PHRASE
122711 ** The output variable *ppExpr is populated with an allocated Fts3Expr
122714 ** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM
122716 ** If SQLITE_ERROR is returned, pContext is populated with an error message.
122746 /* Skip over any whitespace before checking for a keyword, an open or
122770 /* If this is a "NEAR" keyword, check for an explicit nearness. */
122782 ** the next byte must contain either whitespace, an open or close
122806 /* Check for an open bracket. */
122844 ** interface. Before doing so, figure out if there is an explicit
122849 ** an implementation artifact or an intentional decision when fts3 was
122872 ** The argument is an Fts3Expr structure for a binary operator (any type
122873 ** except an FTSQUERY_PHRASE). Return an integer value representing the
122934 ** returns either when the end of the buffer is reached or an unmatched
122966 /* Create an implicit NOT operator. */
122985 ** an expression contained in parenthesis is required. If a
122996 /* Insert an implicit AND operator. */
123017 ** Return an error in either case.
123082 ** an fts3 query expression, respectively. This function attempts to parse the
123085 ** of the parsed expression tree and SQLITE_OK is returned. If an error
123199 ** sqlite3_free() to release the memory. If an OOM condition is encountered,
123368 ** * The FTS3 module is being built as an extension
123484 ** with types "const void*" and "int" and returns an "int".
123510 /* Link an element into the hash table
123562 /* This function (for internal use only) locates an element in an
123645 ** Attempt to locate an element of the hash table pH with a key
123656 /* Insert an element into the hash table pH. The key is pKey,nKey
123751 ** * The FTS3 module is being built as an extension
123906 ** In prose: A word is an optional consonant followed by zero or
123907 ** vowel-consonant pairs followed by an optional vowel. "m" is the
123916 ** for an instance of of a consonant followed by a vowel.
124392 ** This is part of an SQLite module implementing full-text search.
124399 ** * The FTS3 module is being built as an extension
124424 ** an error is returned.
124758 ** in the README.tokenizer file as an example, so it is important to
124888 ** * The FTS3 module is being built as an extension
125137 ** it is always safe to read up to two varints from it without risking an
125341 ** This function is used to obtain an SQLite prepared statement handle
125344 ** Otherwise, an SQLite error code is returned and *pp is set to 0.
125346 ** If argument apVal is not NULL, then it must point to an array with
125482 ** Returns SQLITE_OK if the statement is successfully executed, or an
125582 ** return SQLITE_OK. If an error occurs while preparing the statement,
125583 ** return an SQLite error code.
125633 ** if successful, or an SQLite error code otherwise.
125683 ** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.
125747 ** Add an entry to one of the pending-terms hash tables.
125785 ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
125908 ** This function is called by the xUpdate() method as part of an INSERT
125934 ** This function is called by the xUpdate() method for an INSERT operation.
125991 ** In FTS3, this is an error. It is an error to specify non-NULL values
126053 ** (an integer) of a row about to be deleted. Remove all terms from the
126109 ** returned. Otherwise, an SQLite error code is returned.
126166 ** If an error occurs, or the table does not contain the specified row,
126167 ** an SQLite error code is returned. Otherwise, SQLITE_OK is returned. If
126171 ** This function may leave an open sqlite3_blob* handle in the
126278 ** Set an Fts3SegReader cursor to point at EOF.
126292 ** SQLITE_DONE. Otherwise, an SQLite error code.
126330 /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf
126446 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
126466 /* Pointer p currently points at the first byte of an offset list. The
126617 ** an array of pending terms by term. This occurs as part of flushing
126635 ** This function is used to allocate an Fts3SegReader that iterates through
126773 ** version, it is assumed that each SegReader points to an entry in
126835 ** Argument apSegment is an array of nSegment elements. It is known that
127076 ** blocks were written to the db). Otherwise, an SQLite error code is
127146 ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
127284 ** returned. Otherwise, an SQLite error code.
127331 ** The first value in the apVal[] array is assumed to contain an integer.
127337 ** document pRowid, or false otherwise, and SQLITE_OK is returned. If an
127338 ** error occurs, an SQLite error code is returned.
127365 ** Return SQLITE_OK if successful, or an SQLite error code if not.
127407 ** SQLITE_OK is returned if successful, otherwise an SQLite error code.
127508 ** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered
127764 ** Similarly, if this is a search for an exact match, and the first term
127915 ** Otherwise, if successful, SQLITE_OK is returned. If an error occurs,
127916 ** an SQLite error code is returned.
128216 /* Compose and prepare an SQL statement to loop through the content table */
128424 ** Add an entry for token pToken to the pCsr->pDeferred list.
128506 int isRemove = 0; /* True for an UPDATE or DELETE */
128544 /* If this is an INSERT operation, or an UPDATE that modifies the rowid
128566 ** the statement is either an INSERT or an UPDATE that modifies the
128575 ** be losslessly converted to an integer. In this case, the eventual
128579 ** docid=$pNewRowid if $pNewRowid is not an integer value).
128600 /* If this is an INSERT or UPDATE operation, insert the new record. */
128694 ** Used as an fts3ExprIterate() context when loading phrase doclists to
128738 ** This type is used as an fts3ExprIterate() context object while
128768 ** element of the list is represented by an FTS3 varint that takes the value
128780 ** When this function is called, *pp points to the start of an element of
128817 ** Iterate through all phrase nodes in an FTS3 query, except those that
128836 ** This is an fts3ExprIterate() callback used while loading the doclists
129012 ** This function is an fts3ExprIterate() callback used by fts3BestSnippet().
129013 ** Each invocation populates an element of the SnippetIter.aPhrase[] array.
129547 ** Advance the iterator passed as an argument to the next position. Return
129575 ** Otherwise, if an error occurs, an SQLite error code is returned and the
129645 ** Populate the buffer pInfo->aMatchinfo[] with an array of integers to
129657 ** Return SQLITE_OK if successful, or an SQLite error code if an error
129762 ** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32).
129949 ** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().
130033 /* Retreive the text stored in column iCol. If an SQL NULL is stored
130035 ** If an OOM occurs while retrieving the data (this can happen if SQLite
130174 ** algorithms packaged as an SQLite virtual table module.
130192 ** an entry in the %_parent table associating the node with its parent.
130193 ** And for each row of data in the table, there is an entry in the %_rowid
130197 ** The root node of an r-tree always exists, even if the r-tree table is
130210 ** consists of a single 8-byte integer followed by an even number
130219 ** This file contains an implementation of a couple of different variants
130350 ** If an R*-tree "Reinsert" operation is required, the same number of
130361 ** 2^40 is greater than 2^64, an r-tree structure always has a depth of
130384 ** The argument is an RtreeCoord. Return the value stored within the RtreeCoord
130444 ** the right-hand-side of an SQL MATCH operator used to constrain an
130620 ** Obtain a reference to an r-tree node.
130821 ** an internal node, then the 64-bit integer is a child page number.
131048 ** Return SQLITE_OK if successful or an SQLite error code if an error
131100 ** Return SQLITE_OK if successful or an SQLite error code if an error
131326 ** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf
131327 ** to zero and return an SQLite error code.
131438 ** can be cast into an RtreeMatchArg object. One created using
131439 ** an sqlite3_rtree_geometry_callback() SQL user function.
131528 /* We have an equality constraint on the rowid. Use strategy 1. */
131538 /* This strategy involves a two rowid lookups on an B-Tree structures
131539 ** and then a linear search of an R-Tree node. This should be
131541 ** sqlite uses an internal cost of 0.0).
132346 /* Allocate an array and populate it with a copy of pCell and
132466 ** This operation is required when a row is deleted (or updated - an update
132467 ** is implemented as a delete followed by an insert). SQLite provides the
132893 /* Constraint handling. A write operation on an r-tree table may return
132953 /* If azData[0] is not an SQL NULL value, it is the rowid of a
133018 rtreeConnect, /* xConnect - connect to an existing table */
133114 ** The second argument to this function contains the text of an SQL statement
133117 ** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error
133139 ** Otherwise, an SQLite error code is returned.
133141 ** If this function is being called as part of an xConnect(), then the rtree
133145 ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size.
133204 "Wrong number of columns for an rtree table", /* 1 */
133205 "Too few columns for an rtree table", /* 2 */
133206 "Too many columns for an rtree table" /* 3 */
133282 ** an r-tree node, and the number of dimensions the r-tree indexes.
133380 ** Each call to sqlite3_rtree_geometry_callback() creates an ordinary SQLite
133461 ** This file implements an integration between the ICU library
133462 ** ("International Components for Unicode", an open-source library
133535 ** 1. uPattern is an unescaped match-all character "%",
133536 ** 2. uPattern is an unescaped match-one character "_",
133537 ** 3. uPattern is an unescaped escape character, or
133538 ** 4. uPattern is to be handled as an ordinary character
133598 ** is implemented as like(B, A). If there is an escape character E,
133624 ** Otherwise, return an error.
133644 ** This function is called when an ICU function called from within
133645 ** the implementation of an SQL scalar function returns an error.
133648 ** loaded with an error message based on the following two args.
133674 ** argument is an SQL NULL, then NULL Is returned. Otherwise, the result
133737 ** leaving the regular expression object configured with an invalid
133763 ** of the locale to use. Passing an empty string ("") or SQL NULL value
133848 ** types to an SQLite database connection. It is intended to be called
133853 ** Where <locale> is a string containing an ICU locale identifier (i.e.