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
24901 ** on an older machine (ex: RedHat 6.0). If you compile on RedHat 7.2
25001 ** structure are used to store the file descriptor while waiting for an
25772 ** A pointer to an instance of the following structure can be used as a
25856 /* Search for an existing entry that matching the canonical name.
25918 ** an exclusive lock on fd1, then try to get an exclusive lock
25943 ** The sqlite3_file structure for POSIX is no longer just an integer file
25951 ** file is unlocked. cnt==-1 means the file has an exclusive lock.
25957 ** a locked and an unlocked state.
25965 ** When an attempt is made to close an unixFile, if there are
26012 ** structure contains a pointer to an instance of this object and this
26045 ** It is invoked after an error occurs in an OS function and errno has been
26080 ** strerror_r(), which always writes an error message into aErr[].
26083 ** available, the error message will often be an empty string. Not a
26120 ** So we don't even try to recover from an EINTR. Just log the error
26178 ** return value might be uninitialized if an error occurs.
26183 ** Return an appropriate error code.
26211 /* On OS X on an msdos filesystem, the inode number is reported
26216 ** an ASCII 'S' character which also happens to be the first byte
26270 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
26317 ** ever obtained is an exclusive lock, and it is obtained exactly once
26484 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
26542 /* We are trying for an exclusive lock but another thread in this
26624 ** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED
26728 ** process is holding an incompatible lock. If it does, this
26732 ** an assert to fail). */
26752 /* Decrement the shared lock counter. Release the lock using an
26915 ** Nevertheless, a dotlock is an appropriate locking mode for use if no
26920 ** The existance of a lock directory implies an EXCLUSIVE lock. All other
26934 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27011 /* grab an exclusive lock */
27107 ** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite
27134 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27159 /* unlock failed with an error */
27231 /* grab an exclusive lock */
27275 /* shared can just be set because we always have an exclusive */
27324 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27443 /* shared can just be set because we always have an exclusive */
27519 ** This is a utility for setting or clearing a bit-range lock on an
27568 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27701 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
27753 /* We are trying for an exclusive lock but another thread in this
27771 /* Acquire an EXCLUSIVE lock */
27890 /* Decrement the shared lock counter. Release the lock using an
28230 ** unix systems. The following procedure is an attempt to make
28236 ** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash
28248 ** as far as SQLite is concerned, an fdatasync() is always adequate.
28290 /* If the FULLFSYNC failed, fall back to attempting an fsync().
28293 ** isn't supported for this file system. So, attempt an fsync
28323 ** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM
28324 ** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined
28426 ** Truncate an open file to a specified size
28435 ** file so that it consists of an integer number of chunks (i.e. the
28519 ** or an error number on failure". See the manpage for details. */
28569 ** Information and control of an open file handle.
28667 ** Object used to represent an shared memory buffer.
28714 ** Structure used internally by this VFS to record the state of an
28856 ** Another approach to is to use files in /dev/shm or /dev/tmp or an
28865 ** option results in an incompatible build of SQLite; builds of SQLite
28876 ** that means that an exclusive lock is held on the database file and
28895 /* Check to see if a unixShmNode object already exists. Reuse an existing
28905 ** a new *-shm file is created, an attempt will be made to create it
29017 ** If an error occurs, an error code is returned and *pp is set to NULL.
29195 ** If any sibling already holds an exclusive lock, go ahead and return
29680 /* If an error occured in findInodeInfo(), close the file descriptor
29834 /* It's odd to simulate an io-error here, but really this is just
29873 ** Search for an unused file descriptor that was opened on the database
29891 /* Do not search for an unused file descriptor on vxworks. Not because
29894 ** not to risk breaking vxworks support for the sake of such an obscure
29900 ** almost certain that an open() call on the same path will also fail.
29901 ** For this reason, if an error occurs in the stat() call here, it is
29903 ** descriptor on the same path, fail, and return an error to SQLite.
29934 ** written to *pMode. If an IO error occurs, an SQLite error code is
29938 ** an indication to robust_open() to create the file using
30379 /* It's odd to simulate an io-error here, but really this is just
30640 ** shared range is taken for an EXCLUSIVE lock):
30706 ** by taking an sqlite-style shared lock on the conch file, reading the
30712 ** host ID and/or proxy path, then the lock is escalated to an exclusive
30727 ** The shared lock and an open file descriptor are maintained until
31005 ** Takes an open conch file, copies the contents to a new path and then moves
31197 do { /* in case we need to try again for an :auto: named lock file */
31249 /* We are trying for an exclusive lock but another thread in this
31494 ** Takes an already filled in unix file and alters it so all file locking
31656 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
31804 ** The following macro defines an initializer for an sqlite3_vfs object.
31820 ** database file and tries to choose an locking method appropriate for
32160 BOOL bExclusive; /* Indicates an exclusive lock has been obtained */
32535 ** an ANSI string regardless of the _UNICODE setting */
32818 ** Here is an interesting observation: Win95, Win98, and WinME lack
32884 ** Change the size of an existing memory allocation
32912 ** Return the size of an outstanding allocation, in bytes.
33073 ** Convert an ANSI string to Microsoft Unicode, based on the
33240 ** This routine is invoked after an error occurs in an OS function.
33293 ** to give up with an error.
33513 /* Wanting an exclusive lock? */
33577 /* Releasing a reader lock or an exclusive lock */
33579 /* Did we have an exclusive lock? */
33678 ** whether an error has actually occured, it is also necessary to call
33697 ** It is reported that an attempt to close a handle might sometimes
33702 ** giving up and returning an error.
33834 ** Truncate an open file to a specified size
33846 ** file so that it consists of an integer number of chunks (i.e. the
34131 /* Acquire an EXCLUSIVE lock
34429 ** Structure used internally by this VFS to record the state of an
34591 /* Look to see if there is an existing winShmNode that can be used.
34769 ** If any sibling already holds an exclusive lock, go ahead and return
34843 ** If an error occurs, an error code is returned and *pp is set to NULL.
34983 ** This vector defines all the methods that can operate on an
35046 /* It's odd to simulate an io-error here, but really this is just
35347 ** up and returning an error.
35422 /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
35508 /* It's odd to simulate an io-error here, but really this is just
35730 ** strerror_r() on Unix). After an error is returned by an OS
35744 ** Not supplying an error message will have no adverse effect
35745 ** on SQLite. It is fine to have an implementation that never
35746 ** returns an error message:
35753 ** However if an error message is supplied, it will be incorporated
35825 ** This file implements an object that represents a fixed-length
35877 ** (an arbitrary prime)in the hash function provided
35885 ** A bitmap is an instance of the following structure.
35966 ** Set the i-th bit. Return 0 on success and an error code if
35971 ** that can go wrong with an insert, assuming p and i are valid.
36106 ** Let V[] be an array of unsigned characters sufficient to hold
36107 ** up to N bits. Let I be an integer between 0 and N. 0<=I<N.
36116 ** This routine runs an extensive test of the Bitvec code.
36118 ** The input is an array of integers that acts as a program
36141 ** an error is returned. If they are the same, zero is returned.
36239 ** A complete page cache is an instance of this structure.
36272 ** is not, either fail an assert or return zero. Otherwise, return
36348 ** being used for an in-memory database, this function is a no-op.
36783 ** Return the number of references to the page supplied as an argument.
36872 ** pages when they are under memory pressure. A PGroup is an instance of
36901 /* Each page cache is an instance of the following object. Every
36904 ** is an instance of this object.
36934 ** Each cache entry is represented by an instance of the following
36978 ** (2) even if an incorrect value is read, no great harm is done since this
36979 ** is really just an optimization. */
37002 ** verb to sqlite3_config(). Parameter pBuf points to an allocation large
37070 ** Free an allocated buffer obtained from pcache1Alloc().
37184 ** Free an allocated buffer obtained from sqlite3PageMalloc().
37299 ** Remove the page supplied as an argument from the hash table
37510 ** For a non-purgeable cache (a cache used as the storage for an in-memory
37570 /* Step 1: Search the hash table for an existing entry. */
37585 ** local variable here. Delaying the initialization of pGroup is an
37684 /* It is an error to call this function if the page is already
37787 ** already provided an alternative.
37877 ** This module implements an object we call a "RowSet".
37880 ** are inserted into the RowSet in an arbitrary order. Inserts
37898 ** TEST checks to see if an element is already in the RowSet. SMALLEST
37902 ** allocated in chunks so most INSERTs do no allocation. There is an
37908 ** in the batch number. In other words, if an INSERT occurs between
37917 ** The cost of an INSERT is roughly constant. (Sometime new memory
37918 ** has to be allocated on an INSERT.) The cost of a TEST with a new
37924 ** There is an added cost of O(N) when switching between TEST and
37941 ** Each entry in a RowSet is an instance of the following object.
37961 ** A RowSet in an instance of the following structure.
37984 ** an assertion fault occurs.
37986 ** If N is larger than the minimum, use the surplus as an initial
38166 ** list contains too few elements, then construct an incomplete tree
38375 ** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and
38396 /* Return an integer that records the current (uncommitted) write
38427 /* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)
38489 ** (3) Writes to the database file are an integer multiple of the page size
38493 ** an integer multiple of the page size in length or are taken from the
38554 ** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file
38647 ** If the connection is running with locking_mode=exclusive, an attempt
38648 ** is made to obtain an EXCLUSIVE lock on the database file.
38703 ** commit the transaction. If an error did occur, the caller will need
38708 ** The ERROR state is entered when an IO or disk-full error (including
38716 ** For example, if an IO error occurs while performing a rollback,
38717 ** the contents of the page-cache may be left in an inconsistent state.
38723 ** instead of READER following such an error.
38726 ** to read or write data returns an error. Eventually, once all
38754 ** automatically attempt a rollback, as it assumes that an error in a
38755 ** read-only statement cannot leave the pager in an internally inconsistent
38761 ** * The pager is not an in-memory pager.
38792 ** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY
38801 ** This is usually safe. If an xUnlock fails or appears to fail, there may
38809 ** fails at this point and the pager is left holding an EXCLUSIVE lock, this
38815 ** return true because the caller itself is holding an EXCLUSIVE lock (but
38817 ** a hot-journal may be mistaken for a journal being created by an active
38826 ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
38853 ** such a system. This is currently an undocumented limit.
38883 ** A open page cache is an instance of struct Pager. A description of
38913 ** can only happen if an exclusive lock is held on the database file.
38914 ** It is cleared (set to false) whenever an exclusive lock is
38944 ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the
38969 ** is opened as an in-memory journal file. If false, then in-memory
38984 ** is not an integer multiple of the page-size, the value stored in
39141 ** file after power is restored. If an attempt is then made
39143 ** sanity checking data is an attempt to discover the garbage in the
39153 ** garbage data came from an obsolete journal file, the checksums might
39174 ** The macro MEMDB is true if we are dealing with an in-memory database.
39243 ** as if it has an exclusive lock on the database file. It never updates
39255 /* Check that MEMDB implies noSync. And an in-memory journal. Since
39256 ** this means an in-memory pager performs no IO at all, it cannot encounter
39260 ** is therefore not possible for an in-memory pager to enter the ERROR
39361 ** containing the state of the Pager object passed as an argument. This
39362 ** is intended to be used within debuggers. For example, as an alternative
39440 ** that is read in *pRes. Return SQLITE_OK if everything worked, or an
39462 ** on success or an error code is something goes wrong.
39477 ** UNKNOWN_LOCK for an explanation of this.
39503 ** See the comment above the #define of UNKNOWN_LOCK for an explanation
39530 ** an error to call this function if pPager is opened on an in-memory
39586 ** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES
39587 ** is defined, and NDEBUG is not defined, an assert() statement checks
39626 ** If an error occurs while reading from the journal file, an SQLite
39712 ** If an IO error occurs, abandon processing and return the IO error code.
39880 ** cannot be read from the journal file an error code is returned.
39907 ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise,
39922 ** of the transaction. Return an error code if anything goes wrong.
40042 ** an error occurs, return the error code to the caller.
40189 ** above the #define for UNKNOWN_LOCK for an explanation of why this
40225 ** This function is called whenever an IOERR or FULL error that requires
40261 ** after rollback of a hot-journal, or if an error occurs while opening
40279 ** Journal file descriptor is simply closed. This destroys an
40302 ** SQLITE_OK is returned if no error occurs. If an error occurs during
40315 /* Do nothing if the pager does not have an open write transaction
40323 ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE
40359 ** the database file, it will do so using an in-memory journal.
40421 ** If the pager has not already entered the ERROR state, but an IO or
40449 ** Each byte is interpreted as an 8-bit unsigned integer.
40451 ** Changing the formula used to compute this checksum results in an
40505 ** and played back, then SQLITE_OK is returned. If an IO error occurs
40519 ** allocated by this function. If this is the case and an allocation fails,
40549 ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback
40558 ** file. Return an error code to the caller if an IO error occurs.
40606 ** and a page is moved during an incremental vacuum then the page may
40625 ** database file without an entry in the rollback journal that can
40680 ** The solution is to add an in-memory page to the cache containing
40699 ** of an internal error resulting in an automatic call to
40714 ** back as part of a savepoint (or statement) rollback from an
40777 ** If an IO error within this function, an error code is returned. This
40778 ** function allocates memory by calling sqlite3Malloc(). If an allocation
40894 ** If successful, return SQLITE_OK. If an IO error occurs while modifying
40999 ** Each entry in the journal is an instance of the 8th item.
41022 ** If an I/O or malloc() error occurs, the journal-file is not deleted
41023 ** and an error code is returned.
41057 ** TODO: Technically the following is an error because it assumes that
41076 ** pager_playback_one_page() call returns SQLITE_DONE or an IO error
41180 /* If this playback is happening automatically as a result of an IO or
41230 ** If an IO error occurs, then the IO error is returned to the caller.
41270 ** For an encrypted database, the situation is more complex: bytes
41296 ** This is an unconditional update. See also the pager_incr_changecounter()
41325 ** return an SQLite error code. Otherwise, SQLITE_OK.
41484 ** in pages is stored in *pnPage. Otherwise, an error code (perhaps
41502 ** of the database file is not an integer multiple of the page-size,
41541 ** Return SQLITE_OK or an error code.
41544 ** function. Because an EXCLUSIVE lock on the db file is required to delete
41546 ** between the xAccess() below and an xDelete() being executed by some
41750 ** that an inopertune power failure could leave the journal
41767 ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL
41773 ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an
41859 ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE
41890 ** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).
41899 ** * the database is either not an in-memory database or it is
41900 ** an in-memory database that currently consists of zero pages.
41921 ** At one point this function returned an error if the pager was in
42036 ** the Pager object. There has not been an opportunity to transition
42075 ** Return SQLITE_OK on success and an error code if we cannot obtain
42158 ** an SQLite error code.
42180 ** This function always succeeds. If a transaction is active an attempt
42181 ** is made to roll it back. If an error occurs during the rollback
42202 ** If this is not done, then an unsynced portion of the open journal
42206 ** If an error occurs while trying to sync the journal, shift the pager
42262 ** * If the journal file is an in-memory journal file, no action need
42285 ** page currently held in memory before returning SQLITE_OK. If an IO
42307 /* This block deals with an obscure problem. If the last connection
42403 ** be NULL, representing an empty list. In this case this function is
42408 ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,
42427 ** If everything is successful, SQLITE_OK is returned. If an IO error
42428 ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
42539 ** This function returns SQLITE_OK if everything is successful, an IO
42585 ** (cast as a void*). The pager is always 'purgeable' (not an in-memory
42596 ** SQLITE_OK returned. If an IO error occurs while trying to make the
42616 ** Spilling is also prohibited when in an error state since that could
42707 ** This can be used to implement an in-memory database.
42722 ** the new pager object. If an error occurs, *ppPager is set to NULL
42740 int memDb = 0; /* True if this is an in-memory file */
42753 ** is the maximum space required for an in-memory journal file handle
42765 /* Set the output variable to NULL in case an error occurs. */
42775 /* Compute and store the full pathname in an allocated buffer pointed
42913 ** This branch is also run for an in-memory database. An in-memory
42915 ** disk and uses an in-memory rollback journal.
42932 /* If an error occurred in either of the blocks above, free the
43021 ** exists, that is probably an old journal left over from a prior
43035 ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying
43110 ** its has a zero header, that might be due to an I/O error, or
43115 ** with it under an EXCLUSIVE lock where we do not need to
43138 ** on the database file), then an attempt is made to obtain a
43148 ** then an attempt is made to clear the error state by discarding
43152 ** If everything is successful, SQLITE_OK is returned. If an IO error
43190 /* Get an EXCLUSIVE lock on the database file. At this point it is
43244 ** an inconsistent cache. Sync the hot journal before playing
43261 /* This branch is taken if an error occurs while trying to open
43262 ** or roll back a hot-journal while holding an EXCLUSIVE lock. The
43266 ** UNKNOWN_LOCK above for an explanation).
43303 ** detected. The chance of an undetected change is so small that
43378 ** choose not to allocate a new page object and may reuse an existing
43410 ** an appropriate error code is returned and *ppPage is set to NULL.
43416 ** has to go to disk, and could also playback an old journal if necessary.
43436 /* If the pager is in the error state, return an error immediately.
43445 /* Either the call to sqlite3PcacheFetch() returned an error or the
43455 /* In this case the pcache already contains an initialized copy of
43579 ** an IO error code if opening or writing the journal file fails.
43591 ** an error state. */
43653 ** an EXCLUSIVE lock. If such a lock is already held, no locking
43657 ** within this transaction will be opened as an in-memory file. This
43661 ** sub-journal is implemented in-memory if pPager is an in-memory database,
43675 /* If the pager is configured to use locking_mode=exclusive, and an
43687 ** PAGER_RESERVED state. Otherwise, return an error code to the caller.
43694 ** is true, then immediately upgrade this to an EXCLUSIVE lock. The
43708 ** when it has an open transaction, but never to DBMOD or FINISHED.
43752 /* If an error has been previously detected, report the same error
43768 ** an error might occur and the pager would end up in WRITER_LOCKED state
43786 /* The transaction journal now exists and we have a RESERVED or an
43806 /* Even if an IO or diskfull error occurs while journalling the
43810 ** in the database file. And if an IO error occurs while doing so,
43879 ** If an error occurs, SQLITE_NOMEM or an IO error code is returned
43909 ** an integer power of 2. It sets variable pg1 to the identifier
44016 ** See also the pager_write_changecounter() routine that does an
44027 ** by writing an updated version of page 1 using a call to the
44105 ** function returns SQLITE_OK. Otherwise, an IO error code is returned.
44125 ** Otherwise, if the connection does not already have an EXCLUSIVE lock on
44126 ** the database file, an attempt is made to obtain one.
44130 ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is
44165 ** passed to an sqlite3PagerCommitPhaseOne() call.
44196 /* If this is an in-memory db, or no pages have been written to, or this
44371 ** If an error occurs, an IO error code is returned and the pager
44417 ** state if an error occurs.
44476 /* If an error occurs during a ROLLBACK, we can no longer trust the pager
44563 ** Return true if this is an in-memory pager.
44575 ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error
44576 ** occurs while opening the sub-journal file, then an IO error code is
44650 ** In any case, all savepoints with an index greater than iSavepoint
44655 ** or an IO error code if an IO error occurs while rolling back a
44682 /* Only truncate if it is an in-memory sub-journal. */
44789 ** This function may return SQLITE_NOMEM or an IO error code if an error
44804 /* In order to be able to rollback, an in-memory database must journal
44865 /* Do not discard pages from an in-memory database since we might
44877 /* For an in-memory database, make sure the original page continues
45003 /* Do allow the journalmode of an in-memory database to be set to
45035 ** here is an optimization only.
45108 ** uses it opaquely as an argument to sqlite3BackupRestart() and
45117 ** Unless this is an in-memory or temporary database, clear the pager cache.
45158 ** Attempt to take an exclusive lock on the database file. If a PENDING lock
45177 ** exclusive-locking mode when this function is called, take an EXCLUSIVE
45197 ** (e.g. due to malloc() failure), return an error code.
45215 ** file (not a temp file or an in-memory database), and the WAL file
45216 ** is not already open, make an attempt to open it now. If successful,
45217 ** return SQLITE_OK. If an error occurs or the VFS used by the pager does
45218 ** not support the xShmXXX() methods, return an error code. *pbOpen is
45259 ** Before closing the log file, this function attempts to take an
45260 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
45286 /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on
45358 ** transferred back into the database file in an operation called a
45410 ** an even number of unsigned 32-bit integers: x[0] through x[N]. The
45473 ** use an architecture-specific format; it does not have to be cross-platform.
45482 ** The wal-index consists of a header region, followed by an one or
45497 ** that allows readers to query an index block for a specific page number.
45498 ** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE
45522 ** prior to finding a match is 1. Each entry of the hash table is an
45523 ** 1-based index of an entry in the mapping section of the same
45537 ** reached) until an unused hash slot is found. Let the first unused slot
45540 ** the search is guaranteed to eventually hit an unused entry. Let
45566 ** slots in the hash table and so the first reader will get an answer as
45670 ** is holding an exclusive lock on WAL_READ_LOCK(K). Thus, the value of
45678 ** largest value and will increase an unused aReadMark[] to mxFrame if there
45679 ** is not already an aReadMark[] equal to mxFrame. The exception to the
45724 ** file are calculated by treating all data as an array of 32-bit
45740 ** An open write-ahead log file is represented by an instance of the
45786 ** an array of HASHTABLE_NSLOT elements of the following type.
45791 ** This structure is used to implement an iterator that loops through
45800 ** walIteratorNext() - Step an iterator,
45801 ** walIteratorFree() - Free an iterator.
45847 ** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,
45848 ** then an SQLite error code is returned and *ppPage is set to 0.
45918 ** Generate or extend an 8 byte checksum based on the data in
46081 ** a part of an ordinary build.
46300 ** Set an entry in the wal-index that will map database page number
46385 ** This routine first tries to establish an exclusive lock on the
46399 /* Obtain an exclusive lock on all byte in the locking range not already
46535 /* If more than one frame was recovered from the log file, report an
46554 ** Close an open wal-index.
46580 ** *ppWal is set to point to a new WAL handle. If an error occurs,
46581 ** an SQLite error code is returned and *ppWal is left unmodified.
46610 /* Allocate an instance of struct Wal to return. */
46834 ** Free an iterator allocated by walIteratorInit().
46846 ** return SQLITE_OK. Otherwise, return an error code. If this routine
46847 ** returns an error, the value of *pp is undefined.
46958 ** in response to an sqlite3_wal_checkpoint() request or the equivalent.
47107 /* If this is an SQLITE_CHECKPOINT_RESTART operation, and the entire wal
47132 ** it to exactly nMax bytes. If an error occurs while doing so, ignore it.
47161 /* If an EXCLUSIVE lock can be obtained on the database file (using the
47240 ** meaning it is possible that an inconsistent snapshot is read
47286 ** Otherwise an SQLite error code.
47294 ** wal-index header) is mapped. Return early if an error occurs here.
47360 ** On success return SQLITE_OK. On a permanent failure (such an
47361 ** I/O error or an SQLITE_BUSY because another process is running
47368 ** wal-index header has changed, *pChanged is set to 1 (as an indication
47376 ** race conditions after multiple WAL_RETRY returns, and after an excessive
47402 ** so it takes care to hold an exclusive lock on the corresponding
47426 ** is more of a scheduler yield than an actual delay. But on the 10th
47427 ** an subsequent retries, the delays start becoming longer and longer,
47520 /* There was once an "if" here. The extra "{" is to preserve indentation. */
47563 ** log-wrap (either of which would require an exclusive lock on
47644 ** in this case as an optimization. Likewise, if pWal->readLock==0,
47653 /* Search the hash table or tables for an entry matching page number
47820 ** Otherwise, if the callback function does not return an error, this
47840 ** (b) has an outstanding reference, then xUndo is either a no-op
47859 ** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32
47874 ** the values in the aWalData[] array. aWalData must point to an array
47914 ** if an error occurs.
48112 ** an out-of-order write following a WAL restart could result in
48367 ** upgrade to exclusive-mode following such an error.
48478 ** bytes are stored on overflow pages. The payload for an entry
48488 ** Each page can be either a btree page, a freelist page, an overflow
48534 ** payload is spilled to overflow pages. Once an overflow page is allocated,
48697 ** As each page of the file is loaded into memory, an instance of the following
48762 ** A database connection contains a pointer to an instance of
48884 #define BTS_EXCLUSIVE 0x0020 /* pWriter has an exclusive lock */
48905 ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
48948 u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */
48974 ** A unrecoverable error (an I/O error or a malloc failure) has occurred
48976 ** cursor. The error has left the cache in an inconsistent state.
49026 ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
49057 ** within an expression that is an argument to another macro
49379 ** Including a description of file format and an overview of operation.
49400 ** Extract a 2-byte big-endian integer from an array of unsigned bytes.
49464 **** This function is only used as part of an assert() statement. ***
49474 ** When writing to an index that resides in a sharable database, the
49488 int isIndex, /* True if iRoot is the root of an index b-tree */
49505 /* If the client is reading or writing an index and the schema is
49595 /* If requesting a write-lock, then the Btree must have an open write
49597 ** must be an open write transaction on the file itself.
49607 /* If some other connection is holding an exclusive lock, the
49678 /* First search the list for an existing lock on this table. */
49718 ** This function assumes that Btree p has an open read or write
49857 ** The BtShared.pHasContent bitvec exists to work around an obscure
49940 /* If this is an intKey table, then the above call to BtreeKeySize()
49942 ** all that is required. Otherwise, if pCur is not open on an intKey
50013 const void *pKey, /* Packed key if the btree is an index */
50074 ** This routine returns an error code if something goes wrong. The
50118 ** Write an entry into the pointer map.
50124 ** a no-op. If an error occurs, the appropriate error code is written
50173 ** Read an entry from the pointer map.
50303 ** way will result in an incompatible file format.
50346 ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of
50403 ** to an overflow page, insert an entry into the pointer-map
50507 ** an error code (usually SQLITE_CORRUPT).
50962 ** If an error occurs, then the value *ppPage is set to is undefined. It
50963 ** may remain unchanged, or it may be set to an invalid value.
51021 /* pPage might not be a btree page; it might be an overflow page
51046 ** then an ephemeral database is created. The ephemeral database might
51051 ** If zFilename is ":memory:" then an in-memory database is created
51058 ** and we are in shared cache mode, then the open will fail with an
51078 /* True if opening an ephemeral, temporary database */
51081 /* Set the variable isMemdb to true for an in-memory database, or
51121 ** If this Btree is a candidate for shared cache, try to find an
51222 /* If the magic name ":memory:" will create an in-memory database, then
51313 ** default value. Except, when opening on an existing shared pager-cache,
51368 ** Make sure pBt->pTmpSpace points to an allocation of
51386 ** Close an open database and invalidate all cursors.
51453 ** an abrupt power failure when synchronous is off, the database
51454 ** could be left in an inconsistent and unrecoverable state.
51787 ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow
51831 ** If pBt points to an empty file then convert that empty file
51895 ** If an initial attempt to acquire the lock fails because of lock contention
52016 /* If the db-size header field is incorrect (as it may be if an old
52097 ** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow
52100 ** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next
52194 ** If pDbPage is an overflow page, then the first 4 bytes may store a
52240 ** Perform a single step of an incremental-vacuum. If successful,
52250 ** it returns SQLITE_DONE or an error, and that nFin is the
52360 ** It performs a single unit of work towards an incremental vacuum.
52364 ** SQLITE_OK is returned. Otherwise an SQLite error code.
52388 ** is commited for an auto-vacuum database.
52551 ** Normally, if an error occurs while the pager layer is attempting to
52552 ** finalize the underlying journal file, this function returns an error and
52557 ** functions return code. So, even if an error occurs in the pager layer,
52665 ** in an error.
52726 ** A statement sub-transaction is implemented as an anonymous savepoint. The
52743 ** an index greater than all savepoints created explicitly using
52794 ** the caller is assumed to have an open write transaction.
52812 ** 4: There must be an active transaction.
52914 ** The cache is initialized to zero, indicating an invalid cache.
53062 ** to return an integer result code for historical reasons.
53073 ** Given the page number of an overflow page in the database (parameter
53078 ** If an error occurs an SQLite error code is returned. Otherwise:
53157 ** SQLITE_OK is returned on success, otherwise an error code.
53199 ** Once an overflow page-list cache has been allocated, it may be
53202 ** mode, the following events may invalidate an overflow page-list cache.
53206 ** * Creating a table (may require moving an overflow page).
53234 /* Trying to read or write past the end of the data is an error */
53382 ** Return SQLITE_OK on success or an error code if anything goes
53399 ** Return SQLITE_OK on success or an error code if anything goes
53431 ** This routine is an optimization. It is common for the entire key
53520 ** if an intkey page appears to be the parent of a non-intkey page, or
53551 ** Page pParent is an internal (non-leaf) tree page. This function
53621 ** structure the flags byte is set to 0x02 or 0x0A, indicating an index
53660 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
53662 ** return an SQLITE_CORRUPT error. */
53811 /* Move the cursor so that it points to an entry near the key
53818 ** If an exact match is not found, then the cursor is always
53820 ** were present. The cursor might point to an entry that comes
53828 ** *pRes<0 The cursor is left pointing at an entry that
53832 ** *pRes==0 The cursor is left pointing at an entry that
53835 ** *pRes>0 The cursor is left pointing at an entry that
53927 ** the maximum number of record bytes stored on an index B-Tree
54021 ** Return TRUE if the cursor is not pointing at an entry of the table.
54029 ** have been deleted? This API will need to change to return an error code
54179 ** an error. *ppPage and *pPgno are undefined in the event of an error.
54180 ** Do not invoke sqlite3PagerUnref() on *ppPage if an error is returned.
54183 ** locate a page close to the page number "nearby". This can be used in an
54509 /* If the database supports auto-vacuum, write an entry in the pointer-map
54628 /* 0 is not a legal page number and page 1 cannot be an
54641 /* There is no reason any cursor should have an outstanding reference
54642 ** to an overflow page belonging to a cell that is being deleted/updated.
54644 ** must not really be an overflow page and the database must be corrupt.
54755 ** overflow page is being allocated, add an entry to the pointer-map
54889 ** nSkip is non-zero, then pCell may not point to an invalid memory location
54920 ** malformed cell from a leaf page to an interior page, if the cell size
54971 /* The cell may contain a pointer to an overflow page. If so, write
55093 /* If this is an auto-vacuum database, update the pointer map
55095 ** cell on the page to an overflow page. If either of these
55099 ** be marked as dirty. Returning an error code will cause a
55234 /* If this is an auto-vacuum database, update the pointer-map entries
55254 ** one or two in an effort to keep pages nearly full but not over full.
55276 ** size of a cell stored within an internal node is always less than 1/4
55557 ** This adjustment is more than an optimization. The packing above might
55735 ** Note that this can never happen in an SQLite data file, as all
55770 ** If this is an auto-vacuum database, the call to copyNodeContent()
55827 ** sibling page j. If the siblings are not leaf pages of an
55851 ** sibling page k. If the siblings are not leaf pages of an
55860 ** an overflow cell, or if the cell was located on a different sibling
55884 ** cause an assert() statement to fail. */
55916 ** page is then overwritten to make it an empty page with the right-child
55926 ** to call releasePage() on *ppChild exactly once. If an error occurs,
55927 ** an error code is returned and *ppChild is set to 0.
56105 ** For an INTKEY table, only the nKey value of the key is used. pKey is
56111 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
56112 ** a positive value if pCur points at an etry that is larger than
56126 int appendBias, /* True if this is likely an append */
56150 ** expecting an index b-tree, then the caller should be inserting blob
56151 ** keys with no associated data. If the cursor was opened expecting an
56156 /* If this is an insert into a table b-tree, invalidate any incrblob
56222 /* If no error has occured and pPage has an overflow cell, call balance()
56234 ** multiple records into an intkey b-tree using a single cursor (as can
56235 ** happen while processing an "INSERT INTO ... SELECT" statement), it
56238 ** entry in the table, and the next row inserted has an integer key
56325 ** by the child-page of the cell that was just deleted from an internal
56352 ** Otherwise, if the entry deleted was on an internal node page, then
56408 /* Creating a new table may probably require moving an existing database
56410 ** out to be an overflow page, delete all overflow page-map caches
56442 ** the new table (assuming an error did not occur). But we were
56588 ** If pnChange is not NULL, then table iTable must be an intkey table. The
56642 ** root page. If an open cursor was using this page a problem would
56767 /* If auto-vacuum is disabled in this build and this is an auto-vacuum
56812 ** Otherwise, if an error is encountered (i.e. an IO error or database
56813 ** corruption) an SQLite error code is returned.
56825 /* Unless an error occurs, the following loop runs one iteration for each
56832 /* If this is a leaf page or the tree is not an int-key tree, then
56876 /* An error has occurred. Return an error code. */
56921 ** reference to the page, add an error message to pCheck->zErrMsg.
56943 ** page iParent, pointer type ptrType. If not, append an error message
56973 ** Check the integrity of the freelist or of an overflow page list.
57275 ** an array of pages numbers were each page number is the root page of
57282 ** allocation errors, an error message held in memory obtained from
57367 ** This is an internal consistency check; an integrity check
57428 ** Return SQLITE_LOCKED if this or any other connection has an open
57497 ** btree as the argument handle holds an exclusive lock on the
57538 ** Argument pCsr must be a cursor opened for writing on an
57567 ** (e) the cursor points at a valid row of an intKey table.
57716 ** a NULL pointer and write an error message to pErrorDb.
57719 ** function. If an error occurs while doing so, return 0 and write an
57765 ** Create an sqlite3_backup process to copy the contents of zSrcDb from
57769 ** If an error occurs, NULL is returned and an error code and error message
57818 /* One (or both) of the named databases did not exist or an OOM
57837 ** Argument rc is an SQLite error code. Return true if this error is
57869 /* Catch the case where the destination is an in-memory database and the
57932 ** Return SQLITE_OK if everything is successful, or an SQLite error
57933 ** code if an error occurs.
58176 ** Release all resources associated with an sqlite3_backup* handle.
58278 ** detects that the database has been modified by an external database
58320 /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set
58334 ** within a single call (unless an error occurs). The assert() statement
58336 ** or an error code.
58370 ** stores a single value in the VDBE. Mem is an opaque structure visible
58376 ** If pMem is an object with a valid string representation, this routine
58493 ** If the given Mem* has a zero-filled tail, turn it into an ordinary
58550 ** user and the later is an internal programming error.
58589 ** Memory cell pMem contains the context of an aggregate function.
58593 ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK
58618 ** invoking an external callback, free it now. Calling this function
58640 ** Release any memory held by the Mem. This may leave the Mem in an
58658 ** there are reports that windows throws an expection
58683 ** a very large positive number to an integer results in a very large
58695 ** at representing the value that *pMem describes as an integer.
58696 ** If pMem is an integer, then the value is exact. If pMem is
58698 ** If pMem is a string or blob, then we make an attempt to convert
58699 ** it into a integer and return that. If pMem represents an
58700 ** an SQL-NULL value, return 0.
58726 ** double. If pMem is already a double or an integer, return its
58760 /* Only mark the value as an integer if
58902 ** Delete any previous value and set the value of pMem to be an
58966 ** Make an shallow copy of pFrom into pTo. Prior contents of
59009 ** pFrom contains an SQL NULL when this routine returns.
59052 /* If z is a NULL pointer, set pMem to contain an SQL NULL. */
59248 ** to read from the disk) then the pMem is left in an inconsistent state.
59304 ** If that is the case, then the result must be aligned on an even byte
59474 ** Change the string value of an sqlite3_value object
59487 ** Free an sqlite3_value object
59525 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
59616 ** If an out-of-memory error occurs while resizing the array, return
59644 ** Use the sqlite3VdbeResolveLabel() function to fix an address and
59691 ** Add an opcode that includes the p4 value as a pointer.
59708 ** Add an OP_ParseSchema opcode. This routine is broken out from
59723 ** Add an opcode that includes the p4 value as an integer.
59731 int p4 /* The P4 operand as an integer */
59739 ** Create a new symbolic label for an instruction that has yet to be
59741 ** label can be used as the P2 value of an operation. Later, when
59858 ** throw an ABORT exception (causing the statement, but not entire transaction
59869 ** Then check that the value of Parse.mayAbort is true if an
59872 ** part of an assert statement in the compiler. Similar to:
59915 ** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by
60239 /* Note: this cast is safe, because the origin data point was an int
60335 ** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as
60363 ** Compute a string that describes the P4 parameter for an opcode.
60491 ** that may be accessed by the VM passed as an argument. In doing so it also
60572 ** Release an array of N Mem elements
60588 /* This block is really an inlined version of sqlite3VdbeMemRelease()
60684 ** commandeer the 9th cell to use as storage for an array of pointers
60741 /* When an OP_Program opcode is encounter (the only opcode that has
60847 ** Print an IOTRACE message showing SQL content.
60967 ** the Vdbe becomes an independent entity and the Parse object can be
61013 ** an array to marshal SQL function arguments in.
61193 ** be called on an SQL statement before sqlite3_step().
61253 int nTrans = 0; /* Number of databases with an active write-transaction */
61267 ** required, as an xSync() callback may add an attached database
61275 ** one database file has an open write transaction, a master journal
61276 ** file is required for an atomic commit.
61318 ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
61387 ** master journal file. If an error occurs at this point close
61429 ** an error occurs here, do not delete the master journal file.
61466 ** may be lying around. Returning an error code won't help matters.
61490 ** This is an internal self-check only - it is not an essential processing
61522 ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned.
61531 ** is that an IO error may have occured, causing an emergency rollback.
61581 ** handle associated with the VM passed as an argument is about to be
61587 ** an error message to it. Then return SQLITE_ERROR.
61611 ** Return an error code. If the commit could not complete because of
61630 ** Then the internal cache might have been left in an inconsistent
61668 ** file as part of an effort to free up cache space (see function
61711 ** or hit an 'OR FAIL' constraint and there are no deferred foreign
61744 ** do so. If this operation returns an error, and the current statement
61762 /* If this was an INSERT, UPDATE or DELETE and no statement transaction
61852 /* If the VM did not run to completion or if it encountered an
61912 ** Clean up and delete a VDBE after execution. Return an integer which is
61975 ** Delete an entire VDBE.
61998 ** was last positioned. Return an error code if an OOM fault or I/O error
62049 ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned
62052 ** In an SQLite index record, the serial type is stored directly before
62137 ** If we are on an architecture with mixed-endian floating
62144 ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems
62152 ** Developers using SQLite on an ARM7 should compile and run their
62351 ** This routine is used to allocate sufficient space for an UnpackedRecord
62362 ** If an OOM error occurs, NULL is returned.
62550 ** pCur points at an index entry created using the OP_MakeRecord opcode.
62552 ** Return SQLITE_OK if everything works, or an error code otherwise.
62592 /* The last field of the index should be an integer - the ROWID.
62593 ** Verify that the last entry really is an integer. */
62692 ** sequences, or changing an authorization function are the types of
62710 ** Return a pointer to an sqlite3_value structure containing the value bound
62711 ** parameter iVar of VM v. Except, if the value is an SQL NULL, return
62768 ** Return TRUE (non-zero) of the statement supplied as an argument needs
62772 ** collating sequences are registered or if an authorizer function is
62783 ** an error and return true if it has been finalized (or is otherwise
62805 ** the sqlite3_compile() routine. The integer returned is an SQLITE_
62837 ** Terminate the current execution of an SQL statement and reset it
63042 /* Force an SQLITE_TOOBIG error. */
63081 ** statement is completely executed or an error occurs.
63098 ** This "automatic-reset" change is not technically an incompatibility,
63099 ** since any application that receives an SQLITE_MISUSE is broken by
63200 /* If this statement was prepared using sqlite3_prepare_v2(), and an
63241 /* This case occurs after failing to recompile an sql statement.
63289 ** The following is the implementation of an SQL function that always
63290 ** fails with an error message stating that the function is used in the
63449 ** value SQL NULL. Even though the Mem structure contains an element
63452 ** instead of an 8-byte one. This all works fine, except that when
63454 ** that a Mem structure is located on an 8-byte boundary. To prevent
63478 ** This function is called after invoking an sqlite3_value_XXX function on a
63479 ** column value (i.e. a value returned by evaluating an SQL expression in the
63497 /* If malloc() failed during an encoding conversion within an
63595 ** If the result is not a simple column reference (if it is an expression
63672 ** NULL is returned if the result column is an expression or constant or
63673 ** anything else which is not an unabiguous reference to a database column.
63688 ** NULL is returned if the result column is an expression or constant or
63689 ** anything else which is not an unabiguous reference to a database column.
63704 ** NULL is returned if the result column is an expression or constant or
63705 ** anything else which is not an unabiguous reference to a database column.
63811 ** Bind a blob value to an SQL statement variable.
63990 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
64354 ** In the external interface, an "sqlite3_stmt*" is an opaque pointer
64360 ** a linear sequence of operations. Each operation has an opcode
64362 ** is a null-terminated string. Operand P5 is an unsigned character.
64367 ** either an integer, a null-terminated string, a floating point
64408 ** field of the sqlite3 structure is set in order to simulate an interrupt.
64411 ** in an ordinary build.
64480 ** This routine converts an ephemeral string into a dynamically allocated
64482 ** converts an MEM_Ephem string into an MEM_Dyn string.
64608 ** Try to convert pRec to an integer representation or a
64609 ** floating-point representation if an integer representation
64612 ** an integer representation is more space efficient on disk.
64626 /* Only attempt the conversion to TEXT if there is an integer or real
64907 ** This function is only called from within an assert() expression. It
64926 ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
64950 ** If an attempt is made to open a locked database, then this routine
64954 ** If an error occurs, an error message is written to memory obtained
64978 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65094 } an;
65208 int res; /* Result of an sqlite3BtreeLast() */
65471 /* Check to see if we need to simulate an interrupt. This only happens
65506 ** an undefined integer. Opcodes will either fill in the integer
65566 ** opcode and the opcodes.c file is filled with an array of strings where
65672 ** If P4 is not null then it is an error message string.
65674 ** There is an implied "Halt 0 0 0" instruction inserted at the very end of
65691 ** an IGNORE exception. In this case jump to the address specified
65761 ** into an OP_String before it is executed for the first time.
65871 ** left holding a NULL. It is an error for register ranges
65956 ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
66003 ** and have an assigned type. The results are de-ephemeralized as
66302 ** user function may have called an sqlite3_result_XXX() function
66310 /* If the function returned an error, throw an exception */
66419 ** The result is always an integer.
66421 ** To force any register to be an integer, just add 0.
66433 ** Force the value in register P1 to be an integer. If the value
66434 ** in P1 is not an integer and cannot be converted into an integer
66436 ** raise an SQLITE_MISMATCH exception.
66457 ** If register P1 holds an integer convert it to a real value.
66522 ** Force the value in register P1 to be numeric (either an
66524 ** If the value is text or blob, try to convert it to an using the
66539 ** Force the value in register P1 to be an integer. If
66541 ** If the value is text or blob, try to convert it to an integer using the
66558 ** If The value is currently an integer, convert it.
66559 ** If the value is text or blob, try to convert it to an integer using the
66583 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
66893 ** Interpret the content of register P1 as an integer. Store the
67003 #if 0 /* local variables moved into u.an */
67027 #endif /* local variables moved into u.an */
67030 u.an.p1 = pOp->p1;
67031 u.an.p2 = pOp->p2;
67032 u.an.pC = 0;
67033 memset(&u.an.sMem, 0, sizeof(u.an.sMem));
67034 assert( u.an.p1<p->nCursor );
67036 u.an.pDest = &aMem[pOp->p3];
67037 memAboutToChange(p, u.an.pDest);
67038 u.an.zRec = 0;
67040 /* This block sets the variable u.an.payloadSize to be the total number of
67043 ** u.an.zRec is set to be the complete text of the record if it is available.
67046 ** might be available in the u.an.pC->aRow cache. Or it might not be.
67047 ** If the data is unavailable, u.an.zRec is set to NULL.
67052 u.an.pC = p->apCsr[u.an.p1];
67053 assert( u.an.pC!=0 );
67055 assert( u.an.pC->pVtabCursor==0 );
67057 u.an.pCrsr = u.an.pC->pCursor;
67058 if( u.an.pCrsr!=0 ){
67060 rc = sqlite3VdbeCursorMoveto(u.an.pC);
67062 if( u.an.pC->nullRow ){
67063 u.an.payloadSize = 0;
67064 }else if( u.an.pC->cacheStatus==p->cacheCtr ){
67065 u.an.payloadSize = u.an.pC->payloadSize;
67066 u.an.zRec = (char*)u.an.pC->aRow;
67067 }else if( u.an.pC->isIndex ){
67068 assert( sqlite3BtreeCursorIsValid(u.an.pCrsr) );
67069 VVA_ONLY(rc =) sqlite3BtreeKeySize(u.an.pCrsr, &u.an.payloadSize64);
67072 ** payload size, so it is impossible for u.an.payloadSize64 to be
67074 assert( (u.an.payloadSize64 & SQLITE_MAX_U32)==(u64)u.an.payloadSize64 );
67075 u.an.payloadSize = (u32)u.an.payloadSize64;
67077 assert( sqlite3BtreeCursorIsValid(u.an.pCrsr) );
67078 VVA_ONLY(rc =) sqlite3BtreeDataSize(u.an.pCrsr, &u.an.payloadSize);
67081 }else if( ALWAYS(u.an.pC->pseudoTableReg>0) ){
67082 u.an.pReg = &aMem[u.an.pC->pseudoTableReg];
67083 assert( u.an.pReg->flags & MEM_Blob );
67084 assert( memIsValid(u.an.pReg) );
67085 u.an.payloadSize = u.an.pReg->n;
67086 u.an.zRec = u.an.pReg->z;
67087 u.an.pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr;
67088 assert( u.an.payloadSize==0 || u.an.zRec!=0 );
67091 u.an.payloadSize = 0;
67094 /* If u.an.payloadSize is 0, then just store a NULL. This can happen because of
67096 if( u.an.payloadSize==0 ){
67097 MemSetTypeFlag(u.an.pDest, MEM_Null);
67101 if( u.an.payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
67105 u.an.nField = u.an.pC->nField;
67106 assert( u.an.p2<u.an.nField );
67111 u.an.aType = u.an.pC->aType;
67112 if( u.an.pC->cacheStatus==p->cacheCtr ){
67113 u.an.aOffset = u.an.pC->aOffset;
67115 assert(u.an.aType);
67116 u.an.avail = 0;
67117 u.an.pC->aOffset = u.an.aOffset = &u.an.aType[u.an.nField];
67118 u.an.pC->payloadSize = u.an.payloadSize;
67119 u.an.pC->cacheStatus = p->cacheCtr;
67122 if( u.an.zRec ){
67123 u.an.zData = u.an.zRec;
67125 if( u.an.pC->isIndex ){
67126 u.an.zData = (char*)sqlite3BtreeKeyFetch(u.an.pCrsr, &u.an.avail);
67128 u.an.zData = (char*)sqlite3BtreeDataFetch(u.an.pCrsr, &u.an.avail);
67131 ** save the payload in the u.an.pC->aRow cache. That will save us from
67135 assert( u.an.avail>=0 );
67136 if( u.an.payloadSize <= (u32)u.an.avail ){
67137 u.an.zRec = u.an.zData;
67138 u.an.pC->aRow = (u8*)u.an.zData;
67140 u.an.pC->aRow = 0;
67145 ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
67146 u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
67148 /* Make sure a corrupt database has not given us an oversize header.
67149 ** Do this now to avoid an oversize memory allocation.
67157 if( u.an.offset > 98307 ){
67162 /* Compute in u.an.len the number of bytes of data we need to read in order
67163 ** to get u.an.nField type values. u.an.offset is an upper bound on this. But
67164 ** u.an.nField might be significantly less than the true number of columns
67165 ** in the table, and in that case, 5*u.an.nField+3 might be smaller than u.an.offset.
67166 ** We want to minimize u.an.len in order to limit the size of the memory
67167 ** allocation, especially if a corrupt database file has caused u.an.offset
67170 ** On systems that cannot tolerate large memory allocations, u.an.nField*5+3
67171 ** will likely be much smaller since u.an.nField will likely be less than
67175 u.an.len = u.an.nField*5 + 3;
67176 if( u.an.len > (int)u.an.offset ) u.an.len = (int)u.an.offset;
67184 if( !u.an.zRec && u.an.avail<u.an.len ){
67185 u.an.sMem.flags = 0;
67186 u.an.sMem.db = 0;
67187 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, 0, u.an.len, u.an.pC->isIndex, &u.an.sMem);
67191 u.an.zData = u.an.sMem.z;
67193 u.an.zEndHdr = (u8 *)&u.an.zData[u.an.len];
67194 u.an.zIdx = (u8 *)&u.an.zData[u.an.szHdr];
67196 /* Scan the header and use it to fill in the u.an.aType[] and u.an.aOffset[]
67197 ** arrays. u.an.aType[u.an.i] will contain the type integer for the u.an.i-th
67198 ** column and u.an.aOffset[u.an.i] will contain the u.an.offset from the beginning
67199 ** of the record to the start of the data for the u.an.i-th column
67201 for(u.an.i=0; u.an.i<u.an.nField; u.an.i++){
67202 if( u.an.zIdx<u.an.zEndHdr ){
67203 u.an.aOffset[u.an.i] = u.an.offset;
67204 if( u.an.zIdx[0]<0x80 ){
67205 u.an.t = u.an.zIdx[0];
67206 u.an.zIdx++;
67208 u.an.zIdx += sqlite3GetVarint32(u.an.zIdx, &u.an.t);
67210 u.an.aType[u.an.i] = u.an.t;
67211 u.an.szField = sqlite3VdbeSerialTypeLen(u.an.t);
67212 u.an.offset += u.an.szField;
67213 if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
67214 u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
67218 /* If u.an.i is less that u.an.nField, then there are less fields in this
67220 ** table. Set the u.an.offset for any extra columns not present in
67224 u.an.aOffset[u.an.i] = 0;
67227 sqlite3VdbeMemRelease(&u.an.sMem);
67228 u.an.sMem.flags = MEM_Null;
67236 if( (u.an.zIdx > u.an.zEndHdr) || (u.an.offset > u.an.payloadSize)
67237 || (u.an.zIdx==u.an.zEndHdr && u.an.offset!=u.an.payloadSize) ){
67243 /* Get the column information. If u.an.aOffset[u.an.p2] is non-zero, then
67244 ** deserialize the value from the record. If u.an.aOffset[u.an.p2] is zero,
67249 if( u.an.aOffset[u.an.p2] ){
67251 if( u.an.zRec ){
67252 VdbeMemRelease(u.an.pDest);
67253 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67255 u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67256 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67257 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
67261 u.an.zData = u.an.sMem.z;
67262 sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest);
67264 u.an.pDest->enc = encoding;
67267 sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
67269 MemSetTypeFlag(u.an.pDest, MEM_Null);
67275 ** dynamically allocated space over to the u.an.pDest structure.
67278 if( u.an.sMem.zMalloc ){
67279 assert( u.an.sMem.z==u.an.sMem.zMalloc );
67280 assert( !(u.an.pDest->flags & MEM_Dyn) );
67281 assert( !(u.an.pDest->flags & (MEM_Blob|MEM_Str)) || u.an.pDest->z==u.an.sMem.z );
67282 u.an.pDest->flags &= ~(MEM_Ephem|MEM_Static);
67283 u.an.pDest->flags |= MEM_Term;
67284 u.an.pDest->z = u.an.sMem.z;
67285 u.an.pDest->zMalloc = u.an.sMem.zMalloc;
67288 rc = sqlite3VdbeMemMakeWriteable(u.an.pDest);
67291 UPDATE_MAX_BLOBSIZE(u.an.pDest);
67292 REGISTER_TRACE(pOp->p3, u.an.pDest);
67328 ** in an index. The OP_Column opcode can decode the record later.
67460 ** Store the number of entries (an integer value) in the table or index
67484 ** on the value of P1. To open a new savepoint, P1==0. To release (commit) an
67485 ** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.
67556 /* Find the named savepoint. If there is no such savepoint, then an
67557 ** an error is returned to the user. */
67674 ** still running, and a transaction is active, return an error indicating
67684 ** return an error indicating that the other VMs must complete first.
67728 ** transaction might also be rolled back if an error is encountered.
67740 ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained
67745 ** throw an ABORT exception), a statement transaction may also be opened.
67749 ** VDBE to be rolled back after an error without having to roll back the
67808 ** must be started or there must be an open cursor) before
67832 ** Write the content of register P3 (interpreted as an integer)
67885 ** Either a transaction needs to have been started or an OP_Open needs
67913 ** If virtual-tables are in use, this is not just an optimization.
67938 ** database. Give the new cursor an identifier of P1. The P1
67940 ** It is an error for P1 to be negative.
67945 ** There will be a read lock on the database whenever there is an
67951 ** to get a read lock but fails, the script terminates with an
67954 ** The P4 value may be either an integer (P4_INT32) or a pointer to
67957 ** sequence of the index being opened. Otherwise, if P4 is an integer
67968 ** The P4 value may be either an integer (P4_INT32) or a pointer to
67971 ** sequence of the index being opened. Otherwise, if P4 is an integer
68117 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
68145 ** tables using an external merge-sort algorithm.
68169 ** register P2. In other words, cursor P1 becomes an alias for the
68209 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68211 ** to an SQL index, then P3 is the first in an array of P4 registers
68212 ** that are used as an unpacked index key.
68222 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68224 ** to an SQL index, then P3 is the first in an array of P4 registers
68225 ** that are used as an unpacked index key.
68235 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68237 ** to an SQL index, then P3 is the first in an array of P4 registers
68238 ** that are used as an unpacked index key.
68248 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68250 ** to an SQL index, then P3 is the first in an array of P4 registers
68251 ** that are used as an unpacked index key.
68286 ** blob, or NULL. But it needs to be an integer before we can do
68293 /* If the P3 value could not be converted into an integer without
68307 /* The P3 value is too large in magnitude to be expressed as an
68415 ** P1 is an open table cursor and P2 is a rowid integer. Arrange
68445 ** P4>0 then register P3 is the first of P4 registers that form an unpacked
68448 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
68455 ** P4>0 then register P3 is the first of P4 registers that form an unpacked
68458 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
68460 ** does contain an entry whose prefix matches the P3/P4 record then control
68531 ** Cursor P1 is open on an index b-tree - that is to say, a btree which
68536 ** The P3 register contains an integer record number. Call this record
68538 ** that make up an unpacked index key that can be used with cursor P1.
68546 ** Otherwise, this instruction checks if cursor P1 contains an entry
68620 ** Use the content of register P3 as an integer key. If a record
68626 ** operation assumes the key is an integer and that P1 is a table whereas
68628 ** P1 is an index.
68663 /* This happens when an attempt to open a read cursor on the
68698 ** an SQLITE_FULL error is generated. The P3 register is updated with the '
68706 int res; /* Result of an sqlite3BtreeLast() */
68785 assert( (u.bg.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
68805 ** an AUTOINCREMENT table. */
68841 ** Write an entry into the table of cursor P1. A new entry is
68842 ** created if it doesn't already exist or the data for an existing
68857 ** has already positioned the cursor correctly. This is an optimization
68860 ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
68862 ** is part of an INSERT operation. The difference is only important to
68960 ** a record from within an Next loop.
68994 /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or
69162 ** Store in register P2 an integer which is the key of the table entry that
69165 ** P1 can be either an ordinary table or a virtual table. There used to
69269 ** it increments an undocumented global variable used for testing.
69406 ** Register P2 holds an SQL index key made using the
69411 ** insert is likely to be an append.
69458 ** an unpacked index key. This opcode removes that entry from the
69495 ** Write into register P2 an integer which is the last entry in the record at
69532 ** The P4 register values beginning with P3 form an unpacked index
69539 ** If P5 is non-zero then the key value is increased by an epsilon
69546 ** The P4 register values beginning with P3 form an unpacked index
69553 ** If P5 is non-zero then the key value is increased by an epsilon prior
69599 ** Delete an entire database table or index whose root page in the database
69667 ** If the P3 value is non-zero, then the table referred to must be an
69668 ** intkey table (an SQL table, not an index). In this case the row change
69699 ** auxiliary database file if P1==1 or in an attached database if
69703 ** The difference between a table and an index is this: A table must
69705 ** has an arbitrary key but no data.
69712 ** auxiliary database file if P1==1 or in an attached database if
69828 ** the index named P4 in database P1. This is called after an index
69853 ** Do an analysis of the currently open database. Store in
69854 ** register P1 the text of an error message describing any problems.
69919 ** An assertion fails if P2 is not an integer.
69993 ** delete it now and initialize P1 with an empty rowset
70025 ** cell in an array of values used as arguments to the sub-program. P2
70026 ** contains the address to jump to if the sub-program throws an IGNORE
70212 ** This instruction throws an error if the memory cell is not initially
70213 ** an integer.
70242 ** not contain an integer. An assertion fault will result if you try.
70258 ** not contain an integer. An assertion fault will result if you try.
70271 ** The register P1 must contain an integer. Add literal P3 to the
70275 ** not contain an integer. An assertion fault will result if you try.
70289 ** Execute the step function for an aggregate. The
70354 ** Execute the finalizer function for an aggregate. P1 is
70392 ** completes into mem[P3+2]. However on an error, mem[P3+1] and
70495 ** as an intermediate */
70565 ** fails with an error code of SQLITE_SCHEMA if it is ever executed
70593 ** used to generate an error message if the lock cannot be obtained.
70615 ** P4 may be a pointer to an sqlite3_vtab structure. If so, call the
70662 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70702 ** P1 is a cursor opened using VOpen. P2 is an address to jump to if
70819 ** do this regardless of whether or not an error occurred to ensure any
70860 ** underlying implementation to return an error if one occurs during
70861 ** xNext(). Instead, if an error occurs, true is returned (indicating that
70884 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70916 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70922 ** The xUpdate method will do a DELETE or an INSERT or both.
71113 ** an error of some kind.
71215 ** If an error occurs, or if the specified row does not exist or does not
71217 ** blob handle was opened, then an error code is returned and *pzErr may
71218 ** be set to point to a buffer containing an error message. It is the
71222 ** If an error does occur, then the b-tree cursor is closed. All subsequent
71299 ** After seeking the cursor, the vdbe executes an OP_ResultRow.
71313 /* One of the following two instructions is replaced by an OP_Noop. */
71394 /* Check that the column is not part of an FK child key definition. It
71466 ** always return an SQL NULL. This is useful because it means
71603 ** Move an existing blob handle to point to a different row of the same
71606 ** If an error occurs, or if the specified row does not exist or does not
71607 ** contain a blob or text value, then an error code is returned and the
71681 ** The aIter[] array contains an iterator for each of the PMAs being merged.
71754 ** The following type is an iterator for a PMA. It caches the current key in
71795 ** no error occurs, or an SQLite error code if one does.
71813 /* This is an EOF condition */
71847 ** SQLITE_OK if successful, or an SQLite error code if some error occurs.
71871 ** successful, or an SQLite error code if some error occurs.
71877 ** set to the integer value read. If an error occurs, the final values of
71936 ** used by the comparison. If an error occurs, return an SQLite error code.
71946 ** has been allocated and contains an unpacked record that is used as key2.
72094 ** Otherwise, set *ppFile to 0 and return an SQLite error code.
72141 ** if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if an error
72180 ** SQLITE_OK if successful, or an SQLite error code otherwise.
72230 /* This assert verifies that unless an error has occurred, the size of
72375 ** initialize an iterator for each of them and break out of the loop.
72507 ** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).
72547 ** the caller specifies a buffer size for an in-memory buffer to
72560 ** as an open file handle for journal files.
72781 ** This file contains code use to implement an in-memory rollback journal.
72826 ** is an instance of this class.
72961 ** Syncing an in-memory journal is a no-op. And, in fact, this routine
73014 ** Return true if the file-handle passed as an argument is
73015 ** an in-memory journal
73042 ** an SQL statement.
73049 ** Walk an expression tree. Invoke the callback once for each node
73088 ** an abort request is seen.
73147 ** there is an abort request.
73149 ** If the Walker does not have an xSelectCallback() then this routine
73188 ** Turn the pExpr expression into an alias for the iCol-th column of the
73192 ** makes an exact copy. But for any other kind of expression, this
73218 Expr *pExpr, /* Transform this into an alias to the result set */
73309 ** If the name cannot be resolved unambiguously, leave an error message
73461 ** might refer to an result-set alias. This happens, for example, when
73519 ** more matches. Either way, we have an error.
73577 ** Allocate and return a pointer to an expression to load the column iCol
73689 int is_agg = 0; /* True if is an aggregate function */
73784 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
73787 ** this routine return an integer between 1 and N where N is the number of
73816 ** pE is a pointer to an expression which is a single term in the
73821 ** ORDER BY term is not an integer index into the result set. That
73826 ** as an indication to the caller that it should sort by the i-th column.
73831 ** If there is no match, return 0. Return -1 if an error occurs.
73863 /* Try to match the ORDER BY expression against an expression
73864 ** in the result set. Return an 1-based index of the matching
73878 ** Generate an ORDER BY or GROUP BY term out-of-range error.
73896 ** ORDER BY terms that are already an integer between 1 and N are
73898 ** 1 through N generate an error. ORDER BY terms that are expressions
73993 ** If any errors are detected, add an error message to pParse and
74029 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
74033 ** This routine resolves each term of the clause into an expression.
74034 ** If the order-by term is an integer I between 1 and N (where N is the
74037 ** the order-by term is an identify that corresponds to the AS-name of
74043 ** an appropriate error message might be left in pParse. (OOM errors
74065 /* If an AS-name match is found, mark this ORDER BY column as being
74073 /* The ORDER BY term is an integer constant. Again, set the column
74084 /* Otherwise, treat the ORDER BY term as an ordinary expression */
74119 ** an expression, sqlite3ResolveExprNames() will be called without a
74139 ** are not allowed to refer to any names, so pass an empty NameContext.
74278 ** This routine walks an expression tree and resolves references to
74287 ** the symbolic name assigned to an ATTACH-ed database.
74304 ** size of an AS clause in the result-set of a SELECT. The Z expression
74317 ** If the function is an aggregate function, then the pNC->hasAgg is
74319 ** If an expression contains aggregate functions then the EP_Agg
74411 ** If pExpr is a column, a reference to a column via an 'AS' alias,
74417 ** have an affinity:
74450 ** Set the explicit collating sequence for an expression to the
74518 ** pExpr is an operand of a comparison operator. aff2 is the
74568 ** idx_affinity is the affinity of an indexed column. Return true
74655 ** expression depth allowed. If it is not, leave an error message in
74708 ** Set the Expr.nHeight variable in the structure passed as an
74729 ** leave an error in pParse.
74738 ** by the select statement passed as an argument.
74868 ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed,
74887 ** Join two expressions using an AND operator. If either expression is
74922 ** Assign a variable number to an expression that encodes a wildcard
74930 ** the SQL statement comes from an external source.
74954 /* Wildcard of the form "?nnn". Convert "nnn" to an integer and
75006 ** Recursively delete an expression tree.
75042 ** to store a copy of an expression or expression tree. They differ in
75372 ** Add a new element to the end of an expression list. If pList is
75420 ** pList might be NULL following an OOM error. But pName should never be
75445 ** pList might be NULL following an OOM error. But pSpan should never be
75468 ** leave an error message in pParse.
75484 ** Delete an entire expression list.
75502 ** to an integer. These routines are checking an expression to see
75560 ** Walk an expression tree. Return 1 if the expression is constant
75572 ** Walk an expression tree. Return 1 if the expression is constant
75575 ** an ON or USING clause.
75582 ** Walk an expression tree. Return 1 if the expression is constant
75597 ** in *pValue. If the expression is not an integer or if it is too big
75603 /* If an expression is an integer literal that fits in a signed 32-bit
75636 ** This routine is used as an optimization, to skip OP_IsNull opcodes
75641 ** will likely result in an incorrect answer. So when in doubt, return
75661 ** Generate an OP_IsNull instruction that tests register iReg and jumps
75772 ** Code an OP_Once instruction and allocate space for its flag. Return the
75801 ** through the set members, skipping any duplicates. In this case an
75803 ** to be unique - either because it is an INTEGER PRIMARY KEY or it
75807 ** for fast set membership tests. In this case an epheremal table must
75808 ** be used unless <column> is an INTEGER PRIMARY KEY or an index can
75812 ** needs to know whether or not the structure contains an SQL NULL
75844 /* Check to see if an existing table or index can be used to
75864 /* Code an OP_VerifyCookie and OP_TableLock for <table>. */
75886 /* The collation sequence used by the comparison. If an index is to
75925 /* Could not found an existing table or index to use as the RHS b-tree.
75926 ** We will have to generate an ephemeral table to do the job.
75964 ** to some integer key column of a table B-Tree. In this case, use an
75968 ** If rMayHaveNull is non-zero, that means that the operation is an IN
75981 ** result. For IN operators or if an error occurs, the return value is 0.
76000 ** * The right-hand side is an expression list containing variables
76033 /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
76077 ** For each expression, build an index key from the evaluation and
76140 ** of the memory cell in iColumn. If this is an EXISTS, write
76141 ** an integer 0 (not exists) or 1 (exists) into a memory cell
76187 ** Generate code for an IN expression.
76193 ** is an array of zero or more values. The expression is true if the LHS is
76255 /* In this case, the RHS is an index b-tree.
76320 ** Duplicate an 8-byte value
76332 ** Generate an instruction that will put the floating point
76354 ** Generate an instruction that will put the integer describe by
76439 /* Find an empty slot and replace it */
76561 ** There must be an open cursor to pTab in iTable when this routine
76604 ** Record the fact that an affinity change has occurred on iCount
77104 ** The expression is implemented using an OP_Param opcode. The p1
77105 ** parameter is set to 0 for an old.rowid reference, or to (i+1)
77138 /* If the column has REAL affinity, it may currently be stored as an
77270 ** Generate code to evaluate an expression and store the results
77347 ** Generate a human-readable explanation of an expression tree.
77578 ** Generate a human-readable explanation of an expression list.
77604 ** Return TRUE if pExpr is an constant expression that is appropriate
77615 ** We could factor them out, but then we would end up adding an
77645 ** up generating an OP_SCopy to move the value to the destination
78101 ** this routine is used, it does not hurt to get an extra 2 - that
78103 ** an incorrect 0 or 1 could lead to a malfunction.
78221 ** Make an entry for the column in pAggInfo->aCol[] if there
78222 ** is not an entry there already.
78260 /* There is now an entry for pExpr in pAggInfo->aCol[] (either
78351 ** Call sqlite3ExprAnalyzeAggregates() for every expression in an
78354 ** If an error is found, the analysis is cut short.
78493 /* Ran out of input before finding an opening bracket. Return NULL. */
78518 ** This C function implements an SQL user function that is used by SQL code
78760 ** pTab->zName if this function is being called to code part of an
78807 ** If the table is a system table, this function leaves an error message
78840 VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
78859 ** in database iDb. If so, this is an error.
79047 ** This function is called after an "ALTER TABLE ... ADD" statement
79088 ** for an SQL NULL default below.
79165 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
79201 /* Make sure this is not an attempt to ALTER a view. */
79215 ** the name by adding an "sqlite_altertab_" prefix. By adding this
79216 ** prefix, we insure that the name will not collide with an existing
79323 ** about the distribution of keys within an index. The index is identified by
79328 ** The sqlite_stat2 entries for an index that have sampleno between 0 and 9
79346 ** The sqlite_stat3 is an enhancement to sqlite_stat2. A new name is
79370 ** There can be an arbitrary number of sqlite_stat3 entries per index.
79473 ** share an instance of the following structure to hold their state
79685 ** Generate code to do an analysis of all indices associated with
79811 ** initialized to contain an SQL NULL.
79975 ** Generate code that will do an analysis of an entire database
79998 ** Generate code that will do an analysis of a single table in
80023 ** when it recognizes an ANALYZE command.
80042 /* Read the database schema. If an error occurs, leave an error message
80325 ** If an OOM error occurs, this function always sets db->mallocFailed.
80404 ** Resolve an expression that was part of an ATTACH or DETACH statement. This
80439 ** An SQL user-function registered to do the work of an ATTACH statement. The
80440 ** three arguments to the function come directly from an attach statement:
80446 ** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the
80620 /* Return an error if we get here */
80629 ** An SQL user-function registered to do the work of an DETACH statement. The
80744 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
80780 ** Called by the parser to compile an ATTACH statement.
80834 ** These routines are used to make sure that an index, trigger, or
80838 ** to an object in a different database, an error message is added to
80959 ** API. This facility is an optional feature of the library. Embedded
81008 ** will return with an error. SQLITE_IGNORE means that the SQL statement
81029 ** Write an error message into pParse->zErrMsg that explains that the
81030 ** user-supplied authorization function returned an illegal value.
81039 ** table zTab in database zDb. This function assumes that an authorization
81043 ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
81044 ** is treated as SQLITE_DENY. In this case an error is left in pParse.
81077 ** then generate an error.
81131 ** Do an authorization check using the code and arguments given. Return
81168 ** Push an authorization context. After this routine is called, the
81184 ** Pop an authorization context that was previously pushed
81291 ** Code an OP_TableLock instruction for each table locked by the
81319 ** Note that if an error occurred, it might be the case that
81484 ** database containing the table. Return NULL if not found. Also leave an
81488 ** routine leaves an error message in pParse->zErrMsg where
81499 /* Read the database schema. If an error occurs, leave an error message
81549 ** Reclaim the memory used by an index
81804 ** of a database ("main", "temp" or the name of an attached db). This
81825 ** "temp" or the name of an attached db). This routine returns the
81994 /* Make sure the new table name does not collide with an existing
81995 ** index or table name in the same database. Issue an error message if
81997 ** to an sqlite3_declare_vtab() call. In that case only the column names
82017 sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
82113 /* If an error occurs, we jump here */
82282 ** Default value expressions must be constant. Raise an exception if this
82319 ** a primary key (and this is the second primary key) then create an
82328 ** If the key is not an INTEGER PRIMARY KEY, then create a unique
82375 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
82432 ** then an index may have been created on this column before the
82457 ** another error occurs, NULL is returned and an error message written into
82462 ** and generates an error message.
82527 ** The first parameter is a pointer to an output buffer. The second
82528 ** parameter is a pointer to an integer that contains the offset at
82535 ** characters, does not begin with a digit and is not an SQL keyword,
82802 /* Check to see if we need to create an sqlite_sequence table for
82934 ** of errors. If an error is seen leave an error message in pParse->zErrMsg.
83095 ** erasing iTable (this can happen with an auto-vacuum database).
83103 /* OP_Destroy stores an in integer r1. If this integer
83123 ** is also added (this can happen with an auto-vacuum database).
83138 ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the
83506 ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED
83525 ** content of an index in response to a REINDEX command.
83643 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
83645 ** be NULL for a primary key or an index that is created to satisfy a
83676 Token nullId; /* Fake token for an empty ID list */
83809 /* Check for authorization to create an index.
83845 /* Either pColl!=0 or there was an OOM failure. But if an OOM
83897 ** load the column indices into the Index structure. Report an error
83903 ** same column more than once cannot be an error because that would
83925 ** must exist or else there must have been an OOM error. But if there
83926 ** was an OOM error, we would never reach this point. */
83952 /* This routine has been called to create an automatic index as a
83960 ** Either way, check to see if the table already has such an index. If
83995 ** ON CONFLICT clauses this is an error. Otherwise, use the
84065 /* A named index with an explicit CREATE INDEX statement */
84076 /* Add an entry in sqlite_master for this index
84088 /* Fill the index with data and reparse the schema. Code an OP_Expire
84100 /* When adding an index to the list of indices for a table, make
84140 ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the
84142 ** first column of the index. aiRowEst[2] is an estimate of the number
84171 ** This routine will drop an existing named index. This routine
84239 ** pArray is a pointer to an array of objects. Each object in the
84306 ** Delete an IdList.
84402 ** A SrcList is returned, or NULL if there is an OOM error. The returned
84404 ** a new one. If an OOM error does occurs, then the prior value of pList
84407 ** If pDatabase is not null, it means that the table has an optional
84483 ** Delete an entire SrcList including all its substructure.
84559 ** Add an INDEXED BY or NOT INDEXED clause to the most recently added
84581 ** Shifts all join operators from left to right for an entire FROM
84665 ** release or rollback an SQL savepoint.
84725 ** The first time this routine is called, we code an OP_Goto that
84781 ** Generate VDBE code that prepares for doing an operation that
84804 ** If an abort occurs after some of these writes have completed, then it will
84824 ** particular, it prevents us from writing an effective
84834 ** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT
84931 /* Read the database schema. If an error occurs, leave an error message
84981 ** pointer. If an error occurs (out of memory or missing collation
85128 ** an equivalent collating sequence that uses a text encoding different
85149 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
85153 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
85209 ** if necessary and generates an error message if the collating sequence
85392 /* If the createFlag parameter is true and the search did not reveal an
85491 ** the name of a single table, as one might find in an INSERT, DELETE,
85493 ** return a pointer. Set an error message and return NULL if the table
85520 ** writable, generate an error message and return 1. If it is
85532 ** In either case leave an error message in pParse and return non-zero.
85556 ** Evaluate a view and store its result in an ephemeral table. The
85557 ** pWhere argument is an optional WHERE clause that restricts the
85595 ** Generate an expression tree to implement the WHERE, ORDER BY,
85618 /* Check that there isn't an ORDER BY without a LIMIT clause.
85726 ** put in an SrcList structure because some of the subroutines we
85728 ** an SrcList* parameter instead of just a Table* parameter.
85857 ** because deleting an item can change the scan order. */
86075 ** Generate code that will assemble an index key and put it in register
86076 ** regOut. The key with be for index pIdx which is an index on pTab.
86265 ** abs(X) throws an integer overflow error since there is no
86431 ** raise an SQLITE_TOOBIG exception and return NULL.
86837 ** Otherwise, return an error.
86885 /* IMP: R-48699-48617 This function is an SQL wrapper around the
86901 /* IMP: R-24470-31136 This function is an SQL wrapper around the
86923 ** The result is an integer that identifies if the compiler option
86975 ** EXPERIMENTAL - This is not an official function. The interface may
87370 ** SUM might return an integer if it never encounters a floating point
87371 ** value. TOTAL never fails, but SUM might through an exception if
87372 ** it overflows an integer.
87605 ** pExpr points to an expression which implements a function. If
87765 ** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT
87775 ** time a statement is executed that removes an existing violation from
87823 ** If a delete caused by OR REPLACE violates an FK constraint, an exception
87831 ** and the statement transaction is rolled back. An exception is an INSERT
87833 ** instead of using a counter, an exception is thrown immediately if the
87835 ** an INSERT does not open a statement transaction.
87844 ** Before coding an UPDATE or DELETE row operation, the code-generator
87850 ** coding an INSERT operation. The functions used by the UPDATE/DELETE
87862 ** sqlite3FkDelete() - Delete an FKey structure.
87888 ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY
87894 ** Otherwise, it is set to point to an allocated array of size N, where
87919 ** into pParse. If an OOM error occurs, non-zero is returned and the
87950 ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly
87985 ** map to an explicit list of columns in table pParent. Check if this
88031 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
88093 /* Invoke MustBeInt to coerce the child key value to an integer (i.e.
88102 ** to increment the constraint-counter (i.e. this is an INSERT operation),
88128 ** to increment the constraint-counter (i.e. this is an INSERT operation),
88163 /* Special case: If this is an INSERT statement that will insert exactly
88186 ** code for an SQL UPDATE operation, this function may be called twice -
88234 /* Create an Expr object representing an SQL expression like:
88301 ** clause. If the constraint is not deferred, throw an exception for
88328 ** Calling this function with table "t1" as an argument returns a pointer
88402 ** violations, halt the VDBE and return an error at this point, before
88422 ** first register in an array of (pTab->nCol+1) registers containing the
88427 ** For an INSERT operation, regOld is passed zero and regNew is passed the
88428 ** first register of an array of (pTab->nCol+1) registers containing the new
88431 ** For an UPDATE operation, this function is called twice. Once before
88470 ** schema items cannot be located, set an error in pParse and return
88484 ** If the parent table of an FK constraint on the current table is
88531 ** If the parent does not exist, removing the child row resolves an
88552 /* Inserting a single row into a parent table cannot cause an immediate
88579 ** on the parent table of this FK, then throw an exception
88624 ** parameter aChange is passed a NULL value. For an UPDATE, aChange points
88625 ** to an array of size N, where N is the number of columns in table pTab.
88648 /* This is an UPDATE. Foreign key processing is only required if the
88682 ** This function is called when an UPDATE or DELETE operation is being
88684 ** If the current operation is an UPDATE, then the pChanges parameter is
88903 ** refer to table pTab. If there is an action associated with the FK
89134 ** Locate or create an AutoincInfo structure associated with table pTab
89186 AutoincInfo *p; /* Information about an AUTOINCREMENT */
89221 ** Update the maximum rowid for an autoincrement calculation.
89237 ** Every statement that might do an INSERT into an autoincrement
89424 int appendFlag = 0; /* True if the insert is likely to be an append */
89522 /* If this is an AUTOINCREMENT table, look up the sequence number in the
89663 /* If the INSERT statement included an IDLIST term, then make sure
89667 ** If the table has an INTEGER PRIMARY KEY column and that column
89701 /* If there is no IDLIST term but the table has an integer primary
89775 /* build the NEW.* reference row. Note that if there is an INTEGER
89822 /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
89841 ** except when the table has an INTEGER PRIMARY KEY column, in which
90027 ** Generate code to do constraint checks prior to an INSERT or an UPDATE.
90044 ** is false, indicating an INSERT statement, then a non-zero rowidChng
90047 ** computed automatically in an insert or that the rowid value is not
90048 ** modified by an update.
90078 ** the stack and there is an immediate jump
90088 ** CHECK REPLACE Illegal. The results in an exception.
90110 int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
90194 /* If we have an INTEGER PRIMARY KEY, make sure the primary key
90196 ** is an UPDATE and the primary key is not changing, that is OK.
90298 /* Find out what action to take in case there is an indexing conflict */
90394 int appendBias, /* True if this is likely to be an append */
90505 ** for index pDest in an insert transfer optimization. The rules
90559 ** an unoptimized transfer. This routine also returns FALSE if there
90582 KeyInfo *pKey; /* Key information for an index */
90613 return 0; /* SELECT may not have an ORDER BY clause */
90616 ** there is no ORDER BY, we will get an error. */
90828 ** codes. Also write an error message into memory obtained from
90988 ** an SQLite instance. Shared libraries that intend to be loaded
91219 ** (part of the main SQLite library - not an extension) so that
91787 ** Attempt to load an SQLite extension library contained in the file
91794 ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with
92026 ** If anything goes wrong, set an error in the database connection.
92081 ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or
92135 ** Interpret the given string as an auto-vacuum mode value.
92294 ** compiler (eg. count_changes). So add an opcode to expire all
92415 /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS
92511 /* Malloc may fail when setting the page-size, as there is an internal
92556 ** change. The only purpose is to provide an easy way to test
92727 ** as an auto-vacuum capable db.
92734 ** that this really is an auto-vacuum capable database.
93160 /* Pragma "quick_check" is an experimental reduced version of
93198 /* Do an integrity check on each database file */
93211 /* Do an integrity check of the B-Tree
93334 ** is created. If an existing main database file is opened, then the
93656 ** Fill the InitData structure with an error message that indicates
93741 /* If the SQL column is blank it means this is an index that
93750 /* This can occur if there exists an index on a TEMP table which
93892 ** For an attached db, it is an error if the encoding is not the same
93904 /* If opening an attached database, the encoding much match ENC(db) */
93997 /* Jump here for an error that occurs after successfully allocating
93998 ** curMain and calling sqlite3BtreeEnter(). For an error that occurs
94017 ** created using ATTACH statements. Return a success code. If an
94018 ** error occurs, write an error message into *pzErrMsg.
94391 ** and the statement is automatically recompiled if an schema change
94471 ** and the statement is automatically recompiled if an schema change
94614 ** type of join. Return an integer constant that expresses that type
94626 ** If an illegal or unsupported join type is seen, then still return
94627 ** a join type, but put an error in the pParse structure.
94749 int isOuterJoin, /* True if this is an OUTER join */
94780 ** The EP_FromJoin property is used on terms of an expression to tell
94849 "an ON or USING clause", 0);
94874 ** an AND operator.
94886 ** Report an error if any column mentioned in the USING clause is
95007 ** Generate an error message when a SELECT is used within a subexpression
95021 "a SELECT that is part of an expression");
95086 /* If the destination is an EXISTS(...) expression, the actual
95153 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
95184 /* If this is a scalar select that is part of an expression, then
95245 ** Given an expression list, generate a KeyInfo structure that records
95248 ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting
95256 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
95304 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
95338 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
95491 ** declaration type for a ROWID field is INTEGER. Exactly when an expression
95682 /* If this is an EXPLAIN, skip this step */
95735 ** Given a an expression list (which is really the list of expressions
95766 /* Get an appropriate name for the column
95772 /* If the column contains an "AS <name>" phrase, use <name> as the name */
95912 ** If an error occurs, return NULL and leave a message in pParse.
95981 pParse->nMem++; /* Allocate an extra register for limit+offset */
96078 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
96126 /* Compound SELECTs that have an ORDER BY clause are handled separately.
96415 ** Code an output subroutine for a coroutine implementation of a
96466 /* Suppress the the first OFFSET entries if there is an OFFSET clause
96489 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
96506 #if 0 /* Never occurs on an ORDER BY query */
96516 /* If this is a scalar select that is part of an expression, then
96573 ** is an ORDER BY clause.
96619 ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA
96620 ** causes an immediate jump to EofA and an EOF on B following nextB causes
96621 ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or
97126 ** (2) The subquery is not an aggregate or the outer query is not a join.
97166 ** (16) The outer query is not an aggregate or the subquery does
97175 ** * is not an aggregate or DISTINCT query, and
97182 ** operators have an implied DISTINCT which is disallowed by
97193 ** an ORDER BY clause. Ticket #3773. We could relax this constraint
97275 ** not used as the right operand of an outer join. Examples of why this
97298 ** effectively converts the OUTER JOIN into an INNER JOIN.
97586 ** Analyze the SELECT statement passed as an argument to see if it
97617 ** The select statement passed as the first argument is an aggregate query.
97651 ** If the source-list item passed as an argument was augmented with an
97654 ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate
97724 ** an entry of the FROM clause is a subquery instead of a table or view,
97942 ** If anything goes wrong, an error message is written into pParse.
98046 ** intermediate results while calculating an aggregate. This
98094 ** Update the accumulator memory cells for an aggregate based on
98159 ** values to an OP_Copy.
98231 ** SRT_EphemTab Create an temporary table pDest->iParm and store
98249 ** encountered, then an appropriate error message is left in
98273 int addrSortIndex; /* Address of an OP_OpenEphemeral instruction */
98274 int addrDistinctIndex; /* Address of an OP_OpenEphemeral instruction */
98344 ** an exact limit.
98357 /* Generate a subroutine that will fill an ephemeral table with
98427 /* If there is both a GROUP BY and an ORDER BY clause and they are
98430 ** an optimization - the correct answer should result regardless.
98439 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
98452 ** BY and DISTINCT, and an index or separate temp-table for the other.
98463 /* If there is an ORDER BY clause, then this sorting
98466 ** OP_OpenEphemeral instruction will be changed to an OP_Noop once
98522 ** into an OP_Noop.
98548 /* Change the OP_OpenEphemeral coded earlier to an OP_Integer. The
98682 ** This might involve two separate loops with an OP_Sort in between, or
98683 ** it might be a single loop that uses an index to extract information
98867 ** is better to execute the op on an index, as indexes are almost
98881 ** there is such an index, and it has less columns than the table
98888 ** (2011-04-15) Do not do a full scan of an unordered index.
98920 ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause.
98985 /* If there is an ORDER BY clause, then we need to sort the results
99002 /* Control jumps to here if an error is encountered above, or upon
99146 char *zErrMsg; /* Error message text, if an error occurs */
99181 /* If this is the first row, then generate an extra row containing
99400 IdList *pColumns, /* column list if this is an UPDATE OF trigger */
99478 ** drop so the trigger cannot be dropped. This results in an
99620 /* Make an entry in the sqlite_master table */
99681 ** If an OOM error occurs, NULL is returned and db->mallocFailed is set.
99702 ** Build a trigger step out of an INSERT statement. Return a pointer
99705 ** The parser calls this routine when it sees an INSERT inside the
99737 ** Construct a trigger step that implements an UPDATE statement and return
99739 ** sees an UPDATE statement inside the body of a CREATE TRIGGER.
99934 ** pEList is the SET clause of an UPDATE statement. Each entry
99936 ** in pEList have an <id> which matches an identifier in pIdList,
99953 ** one trigger that must be fired when an operation of type 'op' is
99954 ** performed on the table, and, if that operation is an UPDATE, if at
99961 ExprList *pChanges, /* Columns that change in an UPDATE statement */
100033 ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use
100110 ** (trigger program). If an error has occurred, transfer error information
100148 ** are freed if an error occurs, link them into the Parse.pTriggerPrg
100208 /* Insert an OP_Halt at the end of the sub-program. */
100253 ** process of being coded). If this is the case, then an entry with
100255 ** in the Parse.pTriggerPrg list. Search for such an entry. */
100261 /* If an existing TriggerPrg could not be located, create a new one. */
100308 ** This is called to code the required FOR EACH ROW triggers for an operation
100311 ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then
100317 ** The reg argument is the address of the first in an array of registers
100337 ** are never accessed, and so are not allocated by the caller. So, for an
100345 ** raises an IGNORE exception.
100354 int reg, /* The first in an array of registers (see above) */
100389 ** old.* record into memory when executing an UPDATE or DELETE command.
100392 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
100395 ** with an index greater than 32 may be accessed, 0xffffffff is returned.
100472 ** The most recently coded instruction was an OP_Column to retrieve the
100478 ** was created, or added later to the table definition by an ALTER TABLE
100485 ** Column definitions created by an ALTER TABLE command may only have
100496 ** If parameter iReg is not negative, code an OP_RealAffinity instruction
100497 ** on register iReg. This is used when an equivalent integer value is
100498 ** stored in place of an 8-byte floating point value in order to save
100523 ** Process an UPDATE statement.
100547 ** an expression for the i-th column of the table.
100833 /* If there are triggers on this table, populate an array of registers
101021 ** Generate code for an UPDATE of a virtual table.
101023 ** The strategy is that we create an ephemerial table that contains
101136 ** Finalize a prepared statement. If there was an error, store the
101149 ** Execute zSql on database db. Return an error code.
101282 /* A VACUUM cannot change the pagesize of an encrypted database. */
101296 /* Begin a transaction and take an exclusive lock on the main database
101343 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
101387 ** transaction by sqlite3BtreeCopyFile() and the other by an explicit
101396 ** are an increment to apply to the meta value after the vacuum.
101439 /* Currently there is an SQL level transaction open on the vacuum
101482 ** sqlite3.pVtabCtx member variable is set to point to an instance of
101564 ** If an unlock is omitted, resources leaks will occur.
101621 ** above function sqlite3VtabUnlockList() for an explanation of why
101623 ** database connection that may have an entry in the p->pVTable list.
101829 ** The VM register number pParse->regRowid holds the rowid of an
101857 ** the first time the virtual table is used in an SQL statement. This
101878 ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
101888 ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
102009 ** of the virtual table pTab. If an error occurs, an error code is returned
102010 ** and an error left in pParse.
102080 ** If an error occurs, *pzErr is set to point an an English language
102081 ** description of the error and an SQLITE_XXX error code is returned.
102098 ** invoke it now. If the module has not been registered, return an
102245 ** sqlite3DbFree() containing an error message, if one is available.
102335 ** virtual tables that currently have an open transaction. Pass iSavepoint
102341 ** an open transaction is invoked.
102343 ** If any virtual table method returns an error code other than SQLITE_OK,
102385 ** table implementation have an opportunity to overload the function.
102456 ** array so that an OP_VBegin will get generated for it. Add pTab to the
102484 ** within an xUpdate method.
102575 ** The query generator uses an array of instances of this structure to
102785 #define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */
102787 #define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */
102797 #define WHERE_TEMP_INDEX 0x20000000 /* Uses an ephemeral index */
102938 ** Initialize an expression mask set (a WhereMaskSet object)
102971 ** This routine walks (recursively) an expression tree and generates
103035 ** allowed for an indexable WHERE clause term. The allowed operators are
103038 ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
103149 /* Figure out the collation sequence required from an index for
103223 ** be the name of an indexed column with TEXT affinity. */
103351 ** term that is an equivalent IN expression. In other words, if the term
103370 ** A subterm is also indexable if it is an AND of two or more
103376 ** potentially be used with an index if an appropriate index exists.
103501 ** that there is no possibility of transforming the OR clause into an
103509 ** might be possible to form an IN operator with either table1.column
103525 ** such table and column. Set okToChngToIN if an appropriate table
103542 ** or follwed by an inverted copy (t2.b==t1.a). Skip this term
103591 ** pTerm converted into an IN operator.
103635 ** The input to this routine is an WhereTerm structure with only the
103694 extraRight = x-1; /* ON clause terms may not be used with an index
103754 ** skipped. Or, if the children are satisfied by an index, the original
103781 ** an OR operator.
103892 /* When sqlite_stat3 histogram data is available an operator of the
103894 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
103933 ** an index for tables to the left of the join.
103959 ** for an expression of type TK_COLUMN that refers to the same column and
103964 ** If such an expression is found, its index in pList->a[] is returned. If
104076 /* If any of the expressions is an IPK column on table iBase, then return
104119 ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the
104121 ** the table has a cursor number of "base". pIdx is an index on pTab.
104157 ** or an index structure allocated on the stack by bestBtreeIndex() to
104179 /* Can not use an index sort on anything that is not a column in the
104202 /* If an index column that is constrained by == fails to match an
104210 /* If an index column fails to match and is not constrained by ==
104280 ** Two routines for printing the content of an sqlite3_index_info
104331 ** This routine attempts to find an scanning strategy that can be used
104332 ** to optimize an 'OR' expression that is part of a WHERE clause.
104402 /* If there is an ORDER BY clause, increase the scan cost to account
104429 ** could be used with an index to access pSrc, assuming an appropriate
104471 /* There is no point in building an automatic index for a single scan */
104523 ** Generate code to construct the Index object for an automatic index
104544 int regRecord; /* Register holding an index record */
104580 ** covering index. A "covering index" is an index that contains all
104674 ** Allocate and populate an sqlite3_index_info structure. It is the
104785 ** If an error occurs, pParse is populated with an error message and a
104789 ** Whether or not an error is returned, it is the responsibility of the
104818 "table %s: xBestIndex returned an invalid plan", pTab->zName);
104863 ** wsFlags in an uninitialized state, the caller may behave unpredictably.
104887 ** be a pointer to an sqlite3_vtab structure. Otherwise
104909 ** For each attempt at picking an index, the order of tables in the
104946 /* If there is an ORDER BY clause, and the selected virtual table index
104975 ** to optimize an OR expression within the WHERE clause.
104983 ** Estimate the location of a particular key among all keys in an
105145 ** an sqlite3_value structure containing the same value, with affinity
105151 ** is an SQL variable that currently has a non-NULL value bound to it,
105152 ** create an sqlite3_value structure containing this value, again with
105157 ** If an error occurs, return an error code. Otherwise, SQLITE_OK.
105180 ** by scanning an index for a range of values. The range may have an upper
105207 ** The returned value is an integer divisor to reduce the estimated
105286 ** an equality constraint x=VALUE and where that VALUE occurs in
105288 ** column of an index and sqlite_stat3 histogram data is available
105293 ** If unable to make an estimate, leave *pnRow unchanged and return
105336 ** an IN constraint where the right-hand side of the IN operator
105342 ** If unable to make an estimate, leave *pnRow unchanged and return
105382 ** The lowest cost plan wins. The cost is an estimate of the amount of
105394 ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in
105430 ** use an index to satisfy IS NULL constraints on that table. This is
105494 ** The "in-multiplier". This is an estimate of how many seek operations
105500 ** SQLite must perform 9 lookups on an index on (a, b), so nInMul is
105527 ** Boolean. True if there is an ORDER BY clause that will require an
105536 ** used by the SELECT statement are present in the index (such an
105586 /* If the index being considered is UNIQUE, and there is an equality
105623 /* If there is an ORDER BY clause and the index being considered will
105625 ** in wsFlags. Otherwise, if there is an ORDER BY clause but the index
105645 /* If currently calculating the cost of using an index (not the IPK
105667 ** Estimate the number of rows of output. For an "x IN (SELECT...)"
105706 ** records being an important factor. Both moves and searches are
105719 ** We add an additional 4x penalty to full table scans. This causes
105720 ** the cost function to err on the side of choosing an index over
105721 ** choosing a full scan. This 4x full-scan penalty is an arguable
105731 /* For an index lookup followed by a table lookup:
105776 ** the notReady mask. When computing an "optimal" index, the notReady
105781 ** might be selected even when there exists an optimal index that has
105849 /* If there was an INDEXED BY clause, then only that one index is
105862 ** SQLite outputs rows in in the absence of an ORDER BY clause. */
105933 ** of the join. Disabling is an optimization. When terms are satisfied
105956 ** Code an OP_Affinity opcode to apply the column affinity string zAff
105959 ** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the
106061 ** Generate code that will evaluate all == and IN constraints for an
106067 ** example, the third "c" value is an inequality. So only two
106081 ** this routine allocates an additional nEq memory cells for internal
106117 /* This module is only called on query plans that use an index. */
106176 ** pStr holds the text of an expression that we are building up one term
106196 ** of the subset of table rows scanned by the strategy in the form of an
106203 ** is run and there is an index on (a, b), then this function returns a
106245 ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
106246 ** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single
106370 ** When there is an IN operator, we also have a "addrNxt" label that
106433 /* Case 1: We can directly reference a single row using an
106453 /* Case 2: We have an inequality comparison against the ROWID field.
106530 /* Case 3: A scan using an index.
106537 ** the right-most column can be an inequality - the rest must
106558 ** constraints but an index is selected anyway, in order
106559 ** to force the output order to conform to an ORDER BY.
106577 int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
106628 ** and store the values of those terms in an array of registers
106637 /* If we are doing a reverse order scan on an ascending index, or
106855 ** equivalent to an empty rowset.
106862 ** fall through to the next instruction, just as an OP_Next does if
106863 ** called on an uninitialized cursor.
107061 ** The return value is a pointer to an opaque structure that contains
107066 ** If an error occurs, this routine returns NULL.
107102 ** entire tables. Thus a three-way join is an O(N^3) operation. But if
107136 ** is called from an UPDATE or DELETE statement, then ppOrderBy is NULL.
107138 ** If an index can be used so that the natural output order of the table
107140 ** *ppOrderBy is set to NULL. This is an optimization that prevents an
107141 ** unnecessary sort of the result set if an index appropriate for the
107188 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
107189 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
107218 ** subexpression is separated by an AND operator.
107319 Bitmask notIndexed; /* Mask of tables that cannot use an index */
107331 ** to choose from. The first test looks for an "optimal" scan. In
107332 ** this context an optimal scan is one that uses the same strategy
107342 ** Note that the WhereCost.nRow parameter for an optimal scan might
107406 /* If an INDEXED BY clause is present, then the plan must use that
107422 ** the full-table-scan is an "optimal" plan as defined above.
107424 ** (3) All tables have an INDEXED BY clause or this table lacks an
107427 ** that a best-so-far is always selected even if an impossible
107483 /* Check that if the table scanned by this loop iteration had an
107486 ** Return an error.
107494 /* If an INDEXED BY clause is used, the bestIndex() function is
107496 ** if it find an index at all. */
107513 /* If the caller is an UPDATE or DELETE statement that is requesting
107741 /* If this scan uses an index, make code substitutions to read data
107893 /* Construct an expression node for a unary postfix operator
107918 /* Construct an expression node for a unary prefix operator
108036 ** functions that take a state number and lookahead value and return an
108561 ** the parse is retried before an error is thrown.
108656 /* The state of the parser is completely contained in an instance of
110456 /* When doing a nested parse, one can include terms in an expression
111098 ** <li> A pointer to the parser (an opaque structure.)
111119 int yyerrorhit = 0; /* True if yymajor has invoked an error */
111171 ** The response to an error depends upon whether or not the
111172 ** grammar defines an error token "ERROR".
111239 ** * Report an error message, and throw away the input token.
111276 ** This file contains C code that splits an SQL input string up into
111285 ** an upper-to-lower case map. On EBCDIC machines we also need
111316 ** The sqlite3KeywordCode function looks up an identifier to determine if
111335 ** or not a given identifier is really an SQL keyword. The same thing
111604 ** If X is a character that can be used in an identifier then
111608 ** allowed in an identifier. For 7-bit characters,
111917 ** passed in. An SQLITE_ status code is returned. If an error occurs
111918 ** then an and attempt is made to write an error message into
111930 int mxSqlLen; /* Max length of an SQL string */
112125 ** (1) START At the beginning or end of an SQL statement. This routine
112165 ** is look for a semicolon that is not part of an string or comment.
112484 ** returns an integer equal to SQLITE_VERSION_NUMBER.
112602 ** the pInitMutex mutex. Return an error in either case. */
112764 /* Specify an alternative mutex implementation */
112777 /* Specify an alternative malloc implementation */
112812 /* now an error */
112818 /* Specify an alternative page cache implementation */
112854 ** ENABLE_MEMSYS5 is defined, return an error.
112994 ** Configuration settings for an individual database connection
113160 ** Close an existing SQLite database
113331 /* SQLITE_OK */ "not an error",
113379 ** an integer number of milliseconds passed in as the first
113424 ** This routine is called when an operation failed with a lock.
113426 ** returns 0, the operation aborts with an SQLITE_BUSY error.
113441 ** This routine sets the busy callback for an Sqlite database to the
113459 ** This routine sets the progress callback for an Sqlite database to the
113509 ** that if a malloc() fails in sqlite3_create_function(), an error code
113563 /* Check if an existing function is being overridden or deleted. If so,
113586 /* If an older version of the function with a configured destructor is
113688 ** When virtual tables intend to provide an overloaded function, they
113810 ** is greater than sqlite3.pWalArg cast to an integer (the value configured by
113829 ** Configure an sqlite3_wal_hook() callback to automatically checkpoint
113891 /* Initialize the output variables to -1 in case an error occurs. */
113936 ** an error occurs while running the checkpoint, an SQLite error code is
113944 ** checkpointed. If an error is encountered it is returned immediately -
114082 ** Return the most recent error code generated by an SQLite routine. If NULL is
114136 /* Check if this call is removing or replacing an existing collation
114237 ** If an invalid limit index is supplied, report -1.
114301 ** If an error occurs, then an SQLite error code is returned and *pzErrMsg
114302 ** may be set to point to a buffer containing an English language error
114536 ** Throw an error if any non-sense combination is used. If we
114933 ** This function is now an anachronism. It used to be used to recover from a
115068 ** 2. The table is not a view and the column name identified an
115089 ** to whatever their local counterparts contain. If an error did occur,
115211 ** is an array of integers that defines the test. Return -1 on a
115212 ** memory allocation error, 0 on success, or non-zero for an error.
115246 ** an incompatible database file format. Changing the PENDING byte
115618 ** Register an unlock-notify callback.
115621 ** but has received an SQLITE_LOCKED error because another connection
115762 ** This is a difficult situation to handle. Returning an error
115763 ** code to the caller is insufficient, as even if an error code
115767 ** indefinitely for an unlock-notify callback that will never
115812 ** This is called when the database connection passed as an argument is
115838 ** This is an SQLite module implementing full-text search.
115844 ** * The FTS3 module is being built as an extension
115913 ** memory. A "position" is an index of a token in the token stream
115938 ** A bare doclist omits the position information, becoming an
115990 ** SegmentWriter creates new leaf nodes, or when an interior node
116007 ** Here, optional { X } means an optional element, while array { X }
116036 ** This could be either a leaf node or an interior node. If the top
116108 ** write an empty doclist (varint(docid) varint(POS_END)), for updates
116139 ** FTS4 is really an extension for FTS3. It is enabled using the
116141 ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
116186 ** an sqlite3_tokenizer_module containing pointers to the callback
116187 ** functions that make up an implementation.
116189 ** When an fts3 table is created, it passes any arguments passed to
116192 ** implementation. The xCreate() function in turn returns an
116196 ** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()
116197 ** method is called. It returns an sqlite3_tokenizer_cursor object
116224 ** This method should return either SQLITE_OK (0), or an SQLite error
116237 ** Destroy an existing tokenizer. The fts3 module calls this method
116243 ** Create a tokenizer cursor to tokenize an input buffer. The caller
116254 ** Destroy an existing tokenizer cursor. The fts3 module calls this
116263 ** the end of the buffer has been reached, or an SQLite error code.
116344 /* A complete hash table is an instance of the following structure.
116364 /* Each element in the hash table is an instance of the following
116455 ** Macro to return the number of elements in an array. SQLite has a
116457 ** a collision when building an amalgamation with built-in FTS3.
116483 ** It is considered impossible for an index to use more than 1024 levels. In
116575 ** A connection to a fulltext index is an instance of the following
116576 ** structure. The xCreate and xConnect methods create an instance
116618 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
116620 ** is an index of prefixes of a specific length.
116645 ** virtual table cursor (an instance of the following structure) using
116751 ** matchinfo data. If it is not NULL, it points to an array of size nCol*3,
117009 ** Convert an SQL-style quoted string into a normal string by removing
117159 ** Otherwise, return an SQLite error code.
117171 ** Otherwise, if an error occurs, an SQLite error code is stored in *pRc
117213 ** If the p->bHasDocsize boolean is true (indicating that this is an
117214 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
117281 ** Otherwise, if an error occurs, an SQLite error code is stored in *pRc
117341 ** Append the output of a printf() style formatting to an existing string.
117403 ** being returned directly each column of text data is passed to an SQL
117414 ** a NULL pointer is returned). Otherwise, if an OOM error is encountered
117461 ** is preceded by zFunc and an open bracket, and followed by a closed
117471 ** a NULL pointer is returned). Otherwise, if an OOM error is encountered
117503 ** Only decimal digits ('0'..'9') may be part of an integer value.
117524 ** This function is called to allocate an array of Fts3Index structures
117535 ** array. If an error does occur, an SQLite error code is returned.
117537 ** Regardless of whether or not an error is returned, it is the responsibility
117579 ** This function is called when initializing an FTS4 table that uses the
117593 ** *pazCol: Set to point to an array of *pnCol strings. Each string is
117599 ** If the table cannot be found, an error code is returned and the output
117600 ** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is
117747 /* Check if it is an FTS4 special argument. */
117959 /* If this is an xCreate call, create the underlying tables in the
118034 /* By default use a full table scan. This is an expensive option,
118060 ** it would lead to an "unable to use function MATCH in the requested
118114 /* Allocate a buffer large enough for an Fts3Cursor structure. If the
118145 ** compose and prepare an SQL statement of the form:
118150 ** it. If an error occurs, return an SQLite error code.
118216 ** If an OOM error occurs, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.
118239 ** varints from the buffer) does not risk an overread. If zNode is a
118319 ** The buffer pointed to by argument zNode (size nNode bytes) contains an
118337 ** If an error occurs, an error code other than SQLITE_OK is returned.
118415 /* The end of a position list is marked by a zero encoded as an FTS3
118480 ** Value used to signify the end of an position-list. This is safe because
118516 ** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by
118624 ** If isSaveLeft is 0, an entry is added to the output position list for
118743 ** position lists correspond to the left and right phrases of an expression
118881 ** This function does an "OR" merge of two doclists (output contains all
118887 ** If no error occurs, *paOut is set to point at an sqlite3_malloc'd buffer
118891 ** If an error occurs, an SQLite error code is returned. The output values
119041 ** of the entries from pList at position 0, and terminated by an 0x00 byte.
119092 ** If an OOM error occurs, return SQLITE_NOMEM. In this case it is
119138 ** as the first argument. The merge is an "OR" merge (see function
119147 ** This function returns SQLITE_OK if the merge is successful, or an
119148 ** SQLite error code (SQLITE_NOMEM) if an error occurs.
119230 ** This function returns SQLITE_OK if successful, or an SQLite error code
119250 ** made by an fts4aux module, not an FTS table. In this case calling
119327 /* "isScan" is only set to true by the ft4aux module, an ordinary
119342 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
119357 ** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,
119361 ** an SQLite error code.
119366 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
119367 ** Output parameter *ppSegcsr is set to 0 if an error occurs.
119382 int bFound = 0; /* True once an index has been found */
119424 ** Free an Fts3MultiSegReader allocated by fts3TermSegReaderCursor().
119516 ** subsequently to determine whether or not an EOF was hit.
119689 /* This call is a request for the "docid" column. Since "docid" is an
119813 ** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error
119905 ** where 't' is the name of an FTS3 table.
119995 ** Implementation of FTS3 xRename method. Rename an fts3 table.
120006 ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction
120114 ** This function is registered as the module destructor (called when an
120227 ** Allocate an Fts3MultiSegReader for each token in the expression headed
120232 ** Fts3SegReader objects internally to provide an interface to seek or scan
120238 ** and merged incrementally. Otherwise, it has to be merged into an in-memory
120339 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120375 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120474 ** function has been called successfully on an Fts3Phrase, it may be
120481 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120576 ** If an error occurs, return an SQLite error code. Otherwise, return
120660 ** If an error occurs within this function, *pRc is set to an SQLite error
120709 ** This function is used to populate an allocated Fts3TokenAndCost array.
120712 ** Otherwise, if an error occurs during execution, *pRc is set to an
120761 ** an SQLite error code.
120765 ** of data that will fit on a single leaf page of an intkey table in
120827 ** called on each token to defer. Otherwise, an SQLite error code is
121078 ** If an error occurs, *pRc is set to an SQLite error code. Otherwise, if
121102 ** is advanced to the next row that contains an instance of "A * C",
121315 ** If an error occurs during execution of this function, *pRc is set to
121485 ** a no-op. If an error occurs within this function, *pRc is set to an
121567 ** populated. Otherwise, if an error occurs, an SQLite error code is returned.
121720 ** compression and is terminated by either an 0x01 or 0x00 byte. For example,
121883 /* The user should specify a single argument - the name of an fts3 table. */
122250 ** if successful or an error code if sqlite3_create_module() fails.
122321 ** than an implicit AND. When using the new, both implicity and explicit
122395 ** is defined to accept an argument of type int, its behaviour when passed
122396 ** an integer that falls outside of the range of the unsigned char type
122398 ** is defined to accept an argument of type char, and always returns 0 for
122447 ** and other information (column names etc.) in pParse. Create an Fts3Expr
122525 ** Enlarge a memory allocation. If an out-of-memory allocation occurs,
122538 ** that appeared as part of an fts3 query expression. Neither quote character
122540 ** input buffer and create an Fts3Expr structure of type FTSQUERY_PHRASE
122665 ** The output variable *ppExpr is populated with an allocated Fts3Expr
122668 ** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM
122670 ** If SQLITE_ERROR is returned, pContext is populated with an error message.
122700 /* Skip over any whitespace before checking for a keyword, an open or
122724 /* If this is a "NEAR" keyword, check for an explicit nearness. */
122736 ** the next byte must contain either whitespace, an open or close
122760 /* Check for an open bracket. */
122798 ** interface. Before doing so, figure out if there is an explicit
122803 ** an implementation artifact or an intentional decision when fts3 was
122826 ** The argument is an Fts3Expr structure for a binary operator (any type
122827 ** except an FTSQUERY_PHRASE). Return an integer value representing the
122888 ** returns either when the end of the buffer is reached or an unmatched
122920 /* Create an implicit NOT operator. */
122939 ** an expression contained in parenthesis is required. If a
122950 /* Insert an implicit AND operator. */
122971 ** Return an error in either case.
123036 ** an fts3 query expression, respectively. This function attempts to parse the
123039 ** of the parsed expression tree and SQLITE_OK is returned. If an error
123153 ** sqlite3_free() to release the memory. If an OOM condition is encountered,
123322 ** * The FTS3 module is being built as an extension
123438 ** with types "const void*" and "int" and returns an "int".
123464 /* Link an element into the hash table
123516 /* This function (for internal use only) locates an element in an
123599 ** Attempt to locate an element of the hash table pH with a key
123610 /* Insert an element into the hash table pH. The key is pKey,nKey
123705 ** * The FTS3 module is being built as an extension
123860 ** In prose: A word is an optional consonant followed by zero or
123861 ** vowel-consonant pairs followed by an optional vowel. "m" is the
123870 ** for an instance of of a consonant followed by a vowel.
124346 ** This is part of an SQLite module implementing full-text search.
124353 ** * The FTS3 module is being built as an extension
124378 ** an error is returned.
124712 ** in the README.tokenizer file as an example, so it is important to
124842 ** * The FTS3 module is being built as an extension
125091 ** it is always safe to read up to two varints from it without risking an
125295 ** This function is used to obtain an SQLite prepared statement handle
125298 ** Otherwise, an SQLite error code is returned and *pp is set to 0.
125300 ** If argument apVal is not NULL, then it must point to an array with
125436 ** Returns SQLITE_OK if the statement is successfully executed, or an
125536 ** return SQLITE_OK. If an error occurs while preparing the statement,
125537 ** return an SQLite error code.
125587 ** if successful, or an SQLite error code otherwise.
125637 ** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.
125701 ** Add an entry to one of the pending-terms hash tables.
125739 ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
125862 ** This function is called by the xUpdate() method as part of an INSERT
125888 ** This function is called by the xUpdate() method for an INSERT operation.
125945 ** In FTS3, this is an error. It is an error to specify non-NULL values
126007 ** (an integer) of a row about to be deleted. Remove all terms from the
126063 ** returned. Otherwise, an SQLite error code is returned.
126120 ** If an error occurs, or the table does not contain the specified row,
126121 ** an SQLite error code is returned. Otherwise, SQLITE_OK is returned. If
126125 ** This function may leave an open sqlite3_blob* handle in the
126232 ** Set an Fts3SegReader cursor to point at EOF.
126246 ** SQLITE_DONE. Otherwise, an SQLite error code.
126284 /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf
126400 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
126420 /* Pointer p currently points at the first byte of an offset list. The
126571 ** an array of pending terms by term. This occurs as part of flushing
126589 ** This function is used to allocate an Fts3SegReader that iterates through
126727 ** version, it is assumed that each SegReader points to an entry in
126789 ** Argument apSegment is an array of nSegment elements. It is known that
127030 ** blocks were written to the db). Otherwise, an SQLite error code is
127100 ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
127238 ** returned. Otherwise, an SQLite error code.
127285 ** The first value in the apVal[] array is assumed to contain an integer.
127291 ** document pRowid, or false otherwise, and SQLITE_OK is returned. If an
127292 ** error occurs, an SQLite error code is returned.
127319 ** Return SQLITE_OK if successful, or an SQLite error code if not.
127361 ** SQLITE_OK is returned if successful, otherwise an SQLite error code.
127462 ** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered
127718 ** Similarly, if this is a search for an exact match, and the first term
127869 ** Otherwise, if successful, SQLITE_OK is returned. If an error occurs,
127870 ** an SQLite error code is returned.
128170 /* Compose and prepare an SQL statement to loop through the content table */
128378 ** Add an entry for token pToken to the pCsr->pDeferred list.
128460 int isRemove = 0; /* True for an UPDATE or DELETE */
128498 /* If this is an INSERT operation, or an UPDATE that modifies the rowid
128520 ** the statement is either an INSERT or an UPDATE that modifies the
128529 ** be losslessly converted to an integer. In this case, the eventual
128533 ** docid=$pNewRowid if $pNewRowid is not an integer value).
128554 /* If this is an INSERT or UPDATE operation, insert the new record. */
128648 ** Used as an fts3ExprIterate() context when loading phrase doclists to
128692 ** This type is used as an fts3ExprIterate() context object while
128722 ** element of the list is represented by an FTS3 varint that takes the value
128734 ** When this function is called, *pp points to the start of an element of
128771 ** Iterate through all phrase nodes in an FTS3 query, except those that
128790 ** This is an fts3ExprIterate() callback used while loading the doclists
128966 ** This function is an fts3ExprIterate() callback used by fts3BestSnippet().
128967 ** Each invocation populates an element of the SnippetIter.aPhrase[] array.
129501 ** Advance the iterator passed as an argument to the next position. Return
129529 ** Otherwise, if an error occurs, an SQLite error code is returned and the
129599 ** Populate the buffer pInfo->aMatchinfo[] with an array of integers to
129611 ** Return SQLITE_OK if successful, or an SQLite error code if an error
129716 ** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32).
129903 ** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().
129987 /* Retreive the text stored in column iCol. If an SQL NULL is stored
129989 ** If an OOM occurs while retrieving the data (this can happen if SQLite
130128 ** algorithms packaged as an SQLite virtual table module.
130146 ** an entry in the %_parent table associating the node with its parent.
130147 ** And for each row of data in the table, there is an entry in the %_rowid
130151 ** The root node of an r-tree always exists, even if the r-tree table is
130164 ** consists of a single 8-byte integer followed by an even number
130173 ** This file contains an implementation of a couple of different variants
130304 ** If an R*-tree "Reinsert" operation is required, the same number of
130315 ** 2^40 is greater than 2^64, an r-tree structure always has a depth of
130338 ** The argument is an RtreeCoord. Return the value stored within the RtreeCoord
130398 ** the right-hand-side of an SQL MATCH operator used to constrain an
130574 ** Obtain a reference to an r-tree node.
130775 ** an internal node, then the 64-bit integer is a child page number.
131002 ** Return SQLITE_OK if successful or an SQLite error code if an error
131054 ** Return SQLITE_OK if successful or an SQLite error code if an error
131280 ** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf
131281 ** to zero and return an SQLite error code.
131392 ** can be cast into an RtreeMatchArg object. One created using
131393 ** an sqlite3_rtree_geometry_callback() SQL user function.
131482 /* We have an equality constraint on the rowid. Use strategy 1. */
131492 /* This strategy involves a two rowid lookups on an B-Tree structures
131493 ** and then a linear search of an R-Tree node. This should be
131495 ** sqlite uses an internal cost of 0.0).
132300 /* Allocate an array and populate it with a copy of pCell and
132420 ** This operation is required when a row is deleted (or updated - an update
132421 ** is implemented as a delete followed by an insert). SQLite provides the
132847 /* Constraint handling. A write operation on an r-tree table may return
132907 /* If azData[0] is not an SQL NULL value, it is the rowid of a
132972 rtreeConnect, /* xConnect - connect to an existing table */
133068 ** The second argument to this function contains the text of an SQL statement
133071 ** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error
133093 ** Otherwise, an SQLite error code is returned.
133095 ** If this function is being called as part of an xConnect(), then the rtree
133099 ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size.
133158 "Wrong number of columns for an rtree table", /* 1 */
133159 "Too few columns for an rtree table", /* 2 */
133160 "Too many columns for an rtree table" /* 3 */
133236 ** an r-tree node, and the number of dimensions the r-tree indexes.
133334 ** Each call to sqlite3_rtree_geometry_callback() creates an ordinary SQLite
133415 ** This file implements an integration between the ICU library
133416 ** ("International Components for Unicode", an open-source library
133489 ** 1. uPattern is an unescaped match-all character "%",
133490 ** 2. uPattern is an unescaped match-one character "_",
133491 ** 3. uPattern is an unescaped escape character, or
133492 ** 4. uPattern is to be handled as an ordinary character
133552 ** is implemented as like(B, A). If there is an escape character E,
133578 ** Otherwise, return an error.
133598 ** This function is called when an ICU function called from within
133599 ** the implementation of an SQL scalar function returns an error.
133602 ** loaded with an error message based on the following two args.
133628 ** argument is an SQL NULL, then NULL Is returned. Otherwise, the result
133691 ** leaving the regular expression object configured with an invalid
133717 ** of the locale to use. Passing an empty string ("") or SQL NULL value
133802 ** types to an SQLite database connection. It is intended to be called
133807 ** Where <locale> is a string containing an ICU locale identifier (i.e.