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
25783 ** A pointer to an instance of the following structure can be used as a
25867 /* Search for an existing entry that matching the canonical name.
25929 ** an exclusive lock on fd1, then try to get an exclusive lock
25954 ** The sqlite3_file structure for POSIX is no longer just an integer file
25962 ** file is unlocked. cnt==-1 means the file has an exclusive lock.
25968 ** a locked and an unlocked state.
25976 ** When an attempt is made to close an unixFile, if there are
26023 ** structure contains a pointer to an instance of this object and this
26056 ** It is invoked after an error occurs in an OS function and errno has been
26091 ** strerror_r(), which always writes an error message into aErr[].
26094 ** available, the error message will often be an empty string. Not a
26131 ** So we don't even try to recover from an EINTR. Just log the error
26189 ** return value might be uninitialized if an error occurs.
26194 ** Return an appropriate error code.
26222 /* On OS X on an msdos filesystem, the inode number is reported
26227 ** an ASCII 'S' character which also happens to be the first byte
26281 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
26328 ** ever obtained is an exclusive lock, and it is obtained exactly once
26495 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
26553 /* We are trying for an exclusive lock but another thread in this
26635 ** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED
26739 ** process is holding an incompatible lock. If it does, this
26743 ** an assert to fail). */
26763 /* Decrement the shared lock counter. Release the lock using an
26926 ** Nevertheless, a dotlock is an appropriate locking mode for use if no
26931 ** The existance of a lock directory implies an EXCLUSIVE lock. All other
26945 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27022 /* grab an exclusive lock */
27118 ** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite
27145 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27170 /* unlock failed with an error */
27242 /* grab an exclusive lock */
27286 /* shared can just be set because we always have an exclusive */
27335 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27454 /* shared can just be set because we always have an exclusive */
27530 ** This is a utility for setting or clearing a bit-range lock on an
27579 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
27712 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
27764 /* We are trying for an exclusive lock but another thread in this
27782 /* Acquire an EXCLUSIVE lock */
27901 /* Decrement the shared lock counter. Release the lock using an
28241 ** unix systems. The following procedure is an attempt to make
28247 ** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash
28259 ** as far as SQLite is concerned, an fdatasync() is always adequate.
28301 /* If the FULLFSYNC failed, fall back to attempting an fsync().
28304 ** isn't supported for this file system. So, attempt an fsync
28334 ** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM
28335 ** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined
28437 ** Truncate an open file to a specified size
28446 ** file so that it consists of an integer number of chunks (i.e. the
28532 ** or an error number on failure". See the manpage for details. */
28582 ** Information and control of an open file handle.
28680 ** Object used to represent an shared memory buffer.
28727 ** Structure used internally by this VFS to record the state of an
28869 ** Another approach to is to use files in /dev/shm or /dev/tmp or an
28878 ** option results in an incompatible build of SQLite; builds of SQLite
28889 ** that means that an exclusive lock is held on the database file and
28908 /* Check to see if a unixShmNode object already exists. Reuse an existing
28918 ** a new *-shm file is created, an attempt will be made to create it
29030 ** If an error occurs, an error code is returned and *pp is set to NULL.
29208 ** If any sibling already holds an exclusive lock, go ahead and return
29693 /* If an error occured in findInodeInfo(), close the file descriptor
29847 /* It's odd to simulate an io-error here, but really this is just
29886 ** Search for an unused file descriptor that was opened on the database
29904 /* Do not search for an unused file descriptor on vxworks. Not because
29907 ** not to risk breaking vxworks support for the sake of such an obscure
29913 ** almost certain that an open() call on the same path will also fail.
29914 ** For this reason, if an error occurs in the stat() call here, it is
29916 ** descriptor on the same path, fail, and return an error to SQLite.
29947 ** written to *pMode. If an IO error occurs, an SQLite error code is
29951 ** an indication to robust_open() to create the file using
30392 /* It's odd to simulate an io-error here, but really this is just
30653 ** shared range is taken for an EXCLUSIVE lock):
30719 ** by taking an sqlite-style shared lock on the conch file, reading the
30725 ** host ID and/or proxy path, then the lock is escalated to an exclusive
30740 ** The shared lock and an open file descriptor are maintained until
31018 ** Takes an open conch file, copies the contents to a new path and then moves
31210 do { /* in case we need to try again for an :auto: named lock file */
31262 /* We are trying for an exclusive lock but another thread in this
31507 ** Takes an already filled in unix file and alters it so all file locking
31669 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
31817 ** The following macro defines an initializer for an sqlite3_vfs object.
31833 ** database file and tries to choose an locking method appropriate for
32173 BOOL bExclusive; /* Indicates an exclusive lock has been obtained */
32548 ** an ANSI string regardless of the _UNICODE setting */
32831 ** Here is an interesting observation: Win95, Win98, and WinME lack
32897 ** Change the size of an existing memory allocation
32925 ** Return the size of an outstanding allocation, in bytes.
33086 ** Convert an ANSI string to Microsoft Unicode, based on the
33253 ** This routine is invoked after an error occurs in an OS function.
33306 ** to give up with an error.
33526 /* Wanting an exclusive lock? */
33590 /* Releasing a reader lock or an exclusive lock */
33592 /* Did we have an exclusive lock? */
33691 ** whether an error has actually occured, it is also necessary to call
33710 ** It is reported that an attempt to close a handle might sometimes
33715 ** giving up and returning an error.
33847 ** Truncate an open file to a specified size
33859 ** file so that it consists of an integer number of chunks (i.e. the
34144 /* Acquire an EXCLUSIVE lock
34442 ** Structure used internally by this VFS to record the state of an
34604 /* Look to see if there is an existing winShmNode that can be used.
34782 ** If any sibling already holds an exclusive lock, go ahead and return
34856 ** If an error occurs, an error code is returned and *pp is set to NULL.
34996 ** This vector defines all the methods that can operate on an
35059 /* It's odd to simulate an io-error here, but really this is just
35360 ** up and returning an error.
35435 /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
35521 /* It's odd to simulate an io-error here, but really this is just
35743 ** strerror_r() on Unix). After an error is returned by an OS
35757 ** Not supplying an error message will have no adverse effect
35758 ** on SQLite. It is fine to have an implementation that never
35759 ** returns an error message:
35766 ** However if an error message is supplied, it will be incorporated
35838 ** This file implements an object that represents a fixed-length
35890 ** (an arbitrary prime)in the hash function provided
35898 ** A bitmap is an instance of the following structure.
35979 ** Set the i-th bit. Return 0 on success and an error code if
35984 ** that can go wrong with an insert, assuming p and i are valid.
36119 ** Let V[] be an array of unsigned characters sufficient to hold
36120 ** up to N bits. Let I be an integer between 0 and N. 0<=I<N.
36129 ** This routine runs an extensive test of the Bitvec code.
36131 ** The input is an array of integers that acts as a program
36154 ** an error is returned. If they are the same, zero is returned.
36252 ** A complete page cache is an instance of this structure.
36285 ** is not, either fail an assert or return zero. Otherwise, return
36361 ** being used for an in-memory database, this function is a no-op.
36796 ** Return the number of references to the page supplied as an argument.
36885 ** pages when they are under memory pressure. A PGroup is an instance of
36914 /* Each page cache is an instance of the following object. Every
36917 ** is an instance of this object.
36947 ** Each cache entry is represented by an instance of the following
36991 ** (2) even if an incorrect value is read, no great harm is done since this
36992 ** is really just an optimization. */
37015 ** verb to sqlite3_config(). Parameter pBuf points to an allocation large
37083 ** Free an allocated buffer obtained from pcache1Alloc().
37197 ** Free an allocated buffer obtained from sqlite3PageMalloc().
37312 ** Remove the page supplied as an argument from the hash table
37523 ** For a non-purgeable cache (a cache used as the storage for an in-memory
37583 /* Step 1: Search the hash table for an existing entry. */
37598 ** local variable here. Delaying the initialization of pGroup is an
37697 /* It is an error to call this function if the page is already
37800 ** already provided an alternative.
37890 ** This module implements an object we call a "RowSet".
37893 ** are inserted into the RowSet in an arbitrary order. Inserts
37911 ** TEST checks to see if an element is already in the RowSet. SMALLEST
37915 ** allocated in chunks so most INSERTs do no allocation. There is an
37921 ** in the batch number. In other words, if an INSERT occurs between
37930 ** The cost of an INSERT is roughly constant. (Sometime new memory
37931 ** has to be allocated on an INSERT.) The cost of a TEST with a new
37937 ** There is an added cost of O(N) when switching between TEST and
37954 ** Each entry in a RowSet is an instance of the following object.
37974 ** A RowSet in an instance of the following structure.
37997 ** an assertion fault occurs.
37999 ** If N is larger than the minimum, use the surplus as an initial
38179 ** list contains too few elements, then construct an incomplete tree
38388 ** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and
38409 /* Return an integer that records the current (uncommitted) write
38440 /* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)
38502 ** (3) Writes to the database file are an integer multiple of the page size
38506 ** an integer multiple of the page size in length or are taken from the
38567 ** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file
38660 ** If the connection is running with locking_mode=exclusive, an attempt
38661 ** is made to obtain an EXCLUSIVE lock on the database file.
38716 ** commit the transaction. If an error did occur, the caller will need
38721 ** The ERROR state is entered when an IO or disk-full error (including
38729 ** For example, if an IO error occurs while performing a rollback,
38730 ** the contents of the page-cache may be left in an inconsistent state.
38736 ** instead of READER following such an error.
38739 ** to read or write data returns an error. Eventually, once all
38767 ** automatically attempt a rollback, as it assumes that an error in a
38768 ** read-only statement cannot leave the pager in an internally inconsistent
38774 ** * The pager is not an in-memory pager.
38805 ** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY
38814 ** This is usually safe. If an xUnlock fails or appears to fail, there may
38822 ** fails at this point and the pager is left holding an EXCLUSIVE lock, this
38828 ** return true because the caller itself is holding an EXCLUSIVE lock (but
38830 ** a hot-journal may be mistaken for a journal being created by an active
38839 ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
38866 ** such a system. This is currently an undocumented limit.
38896 ** A open page cache is an instance of struct Pager. A description of
38926 ** can only happen if an exclusive lock is held on the database file.
38927 ** It is cleared (set to false) whenever an exclusive lock is
38957 ** by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the
38982 ** is opened as an in-memory journal file. If false, then in-memory
38997 ** is not an integer multiple of the page-size, the value stored in
39154 ** file after power is restored. If an attempt is then made
39156 ** sanity checking data is an attempt to discover the garbage in the
39166 ** garbage data came from an obsolete journal file, the checksums might
39187 ** The macro MEMDB is true if we are dealing with an in-memory database.
39256 ** as if it has an exclusive lock on the database file. It never updates
39268 /* Check that MEMDB implies noSync. And an in-memory journal. Since
39269 ** this means an in-memory pager performs no IO at all, it cannot encounter
39273 ** is therefore not possible for an in-memory pager to enter the ERROR
39374 ** containing the state of the Pager object passed as an argument. This
39375 ** is intended to be used within debuggers. For example, as an alternative
39453 ** that is read in *pRes. Return SQLITE_OK if everything worked, or an
39475 ** on success or an error code is something goes wrong.
39490 ** UNKNOWN_LOCK for an explanation of this.
39516 ** See the comment above the #define of UNKNOWN_LOCK for an explanation
39543 ** an error to call this function if pPager is opened on an in-memory
39599 ** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES
39600 ** is defined, and NDEBUG is not defined, an assert() statement checks
39639 ** If an error occurs while reading from the journal file, an SQLite
39725 ** If an IO error occurs, abandon processing and return the IO error code.
39893 ** cannot be read from the journal file an error code is returned.
39920 ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise,
39935 ** of the transaction. Return an error code if anything goes wrong.
40055 ** an error occurs, return the error code to the caller.
40202 ** above the #define for UNKNOWN_LOCK for an explanation of why this
40238 ** This function is called whenever an IOERR or FULL error that requires
40274 ** after rollback of a hot-journal, or if an error occurs while opening
40292 ** Journal file descriptor is simply closed. This destroys an
40315 ** SQLITE_OK is returned if no error occurs. If an error occurs during
40328 /* Do nothing if the pager does not have an open write transaction
40336 ** 2. If a connection with locking_mode=exclusive holding an EXCLUSIVE
40372 ** the database file, it will do so using an in-memory journal.
40434 ** If the pager has not already entered the ERROR state, but an IO or
40462 ** Each byte is interpreted as an 8-bit unsigned integer.
40464 ** Changing the formula used to compute this checksum results in an
40518 ** and played back, then SQLITE_OK is returned. If an IO error occurs
40532 ** allocated by this function. If this is the case and an allocation fails,
40562 ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback
40571 ** file. Return an error code to the caller if an IO error occurs.
40619 ** and a page is moved during an incremental vacuum then the page may
40638 ** database file without an entry in the rollback journal that can
40693 ** The solution is to add an in-memory page to the cache containing
40712 ** of an internal error resulting in an automatic call to
40727 ** back as part of a savepoint (or statement) rollback from an
40790 ** If an IO error within this function, an error code is returned. This
40791 ** function allocates memory by calling sqlite3Malloc(). If an allocation
40907 ** If successful, return SQLITE_OK. If an IO error occurs while modifying
41012 ** Each entry in the journal is an instance of the 8th item.
41035 ** If an I/O or malloc() error occurs, the journal-file is not deleted
41036 ** and an error code is returned.
41070 ** TODO: Technically the following is an error because it assumes that
41089 ** pager_playback_one_page() call returns SQLITE_DONE or an IO error
41193 /* If this playback is happening automatically as a result of an IO or
41243 ** If an IO error occurs, then the IO error is returned to the caller.
41283 ** For an encrypted database, the situation is more complex: bytes
41309 ** This is an unconditional update. See also the pager_incr_changecounter()
41338 ** return an SQLite error code. Otherwise, SQLITE_OK.
41497 ** in pages is stored in *pnPage. Otherwise, an error code (perhaps
41515 ** of the database file is not an integer multiple of the page-size,
41554 ** Return SQLITE_OK or an error code.
41557 ** function. Because an EXCLUSIVE lock on the db file is required to delete
41559 ** between the xAccess() below and an xDelete() being executed by some
41763 ** that an inopertune power failure could leave the journal
41780 ** an ordinary commit in NORMAL mode with WAL. FULL means that the WAL
41786 ** using fcntl(F_FULLFSYNC). SQLITE_SYNC_NORMAL means to do an
41872 ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE
41903 ** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).
41912 ** * the database is either not an in-memory database or it is
41913 ** an in-memory database that currently consists of zero pages.
41934 ** At one point this function returned an error if the pager was in
42049 ** the Pager object. There has not been an opportunity to transition
42088 ** Return SQLITE_OK on success and an error code if we cannot obtain
42171 ** an SQLite error code.
42193 ** This function always succeeds. If a transaction is active an attempt
42194 ** is made to roll it back. If an error occurs during the rollback
42215 ** If this is not done, then an unsynced portion of the open journal
42219 ** If an error occurs while trying to sync the journal, shift the pager
42275 ** * If the journal file is an in-memory journal file, no action need
42298 ** page currently held in memory before returning SQLITE_OK. If an IO
42320 /* This block deals with an obscure problem. If the last connection
42416 ** be NULL, representing an empty list. In this case this function is
42421 ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,
42440 ** If everything is successful, SQLITE_OK is returned. If an IO error
42441 ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
42552 ** This function returns SQLITE_OK if everything is successful, an IO
42598 ** (cast as a void*). The pager is always 'purgeable' (not an in-memory
42609 ** SQLITE_OK returned. If an IO error occurs while trying to make the
42629 ** Spilling is also prohibited when in an error state since that could
42720 ** This can be used to implement an in-memory database.
42735 ** the new pager object. If an error occurs, *ppPager is set to NULL
42753 int memDb = 0; /* True if this is an in-memory file */
42766 ** is the maximum space required for an in-memory journal file handle
42778 /* Set the output variable to NULL in case an error occurs. */
42788 /* Compute and store the full pathname in an allocated buffer pointed
42926 ** This branch is also run for an in-memory database. An in-memory
42928 ** disk and uses an in-memory rollback journal.
42945 /* If an error occurred in either of the blocks above, free the
43034 ** exists, that is probably an old journal left over from a prior
43048 ** set to 0 and SQLITE_OK returned. If an IO error occurs while trying
43123 ** its has a zero header, that might be due to an I/O error, or
43128 ** with it under an EXCLUSIVE lock where we do not need to
43151 ** on the database file), then an attempt is made to obtain a
43161 ** then an attempt is made to clear the error state by discarding
43165 ** If everything is successful, SQLITE_OK is returned. If an IO error
43203 /* Get an EXCLUSIVE lock on the database file. At this point it is
43257 ** an inconsistent cache. Sync the hot journal before playing
43274 /* This branch is taken if an error occurs while trying to open
43275 ** or roll back a hot-journal while holding an EXCLUSIVE lock. The
43279 ** UNKNOWN_LOCK above for an explanation).
43316 ** detected. The chance of an undetected change is so small that
43391 ** choose not to allocate a new page object and may reuse an existing
43423 ** an appropriate error code is returned and *ppPage is set to NULL.
43429 ** has to go to disk, and could also playback an old journal if necessary.
43449 /* If the pager is in the error state, return an error immediately.
43458 /* Either the call to sqlite3PcacheFetch() returned an error or the
43468 /* In this case the pcache already contains an initialized copy of
43592 ** an IO error code if opening or writing the journal file fails.
43604 ** an error state. */
43666 ** an EXCLUSIVE lock. If such a lock is already held, no locking
43670 ** within this transaction will be opened as an in-memory file. This
43674 ** sub-journal is implemented in-memory if pPager is an in-memory database,
43688 /* If the pager is configured to use locking_mode=exclusive, and an
43700 ** PAGER_RESERVED state. Otherwise, return an error code to the caller.
43707 ** is true, then immediately upgrade this to an EXCLUSIVE lock. The
43721 ** when it has an open transaction, but never to DBMOD or FINISHED.
43765 /* If an error has been previously detected, report the same error
43781 ** an error might occur and the pager would end up in WRITER_LOCKED state
43799 /* The transaction journal now exists and we have a RESERVED or an
43819 /* Even if an IO or diskfull error occurs while journalling the
43823 ** in the database file. And if an IO error occurs while doing so,
43892 ** If an error occurs, SQLITE_NOMEM or an IO error code is returned
43922 ** an integer power of 2. It sets variable pg1 to the identifier
44029 ** See also the pager_write_changecounter() routine that does an
44040 ** by writing an updated version of page 1 using a call to the
44118 ** function returns SQLITE_OK. Otherwise, an IO error code is returned.
44138 ** Otherwise, if the connection does not already have an EXCLUSIVE lock on
44139 ** the database file, an attempt is made to obtain one.
44143 ** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is
44178 ** passed to an sqlite3PagerCommitPhaseOne() call.
44209 /* If this is an in-memory db, or no pages have been written to, or this
44384 ** If an error occurs, an IO error code is returned and the pager
44430 ** state if an error occurs.
44489 /* If an error occurs during a ROLLBACK, we can no longer trust the pager
44576 ** Return true if this is an in-memory pager.
44588 ** If a memory allocation fails, SQLITE_NOMEM is returned. If an error
44589 ** occurs while opening the sub-journal file, then an IO error code is
44663 ** In any case, all savepoints with an index greater than iSavepoint
44668 ** or an IO error code if an IO error occurs while rolling back a
44695 /* Only truncate if it is an in-memory sub-journal. */
44802 ** This function may return SQLITE_NOMEM or an IO error code if an error
44817 /* In order to be able to rollback, an in-memory database must journal
44878 /* Do not discard pages from an in-memory database since we might
44890 /* For an in-memory database, make sure the original page continues
45016 /* Do allow the journalmode of an in-memory database to be set to
45048 ** here is an optimization only.
45121 ** uses it opaquely as an argument to sqlite3BackupRestart() and
45130 ** Unless this is an in-memory or temporary database, clear the pager cache.
45171 ** Attempt to take an exclusive lock on the database file. If a PENDING lock
45190 ** exclusive-locking mode when this function is called, take an EXCLUSIVE
45210 ** (e.g. due to malloc() failure), return an error code.
45228 ** file (not a temp file or an in-memory database), and the WAL file
45229 ** is not already open, make an attempt to open it now. If successful,
45230 ** return SQLITE_OK. If an error occurs or the VFS used by the pager does
45231 ** not support the xShmXXX() methods, return an error code. *pbOpen is
45272 ** Before closing the log file, this function attempts to take an
45273 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
45299 /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on
45371 ** transferred back into the database file in an operation called a
45423 ** an even number of unsigned 32-bit integers: x[0] through x[N]. The
45486 ** use an architecture-specific format; it does not have to be cross-platform.
45495 ** The wal-index consists of a header region, followed by an one or
45510 ** that allows readers to query an index block for a specific page number.
45511 ** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE
45535 ** prior to finding a match is 1. Each entry of the hash table is an
45536 ** 1-based index of an entry in the mapping section of the same
45550 ** reached) until an unused hash slot is found. Let the first unused slot
45553 ** the search is guaranteed to eventually hit an unused entry. Let
45579 ** slots in the hash table and so the first reader will get an answer as
45683 ** is holding an exclusive lock on WAL_READ_LOCK(K). Thus, the value of
45691 ** largest value and will increase an unused aReadMark[] to mxFrame if there
45692 ** is not already an aReadMark[] equal to mxFrame. The exception to the
45737 ** file are calculated by treating all data as an array of 32-bit
45753 ** An open write-ahead log file is represented by an instance of the
45799 ** an array of HASHTABLE_NSLOT elements of the following type.
45804 ** This structure is used to implement an iterator that loops through
45813 ** walIteratorNext() - Step an iterator,
45814 ** walIteratorFree() - Free an iterator.
45860 ** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,
45861 ** then an SQLite error code is returned and *ppPage is set to 0.
45931 ** Generate or extend an 8 byte checksum based on the data in
46094 ** a part of an ordinary build.
46313 ** Set an entry in the wal-index that will map database page number
46398 ** This routine first tries to establish an exclusive lock on the
46412 /* Obtain an exclusive lock on all byte in the locking range not already
46548 /* If more than one frame was recovered from the log file, report an
46567 ** Close an open wal-index.
46593 ** *ppWal is set to point to a new WAL handle. If an error occurs,
46594 ** an SQLite error code is returned and *ppWal is left unmodified.
46623 /* Allocate an instance of struct Wal to return. */
46847 ** Free an iterator allocated by walIteratorInit().
46859 ** return SQLITE_OK. Otherwise, return an error code. If this routine
46860 ** returns an error, the value of *pp is undefined.
46971 ** in response to an sqlite3_wal_checkpoint() request or the equivalent.
47120 /* If this is an SQLITE_CHECKPOINT_RESTART operation, and the entire wal
47145 ** it to exactly nMax bytes. If an error occurs while doing so, ignore it.
47174 /* If an EXCLUSIVE lock can be obtained on the database file (using the
47253 ** meaning it is possible that an inconsistent snapshot is read
47299 ** Otherwise an SQLite error code.
47307 ** wal-index header) is mapped. Return early if an error occurs here.
47373 ** On success return SQLITE_OK. On a permanent failure (such an
47374 ** I/O error or an SQLITE_BUSY because another process is running
47381 ** wal-index header has changed, *pChanged is set to 1 (as an indication
47389 ** race conditions after multiple WAL_RETRY returns, and after an excessive
47415 ** so it takes care to hold an exclusive lock on the corresponding
47439 ** is more of a scheduler yield than an actual delay. But on the 10th
47440 ** an subsequent retries, the delays start becoming longer and longer,
47533 /* There was once an "if" here. The extra "{" is to preserve indentation. */
47576 ** log-wrap (either of which would require an exclusive lock on
47657 ** in this case as an optimization. Likewise, if pWal->readLock==0,
47666 /* Search the hash table or tables for an entry matching page number
47833 ** Otherwise, if the callback function does not return an error, this
47853 ** (b) has an outstanding reference, then xUndo is either a no-op
47872 ** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32
47887 ** the values in the aWalData[] array. aWalData must point to an array
47927 ** if an error occurs.
48125 ** an out-of-order write following a WAL restart could result in
48380 ** upgrade to exclusive-mode following such an error.
48491 ** bytes are stored on overflow pages. The payload for an entry
48501 ** Each page can be either a btree page, a freelist page, an overflow
48547 ** payload is spilled to overflow pages. Once an overflow page is allocated,
48710 ** As each page of the file is loaded into memory, an instance of the following
48775 ** A database connection contains a pointer to an instance of
48897 #define BTS_EXCLUSIVE 0x0020 /* pWriter has an exclusive lock */
48918 ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
48961 u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */
48987 ** A unrecoverable error (an I/O error or a malloc failure) has occurred
48989 ** cursor. The error has left the cache in an inconsistent state.
49039 ** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
49070 ** within an expression that is an argument to another macro
49392 ** Including a description of file format and an overview of operation.
49413 ** Extract a 2-byte big-endian integer from an array of unsigned bytes.
49477 **** This function is only used as part of an assert() statement. ***
49487 ** When writing to an index that resides in a sharable database, the
49501 int isIndex, /* True if iRoot is the root of an index b-tree */
49518 /* If the client is reading or writing an index and the schema is
49608 /* If requesting a write-lock, then the Btree must have an open write
49610 ** must be an open write transaction on the file itself.
49620 /* If some other connection is holding an exclusive lock, the
49691 /* First search the list for an existing lock on this table. */
49731 ** This function assumes that Btree p has an open read or write
49870 ** The BtShared.pHasContent bitvec exists to work around an obscure
49953 /* If this is an intKey table, then the above call to BtreeKeySize()
49955 ** all that is required. Otherwise, if pCur is not open on an intKey
50026 const void *pKey, /* Packed key if the btree is an index */
50087 ** This routine returns an error code if something goes wrong. The
50131 ** Write an entry into the pointer map.
50137 ** a no-op. If an error occurs, the appropriate error code is written
50186 ** Read an entry from the pointer map.
50316 ** way will result in an incompatible file format.
50359 ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of
50416 ** to an overflow page, insert an entry into the pointer-map
50520 ** an error code (usually SQLITE_CORRUPT).
50975 ** If an error occurs, then the value *ppPage is set to is undefined. It
50976 ** may remain unchanged, or it may be set to an invalid value.
51034 /* pPage might not be a btree page; it might be an overflow page
51059 ** then an ephemeral database is created. The ephemeral database might
51064 ** If zFilename is ":memory:" then an in-memory database is created
51071 ** and we are in shared cache mode, then the open will fail with an
51091 /* True if opening an ephemeral, temporary database */
51094 /* Set the variable isMemdb to true for an in-memory database, or
51134 ** If this Btree is a candidate for shared cache, try to find an
51235 /* If the magic name ":memory:" will create an in-memory database, then
51326 ** default value. Except, when opening on an existing shared pager-cache,
51381 ** Make sure pBt->pTmpSpace points to an allocation of
51399 ** Close an open database and invalidate all cursors.
51466 ** an abrupt power failure when synchronous is off, the database
51467 ** could be left in an inconsistent and unrecoverable state.
51800 ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow
51844 ** If pBt points to an empty file then convert that empty file
51908 ** If an initial attempt to acquire the lock fails because of lock contention
52029 /* If the db-size header field is incorrect (as it may be if an old
52110 ** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow
52113 ** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next
52207 ** If pDbPage is an overflow page, then the first 4 bytes may store a
52253 ** Perform a single step of an incremental-vacuum. If successful,
52263 ** it returns SQLITE_DONE or an error, and that nFin is the
52373 ** It performs a single unit of work towards an incremental vacuum.
52377 ** SQLITE_OK is returned. Otherwise an SQLite error code.
52401 ** is commited for an auto-vacuum database.
52564 ** Normally, if an error occurs while the pager layer is attempting to
52565 ** finalize the underlying journal file, this function returns an error and
52570 ** functions return code. So, even if an error occurs in the pager layer,
52678 ** in an error.
52739 ** A statement sub-transaction is implemented as an anonymous savepoint. The
52756 ** an index greater than all savepoints created explicitly using
52807 ** the caller is assumed to have an open write transaction.
52825 ** 4: There must be an active transaction.
52927 ** The cache is initialized to zero, indicating an invalid cache.
53075 ** to return an integer result code for historical reasons.
53086 ** Given the page number of an overflow page in the database (parameter
53091 ** If an error occurs an SQLite error code is returned. Otherwise:
53170 ** SQLITE_OK is returned on success, otherwise an error code.
53212 ** Once an overflow page-list cache has been allocated, it may be
53215 ** mode, the following events may invalidate an overflow page-list cache.
53219 ** * Creating a table (may require moving an overflow page).
53247 /* Trying to read or write past the end of the data is an error */
53395 ** Return SQLITE_OK on success or an error code if anything goes
53412 ** Return SQLITE_OK on success or an error code if anything goes
53444 ** This routine is an optimization. It is common for the entire key
53533 ** if an intkey page appears to be the parent of a non-intkey page, or
53564 ** Page pParent is an internal (non-leaf) tree page. This function
53634 ** structure the flags byte is set to 0x02 or 0x0A, indicating an index
53673 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
53675 ** return an SQLITE_CORRUPT error. */
53824 /* Move the cursor so that it points to an entry near the key
53831 ** If an exact match is not found, then the cursor is always
53833 ** were present. The cursor might point to an entry that comes
53841 ** *pRes<0 The cursor is left pointing at an entry that
53845 ** *pRes==0 The cursor is left pointing at an entry that
53848 ** *pRes>0 The cursor is left pointing at an entry that
53940 ** the maximum number of record bytes stored on an index B-Tree
54034 ** Return TRUE if the cursor is not pointing at an entry of the table.
54042 ** have been deleted? This API will need to change to return an error code
54192 ** an error. *ppPage and *pPgno are undefined in the event of an error.
54193 ** Do not invoke sqlite3PagerUnref() on *ppPage if an error is returned.
54196 ** locate a page close to the page number "nearby". This can be used in an
54522 /* If the database supports auto-vacuum, write an entry in the pointer-map
54641 /* 0 is not a legal page number and page 1 cannot be an
54654 /* There is no reason any cursor should have an outstanding reference
54655 ** to an overflow page belonging to a cell that is being deleted/updated.
54657 ** must not really be an overflow page and the database must be corrupt.
54768 ** overflow page is being allocated, add an entry to the pointer-map
54902 ** nSkip is non-zero, then pCell may not point to an invalid memory location
54933 ** malformed cell from a leaf page to an interior page, if the cell size
54984 /* The cell may contain a pointer to an overflow page. If so, write
55106 /* If this is an auto-vacuum database, update the pointer map
55108 ** cell on the page to an overflow page. If either of these
55112 ** be marked as dirty. Returning an error code will cause a
55247 /* If this is an auto-vacuum database, update the pointer-map entries
55267 ** one or two in an effort to keep pages nearly full but not over full.
55289 ** size of a cell stored within an internal node is always less than 1/4
55570 ** This adjustment is more than an optimization. The packing above might
55748 ** Note that this can never happen in an SQLite data file, as all
55783 ** If this is an auto-vacuum database, the call to copyNodeContent()
55840 ** sibling page j. If the siblings are not leaf pages of an
55864 ** sibling page k. If the siblings are not leaf pages of an
55873 ** an overflow cell, or if the cell was located on a different sibling
55897 ** cause an assert() statement to fail. */
55929 ** page is then overwritten to make it an empty page with the right-child
55939 ** to call releasePage() on *ppChild exactly once. If an error occurs,
55940 ** an error code is returned and *ppChild is set to 0.
56118 ** For an INTKEY table, only the nKey value of the key is used. pKey is
56124 ** number if pCur points at an entry that is smaller than (pKey, nKey), or
56125 ** a positive value if pCur points at an etry that is larger than
56139 int appendBias, /* True if this is likely an append */
56163 ** expecting an index b-tree, then the caller should be inserting blob
56164 ** keys with no associated data. If the cursor was opened expecting an
56169 /* If this is an insert into a table b-tree, invalidate any incrblob
56235 /* If no error has occured and pPage has an overflow cell, call balance()
56247 ** multiple records into an intkey b-tree using a single cursor (as can
56248 ** happen while processing an "INSERT INTO ... SELECT" statement), it
56251 ** entry in the table, and the next row inserted has an integer key
56338 ** by the child-page of the cell that was just deleted from an internal
56365 ** Otherwise, if the entry deleted was on an internal node page, then
56421 /* Creating a new table may probably require moving an existing database
56423 ** out to be an overflow page, delete all overflow page-map caches
56455 ** the new table (assuming an error did not occur). But we were
56601 ** If pnChange is not NULL, then table iTable must be an intkey table. The
56655 ** root page. If an open cursor was using this page a problem would
56780 /* If auto-vacuum is disabled in this build and this is an auto-vacuum
56825 ** Otherwise, if an error is encountered (i.e. an IO error or database
56826 ** corruption) an SQLite error code is returned.
56838 /* Unless an error occurs, the following loop runs one iteration for each
56845 /* If this is a leaf page or the tree is not an int-key tree, then
56889 /* An error has occurred. Return an error code. */
56934 ** reference to the page, add an error message to pCheck->zErrMsg.
56956 ** page iParent, pointer type ptrType. If not, append an error message
56986 ** Check the integrity of the freelist or of an overflow page list.
57288 ** an array of pages numbers were each page number is the root page of
57295 ** allocation errors, an error message held in memory obtained from
57380 ** This is an internal consistency check; an integrity check
57441 ** Return SQLITE_LOCKED if this or any other connection has an open
57510 ** btree as the argument handle holds an exclusive lock on the
57551 ** Argument pCsr must be a cursor opened for writing on an
57580 ** (e) the cursor points at a valid row of an intKey table.
57729 ** a NULL pointer and write an error message to pErrorDb.
57732 ** function. If an error occurs while doing so, return 0 and write an
57778 ** Create an sqlite3_backup process to copy the contents of zSrcDb from
57782 ** If an error occurs, NULL is returned and an error code and error message
57831 /* One (or both) of the named databases did not exist or an OOM
57850 ** Argument rc is an SQLite error code. Return true if this error is
57882 /* Catch the case where the destination is an in-memory database and the
57945 ** Return SQLITE_OK if everything is successful, or an SQLite error
57946 ** code if an error occurs.
58189 ** Release all resources associated with an sqlite3_backup* handle.
58291 ** detects that the database has been modified by an external database
58333 /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set
58347 ** within a single call (unless an error occurs). The assert() statement
58349 ** or an error code.
58383 ** stores a single value in the VDBE. Mem is an opaque structure visible
58389 ** If pMem is an object with a valid string representation, this routine
58506 ** If the given Mem* has a zero-filled tail, turn it into an ordinary
58563 ** user and the later is an internal programming error.
58602 ** Memory cell pMem contains the context of an aggregate function.
58606 ** Return SQLITE_ERROR if the finalizer reports an error. SQLITE_OK
58631 ** invoking an external callback, free it now. Calling this function
58653 ** Release any memory held by the Mem. This may leave the Mem in an
58671 ** there are reports that windows throws an expection
58696 ** a very large positive number to an integer results in a very large
58708 ** at representing the value that *pMem describes as an integer.
58709 ** If pMem is an integer, then the value is exact. If pMem is
58711 ** If pMem is a string or blob, then we make an attempt to convert
58712 ** it into a integer and return that. If pMem represents an
58713 ** an SQL-NULL value, return 0.
58739 ** double. If pMem is already a double or an integer, return its
58773 /* Only mark the value as an integer if
58915 ** Delete any previous value and set the value of pMem to be an
58979 ** Make an shallow copy of pFrom into pTo. Prior contents of
59022 ** pFrom contains an SQL NULL when this routine returns.
59065 /* If z is a NULL pointer, set pMem to contain an SQL NULL. */
59261 ** to read from the disk) then the pMem is left in an inconsistent state.
59317 ** If that is the case, then the result must be aligned on an even byte
59487 ** Change the string value of an sqlite3_value object
59500 ** Free an sqlite3_value object
59538 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
59629 ** If an out-of-memory error occurs while resizing the array, return
59657 ** Use the sqlite3VdbeResolveLabel() function to fix an address and
59704 ** Add an opcode that includes the p4 value as a pointer.
59721 ** Add an OP_ParseSchema opcode. This routine is broken out from
59736 ** Add an opcode that includes the p4 value as an integer.
59744 int p4 /* The P4 operand as an integer */
59752 ** Create a new symbolic label for an instruction that has yet to be
59754 ** label can be used as the P2 value of an operation. Later, when
59871 ** throw an ABORT exception (causing the statement, but not entire transaction
59882 ** Then check that the value of Parse.mayAbort is true if an
59885 ** part of an assert statement in the compiler. Similar to:
59928 ** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by
60252 /* Note: this cast is safe, because the origin data point was an int
60348 ** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as
60376 ** Compute a string that describes the P4 parameter for an opcode.
60504 ** that may be accessed by the VM passed as an argument. In doing so it also
60585 ** Release an array of N Mem elements
60601 /* This block is really an inlined version of sqlite3VdbeMemRelease()
60697 ** commandeer the 9th cell to use as storage for an array of pointers
60754 /* When an OP_Program opcode is encounter (the only opcode that has
60860 ** Print an IOTRACE message showing SQL content.
60980 ** the Vdbe becomes an independent entity and the Parse object can be
61026 ** an array to marshal SQL function arguments in.
61206 ** be called on an SQL statement before sqlite3_step().
61266 int nTrans = 0; /* Number of databases with an active write-transaction */
61280 ** required, as an xSync() callback may add an attached database
61288 ** one database file has an open write transaction, a master journal
61289 ** file is required for an atomic commit.
61331 ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
61400 ** master journal file. If an error occurs at this point close
61442 ** an error occurs here, do not delete the master journal file.
61479 ** may be lying around. Returning an error code won't help matters.
61503 ** This is an internal self-check only - it is not an essential processing
61535 ** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned.
61544 ** is that an IO error may have occured, causing an emergency rollback.
61594 ** handle associated with the VM passed as an argument is about to be
61600 ** an error message to it. Then return SQLITE_ERROR.
61624 ** Return an error code. If the commit could not complete because of
61643 ** Then the internal cache might have been left in an inconsistent
61681 ** file as part of an effort to free up cache space (see function
61724 ** or hit an 'OR FAIL' constraint and there are no deferred foreign
61757 ** do so. If this operation returns an error, and the current statement
61775 /* If this was an INSERT, UPDATE or DELETE and no statement transaction
61865 /* If the VM did not run to completion or if it encountered an
61925 ** Clean up and delete a VDBE after execution. Return an integer which is
61988 ** Delete an entire VDBE.
62011 ** was last positioned. Return an error code if an OOM fault or I/O error
62062 ** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned
62065 ** In an SQLite index record, the serial type is stored directly before
62150 ** If we are on an architecture with mixed-endian floating
62157 ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems
62165 ** Developers using SQLite on an ARM7 should compile and run their
62364 ** This routine is used to allocate sufficient space for an UnpackedRecord
62375 ** If an OOM error occurs, NULL is returned.
62563 ** pCur points at an index entry created using the OP_MakeRecord opcode.
62565 ** Return SQLITE_OK if everything works, or an error code otherwise.
62605 /* The last field of the index should be an integer - the ROWID.
62606 ** Verify that the last entry really is an integer. */
62705 ** sequences, or changing an authorization function are the types of
62723 ** Return a pointer to an sqlite3_value structure containing the value bound
62724 ** parameter iVar of VM v. Except, if the value is an SQL NULL, return
62781 ** Return TRUE (non-zero) of the statement supplied as an argument needs
62785 ** collating sequences are registered or if an authorizer function is
62796 ** an error and return true if it has been finalized (or is otherwise
62818 ** the sqlite3_compile() routine. The integer returned is an SQLITE_
62850 ** Terminate the current execution of an SQL statement and reset it
63055 /* Force an SQLITE_TOOBIG error. */
63094 ** statement is completely executed or an error occurs.
63111 ** This "automatic-reset" change is not technically an incompatibility,
63112 ** since any application that receives an SQLITE_MISUSE is broken by
63213 /* If this statement was prepared using sqlite3_prepare_v2(), and an
63254 /* This case occurs after failing to recompile an sql statement.
63302 ** The following is the implementation of an SQL function that always
63303 ** fails with an error message stating that the function is used in the
63462 ** value SQL NULL. Even though the Mem structure contains an element
63465 ** instead of an 8-byte one. This all works fine, except that when
63467 ** that a Mem structure is located on an 8-byte boundary. To prevent
63491 ** This function is called after invoking an sqlite3_value_XXX function on a
63492 ** column value (i.e. a value returned by evaluating an SQL expression in the
63510 /* If malloc() failed during an encoding conversion within an
63608 ** If the result is not a simple column reference (if it is an expression
63685 ** NULL is returned if the result column is an expression or constant or
63686 ** anything else which is not an unabiguous reference to a database column.
63701 ** NULL is returned if the result column is an expression or constant or
63702 ** anything else which is not an unabiguous reference to a database column.
63717 ** NULL is returned if the result column is an expression or constant or
63718 ** anything else which is not an unabiguous reference to a database column.
63824 ** Bind a blob value to an SQL statement variable.
64003 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
64367 ** In the external interface, an "sqlite3_stmt*" is an opaque pointer
64373 ** a linear sequence of operations. Each operation has an opcode
64375 ** is a null-terminated string. Operand P5 is an unsigned character.
64380 ** either an integer, a null-terminated string, a floating point
64421 ** field of the sqlite3 structure is set in order to simulate an interrupt.
64424 ** in an ordinary build.
64493 ** This routine converts an ephemeral string into a dynamically allocated
64495 ** converts an MEM_Ephem string into an MEM_Dyn string.
64621 ** Try to convert pRec to an integer representation or a
64622 ** floating-point representation if an integer representation
64625 ** an integer representation is more space efficient on disk.
64639 /* Only attempt the conversion to TEXT if there is an integer or real
64920 ** This function is only called from within an assert() expression. It
64939 ** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
64963 ** If an attempt is made to open a locked database, then this routine
64967 ** If an error occurs, an error message is written to memory obtained
64991 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
65107 } an;
65221 int res; /* Result of an sqlite3BtreeLast() */
65484 /* Check to see if we need to simulate an interrupt. This only happens
65519 ** an undefined integer. Opcodes will either fill in the integer
65579 ** opcode and the opcodes.c file is filled with an array of strings where
65685 ** If P4 is not null then it is an error message string.
65687 ** There is an implied "Halt 0 0 0" instruction inserted at the very end of
65704 ** an IGNORE exception. In this case jump to the address specified
65774 ** into an OP_String before it is executed for the first time.
65884 ** left holding a NULL. It is an error for register ranges
65969 ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
66016 ** and have an assigned type. The results are de-ephemeralized as
66315 ** user function may have called an sqlite3_result_XXX() function
66323 /* If the function returned an error, throw an exception */
66432 ** The result is always an integer.
66434 ** To force any register to be an integer, just add 0.
66446 ** Force the value in register P1 to be an integer. If the value
66447 ** in P1 is not an integer and cannot be converted into an integer
66449 ** raise an SQLITE_MISMATCH exception.
66470 ** If register P1 holds an integer convert it to a real value.
66535 ** Force the value in register P1 to be numeric (either an
66537 ** If the value is text or blob, try to convert it to an using the
66552 ** Force the value in register P1 to be an integer. If
66554 ** If the value is text or blob, try to convert it to an integer using the
66571 ** If The value is currently an integer, convert it.
66572 ** If the value is text or blob, try to convert it to an integer using the
66596 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
66906 ** Interpret the content of register P1 as an integer. Store the
67016 #if 0 /* local variables moved into u.an */
67040 #endif /* local variables moved into u.an */
67043 u.an.p1 = pOp->p1;
67044 u.an.p2 = pOp->p2;
67045 u.an.pC = 0;
67046 memset(&u.an.sMem, 0, sizeof(u.an.sMem));
67047 assert( u.an.p1<p->nCursor );
67049 u.an.pDest = &aMem[pOp->p3];
67050 memAboutToChange(p, u.an.pDest);
67051 u.an.zRec = 0;
67053 /* This block sets the variable u.an.payloadSize to be the total number of
67056 ** u.an.zRec is set to be the complete text of the record if it is available.
67059 ** might be available in the u.an.pC->aRow cache. Or it might not be.
67060 ** If the data is unavailable, u.an.zRec is set to NULL.
67065 u.an.pC = p->apCsr[u.an.p1];
67066 assert( u.an.pC!=0 );
67068 assert( u.an.pC->pVtabCursor==0 );
67070 u.an.pCrsr = u.an.pC->pCursor;
67071 if( u.an.pCrsr!=0 ){
67073 rc = sqlite3VdbeCursorMoveto(u.an.pC);
67075 if( u.an.pC->nullRow ){
67076 u.an.payloadSize = 0;
67077 }else if( u.an.pC->cacheStatus==p->cacheCtr ){
67078 u.an.payloadSize = u.an.pC->payloadSize;
67079 u.an.zRec = (char*)u.an.pC->aRow;
67080 }else if( u.an.pC->isIndex ){
67081 assert( sqlite3BtreeCursorIsValid(u.an.pCrsr) );
67082 VVA_ONLY(rc =) sqlite3BtreeKeySize(u.an.pCrsr, &u.an.payloadSize64);
67085 ** payload size, so it is impossible for u.an.payloadSize64 to be
67087 assert( (u.an.payloadSize64 & SQLITE_MAX_U32)==(u64)u.an.payloadSize64 );
67088 u.an.payloadSize = (u32)u.an.payloadSize64;
67090 assert( sqlite3BtreeCursorIsValid(u.an.pCrsr) );
67091 VVA_ONLY(rc =) sqlite3BtreeDataSize(u.an.pCrsr, &u.an.payloadSize);
67094 }else if( ALWAYS(u.an.pC->pseudoTableReg>0) ){
67095 u.an.pReg = &aMem[u.an.pC->pseudoTableReg];
67096 assert( u.an.pReg->flags & MEM_Blob );
67097 assert( memIsValid(u.an.pReg) );
67098 u.an.payloadSize = u.an.pReg->n;
67099 u.an.zRec = u.an.pReg->z;
67100 u.an.pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr;
67101 assert( u.an.payloadSize==0 || u.an.zRec!=0 );
67104 u.an.payloadSize = 0;
67107 /* If u.an.payloadSize is 0, then just store a NULL. This can happen because of
67109 if( u.an.payloadSize==0 ){
67110 MemSetTypeFlag(u.an.pDest, MEM_Null);
67114 if( u.an.payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
67118 u.an.nField = u.an.pC->nField;
67119 assert( u.an.p2<u.an.nField );
67124 u.an.aType = u.an.pC->aType;
67125 if( u.an.pC->cacheStatus==p->cacheCtr ){
67126 u.an.aOffset = u.an.pC->aOffset;
67128 assert(u.an.aType);
67129 u.an.avail = 0;
67130 u.an.pC->aOffset = u.an.aOffset = &u.an.aType[u.an.nField];
67131 u.an.pC->payloadSize = u.an.payloadSize;
67132 u.an.pC->cacheStatus = p->cacheCtr;
67135 if( u.an.zRec ){
67136 u.an.zData = u.an.zRec;
67138 if( u.an.pC->isIndex ){
67139 u.an.zData = (char*)sqlite3BtreeKeyFetch(u.an.pCrsr, &u.an.avail);
67141 u.an.zData = (char*)sqlite3BtreeDataFetch(u.an.pCrsr, &u.an.avail);
67144 ** save the payload in the u.an.pC->aRow cache. That will save us from
67148 assert( u.an.avail>=0 );
67149 if( u.an.payloadSize <= (u32)u.an.avail ){
67150 u.an.zRec = u.an.zData;
67151 u.an.pC->aRow = (u8*)u.an.zData;
67153 u.an.pC->aRow = 0;
67158 ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
67159 u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
67161 /* Make sure a corrupt database has not given us an oversize header.
67162 ** Do this now to avoid an oversize memory allocation.
67170 if( u.an.offset > 98307 ){
67175 /* Compute in u.an.len the number of bytes of data we need to read in order
67176 ** to get u.an.nField type values. u.an.offset is an upper bound on this. But
67177 ** u.an.nField might be significantly less than the true number of columns
67178 ** in the table, and in that case, 5*u.an.nField+3 might be smaller than u.an.offset.
67179 ** We want to minimize u.an.len in order to limit the size of the memory
67180 ** allocation, especially if a corrupt database file has caused u.an.offset
67183 ** On systems that cannot tolerate large memory allocations, u.an.nField*5+3
67184 ** will likely be much smaller since u.an.nField will likely be less than
67188 u.an.len = u.an.nField*5 + 3;
67189 if( u.an.len > (int)u.an.offset ) u.an.len = (int)u.an.offset;
67197 if( !u.an.zRec && u.an.avail<u.an.len ){
67198 u.an.sMem.flags = 0;
67199 u.an.sMem.db = 0;
67200 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, 0, u.an.len, u.an.pC->isIndex, &u.an.sMem);
67204 u.an.zData = u.an.sMem.z;
67206 u.an.zEndHdr = (u8 *)&u.an.zData[u.an.len];
67207 u.an.zIdx = (u8 *)&u.an.zData[u.an.szHdr];
67209 /* Scan the header and use it to fill in the u.an.aType[] and u.an.aOffset[]
67210 ** arrays. u.an.aType[u.an.i] will contain the type integer for the u.an.i-th
67211 ** column and u.an.aOffset[u.an.i] will contain the u.an.offset from the beginning
67212 ** of the record to the start of the data for the u.an.i-th column
67214 for(u.an.i=0; u.an.i<u.an.nField; u.an.i++){
67215 if( u.an.zIdx<u.an.zEndHdr ){
67216 u.an.aOffset[u.an.i] = u.an.offset;
67217 if( u.an.zIdx[0]<0x80 ){
67218 u.an.t = u.an.zIdx[0];
67219 u.an.zIdx++;
67221 u.an.zIdx += sqlite3GetVarint32(u.an.zIdx, &u.an.t);
67223 u.an.aType[u.an.i] = u.an.t;
67224 u.an.szField = sqlite3VdbeSerialTypeLen(u.an.t);
67225 u.an.offset += u.an.szField;
67226 if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
67227 u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
67231 /* If u.an.i is less that u.an.nField, then there are less fields in this
67233 ** table. Set the u.an.offset for any extra columns not present in
67237 u.an.aOffset[u.an.i] = 0;
67240 sqlite3VdbeMemRelease(&u.an.sMem);
67241 u.an.sMem.flags = MEM_Null;
67249 if( (u.an.zIdx > u.an.zEndHdr) || (u.an.offset > u.an.payloadSize)
67250 || (u.an.zIdx==u.an.zEndHdr && u.an.offset!=u.an.payloadSize) ){
67256 /* Get the column information. If u.an.aOffset[u.an.p2] is non-zero, then
67257 ** deserialize the value from the record. If u.an.aOffset[u.an.p2] is zero,
67262 if( u.an.aOffset[u.an.p2] ){
67264 if( u.an.zRec ){
67265 VdbeMemRelease(u.an.pDest);
67266 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67268 u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67269 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67270 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
67274 u.an.zData = u.an.sMem.z;
67275 sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest);
67277 u.an.pDest->enc = encoding;
67280 sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
67282 MemSetTypeFlag(u.an.pDest, MEM_Null);
67288 ** dynamically allocated space over to the u.an.pDest structure.
67291 if( u.an.sMem.zMalloc ){
67292 assert( u.an.sMem.z==u.an.sMem.zMalloc );
67293 assert( !(u.an.pDest->flags & MEM_Dyn) );
67294 assert( !(u.an.pDest->flags & (MEM_Blob|MEM_Str)) || u.an.pDest->z==u.an.sMem.z );
67295 u.an.pDest->flags &= ~(MEM_Ephem|MEM_Static);
67296 u.an.pDest->flags |= MEM_Term;
67297 u.an.pDest->z = u.an.sMem.z;
67298 u.an.pDest->zMalloc = u.an.sMem.zMalloc;
67301 rc = sqlite3VdbeMemMakeWriteable(u.an.pDest);
67304 UPDATE_MAX_BLOBSIZE(u.an.pDest);
67305 REGISTER_TRACE(pOp->p3, u.an.pDest);
67341 ** in an index. The OP_Column opcode can decode the record later.
67473 ** Store the number of entries (an integer value) in the table or index
67497 ** on the value of P1. To open a new savepoint, P1==0. To release (commit) an
67498 ** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.
67569 /* Find the named savepoint. If there is no such savepoint, then an
67570 ** an error is returned to the user. */
67687 ** still running, and a transaction is active, return an error indicating
67697 ** return an error indicating that the other VMs must complete first.
67741 ** transaction might also be rolled back if an error is encountered.
67753 ** database. If P2 is 2 or greater then an EXCLUSIVE lock is also obtained
67758 ** throw an ABORT exception), a statement transaction may also be opened.
67762 ** VDBE to be rolled back after an error without having to roll back the
67821 ** must be started or there must be an open cursor) before
67845 ** Write the content of register P3 (interpreted as an integer)
67898 ** Either a transaction needs to have been started or an OP_Open needs
67926 ** If virtual-tables are in use, this is not just an optimization.
67951 ** database. Give the new cursor an identifier of P1. The P1
67953 ** It is an error for P1 to be negative.
67958 ** There will be a read lock on the database whenever there is an
67964 ** to get a read lock but fails, the script terminates with an
67967 ** The P4 value may be either an integer (P4_INT32) or a pointer to
67970 ** sequence of the index being opened. Otherwise, if P4 is an integer
67981 ** The P4 value may be either an integer (P4_INT32) or a pointer to
67984 ** sequence of the index being opened. Otherwise, if P4 is an integer
68130 ** automatically created table with root-page 1 (an BLOB_INTKEY table).
68158 ** tables using an external merge-sort algorithm.
68182 ** register P2. In other words, cursor P1 becomes an alias for the
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.
68261 ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
68263 ** to an SQL index, then P3 is the first in an array of P4 registers
68264 ** that are used as an unpacked index key.
68299 ** blob, or NULL. But it needs to be an integer before we can do
68306 /* If the P3 value could not be converted into an integer without
68320 /* The P3 value is too large in magnitude to be expressed as an
68428 ** P1 is an open table cursor and P2 is a rowid integer. Arrange
68458 ** P4>0 then register P3 is the first of P4 registers that form an unpacked
68461 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
68468 ** P4>0 then register P3 is the first of P4 registers that form an unpacked
68471 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
68473 ** does contain an entry whose prefix matches the P3/P4 record then control
68544 ** Cursor P1 is open on an index b-tree - that is to say, a btree which
68549 ** The P3 register contains an integer record number. Call this record
68551 ** that make up an unpacked index key that can be used with cursor P1.
68559 ** Otherwise, this instruction checks if cursor P1 contains an entry
68633 ** Use the content of register P3 as an integer key. If a record
68639 ** operation assumes the key is an integer and that P1 is a table whereas
68641 ** P1 is an index.
68676 /* This happens when an attempt to open a read cursor on the
68711 ** an SQLITE_FULL error is generated. The P3 register is updated with the '
68719 int res; /* Result of an sqlite3BtreeLast() */
68798 assert( (u.bg.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
68818 ** an AUTOINCREMENT table. */
68854 ** Write an entry into the table of cursor P1. A new entry is
68855 ** created if it doesn't already exist or the data for an existing
68870 ** has already positioned the cursor correctly. This is an optimization
68873 ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
68875 ** is part of an INSERT operation. The difference is only important to
68973 ** a record from within an Next loop.
69007 /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or
69175 ** Store in register P2 an integer which is the key of the table entry that
69178 ** P1 can be either an ordinary table or a virtual table. There used to
69282 ** it increments an undocumented global variable used for testing.
69419 ** Register P2 holds an SQL index key made using the
69424 ** insert is likely to be an append.
69471 ** an unpacked index key. This opcode removes that entry from the
69508 ** Write into register P2 an integer which is the last entry in the record at
69545 ** The P4 register values beginning with P3 form an unpacked index
69552 ** If P5 is non-zero then the key value is increased by an epsilon
69559 ** The P4 register values beginning with P3 form an unpacked index
69566 ** If P5 is non-zero then the key value is increased by an epsilon prior
69612 ** Delete an entire database table or index whose root page in the database
69680 ** If the P3 value is non-zero, then the table referred to must be an
69681 ** intkey table (an SQL table, not an index). In this case the row change
69712 ** auxiliary database file if P1==1 or in an attached database if
69716 ** The difference between a table and an index is this: A table must
69718 ** has an arbitrary key but no data.
69725 ** auxiliary database file if P1==1 or in an attached database if
69841 ** the index named P4 in database P1. This is called after an index
69866 ** Do an analysis of the currently open database. Store in
69867 ** register P1 the text of an error message describing any problems.
69932 ** An assertion fails if P2 is not an integer.
70006 ** delete it now and initialize P1 with an empty rowset
70038 ** cell in an array of values used as arguments to the sub-program. P2
70039 ** contains the address to jump to if the sub-program throws an IGNORE
70225 ** This instruction throws an error if the memory cell is not initially
70226 ** an integer.
70255 ** not contain an integer. An assertion fault will result if you try.
70271 ** not contain an integer. An assertion fault will result if you try.
70284 ** The register P1 must contain an integer. Add literal P3 to the
70288 ** not contain an integer. An assertion fault will result if you try.
70302 ** Execute the step function for an aggregate. The
70367 ** Execute the finalizer function for an aggregate. P1 is
70405 ** completes into mem[P3+2]. However on an error, mem[P3+1] and
70508 ** as an intermediate */
70578 ** fails with an error code of SQLITE_SCHEMA if it is ever executed
70606 ** used to generate an error message if the lock cannot be obtained.
70628 ** P4 may be a pointer to an sqlite3_vtab structure. If so, call the
70675 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70715 ** P1 is a cursor opened using VOpen. P2 is an address to jump to if
70832 ** do this regardless of whether or not an error occurred to ensure any
70873 ** underlying implementation to return an error if one occurs during
70874 ** xNext(). Instead, if an error occurs, true is returned (indicating that
70897 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70929 ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
70935 ** The xUpdate method will do a DELETE or an INSERT or both.
71126 ** an error of some kind.
71228 ** If an error occurs, or if the specified row does not exist or does not
71230 ** blob handle was opened, then an error code is returned and *pzErr may
71231 ** be set to point to a buffer containing an error message. It is the
71235 ** If an error does occur, then the b-tree cursor is closed. All subsequent
71312 ** After seeking the cursor, the vdbe executes an OP_ResultRow.
71326 /* One of the following two instructions is replaced by an OP_Noop. */
71407 /* Check that the column is not part of an FK child key definition. It
71479 ** always return an SQL NULL. This is useful because it means
71616 ** Move an existing blob handle to point to a different row of the same
71619 ** If an error occurs, or if the specified row does not exist or does not
71620 ** contain a blob or text value, then an error code is returned and the
71694 ** The aIter[] array contains an iterator for each of the PMAs being merged.
71767 ** The following type is an iterator for a PMA. It caches the current key in
71808 ** no error occurs, or an SQLite error code if one does.
71826 /* This is an EOF condition */
71860 ** SQLITE_OK if successful, or an SQLite error code if some error occurs.
71884 ** successful, or an SQLite error code if some error occurs.
71890 ** set to the integer value read. If an error occurs, the final values of
71949 ** used by the comparison. If an error occurs, return an SQLite error code.
71959 ** has been allocated and contains an unpacked record that is used as key2.
72107 ** Otherwise, set *ppFile to 0 and return an SQLite error code.
72154 ** if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if an error
72193 ** SQLITE_OK if successful, or an SQLite error code otherwise.
72243 /* This assert verifies that unless an error has occurred, the size of
72388 ** initialize an iterator for each of them and break out of the loop.
72520 ** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).
72560 ** the caller specifies a buffer size for an in-memory buffer to
72573 ** as an open file handle for journal files.
72794 ** This file contains code use to implement an in-memory rollback journal.
72839 ** is an instance of this class.
72974 ** Syncing an in-memory journal is a no-op. And, in fact, this routine
73027 ** Return true if the file-handle passed as an argument is
73028 ** an in-memory journal
73055 ** an SQL statement.
73062 ** Walk an expression tree. Invoke the callback once for each node
73101 ** an abort request is seen.
73160 ** there is an abort request.
73162 ** If the Walker does not have an xSelectCallback() then this routine
73201 ** Turn the pExpr expression into an alias for the iCol-th column of the
73205 ** makes an exact copy. But for any other kind of expression, this
73231 Expr *pExpr, /* Transform this into an alias to the result set */
73322 ** If the name cannot be resolved unambiguously, leave an error message
73474 ** might refer to an result-set alias. This happens, for example, when
73532 ** more matches. Either way, we have an error.
73590 ** Allocate and return a pointer to an expression to load the column iCol
73702 int is_agg = 0; /* True if is an aggregate function */
73797 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
73800 ** this routine return an integer between 1 and N where N is the number of
73829 ** pE is a pointer to an expression which is a single term in the
73834 ** ORDER BY term is not an integer index into the result set. That
73839 ** as an indication to the caller that it should sort by the i-th column.
73844 ** If there is no match, return 0. Return -1 if an error occurs.
73876 /* Try to match the ORDER BY expression against an expression
73877 ** in the result set. Return an 1-based index of the matching
73891 ** Generate an ORDER BY or GROUP BY term out-of-range error.
73909 ** ORDER BY terms that are already an integer between 1 and N are
73911 ** 1 through N generate an error. ORDER BY terms that are expressions
74006 ** If any errors are detected, add an error message to pParse and
74042 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
74046 ** This routine resolves each term of the clause into an expression.
74047 ** If the order-by term is an integer I between 1 and N (where N is the
74050 ** the order-by term is an identify that corresponds to the AS-name of
74056 ** an appropriate error message might be left in pParse. (OOM errors
74078 /* If an AS-name match is found, mark this ORDER BY column as being
74086 /* The ORDER BY term is an integer constant. Again, set the column
74097 /* Otherwise, treat the ORDER BY term as an ordinary expression */
74132 ** an expression, sqlite3ResolveExprNames() will be called without a
74152 ** are not allowed to refer to any names, so pass an empty NameContext.
74291 ** This routine walks an expression tree and resolves references to
74300 ** the symbolic name assigned to an ATTACH-ed database.
74317 ** size of an AS clause in the result-set of a SELECT. The Z expression
74330 ** If the function is an aggregate function, then the pNC->hasAgg is
74332 ** If an expression contains aggregate functions then the EP_Agg
74424 ** If pExpr is a column, a reference to a column via an 'AS' alias,
74430 ** have an affinity:
74463 ** Set the explicit collating sequence for an expression to the
74531 ** pExpr is an operand of a comparison operator. aff2 is the
74581 ** idx_affinity is the affinity of an indexed column. Return true
74668 ** expression depth allowed. If it is not, leave an error message in
74721 ** Set the Expr.nHeight variable in the structure passed as an
74742 ** leave an error in pParse.
74751 ** by the select statement passed as an argument.
74881 ** Expr node. Or, if an OOM error occurs, set pParse->db->mallocFailed,
74900 ** Join two expressions using an AND operator. If either expression is
74935 ** Assign a variable number to an expression that encodes a wildcard
74943 ** the SQL statement comes from an external source.
74967 /* Wildcard of the form "?nnn". Convert "nnn" to an integer and
75019 ** Recursively delete an expression tree.
75055 ** to store a copy of an expression or expression tree. They differ in
75385 ** Add a new element to the end of an expression list. If pList is
75433 ** pList might be NULL following an OOM error. But pName should never be
75458 ** pList might be NULL following an OOM error. But pSpan should never be
75481 ** leave an error message in pParse.
75497 ** Delete an entire expression list.
75515 ** to an integer. These routines are checking an expression to see
75573 ** Walk an expression tree. Return 1 if the expression is constant
75585 ** Walk an expression tree. Return 1 if the expression is constant
75588 ** an ON or USING clause.
75595 ** Walk an expression tree. Return 1 if the expression is constant
75610 ** in *pValue. If the expression is not an integer or if it is too big
75616 /* If an expression is an integer literal that fits in a signed 32-bit
75649 ** This routine is used as an optimization, to skip OP_IsNull opcodes
75654 ** will likely result in an incorrect answer. So when in doubt, return
75674 ** Generate an OP_IsNull instruction that tests register iReg and jumps
75785 ** Code an OP_Once instruction and allocate space for its flag. Return the
75814 ** through the set members, skipping any duplicates. In this case an
75816 ** to be unique - either because it is an INTEGER PRIMARY KEY or it
75820 ** for fast set membership tests. In this case an epheremal table must
75821 ** be used unless <column> is an INTEGER PRIMARY KEY or an index can
75825 ** needs to know whether or not the structure contains an SQL NULL
75857 /* Check to see if an existing table or index can be used to
75877 /* Code an OP_VerifyCookie and OP_TableLock for <table>. */
75899 /* The collation sequence used by the comparison. If an index is to
75938 /* Could not found an existing table or index to use as the RHS b-tree.
75939 ** We will have to generate an ephemeral table to do the job.
75977 ** to some integer key column of a table B-Tree. In this case, use an
75981 ** If rMayHaveNull is non-zero, that means that the operation is an IN
75994 ** result. For IN operators or if an error occurs, the return value is 0.
76013 ** * The right-hand side is an expression list containing variables
76046 /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
76090 ** For each expression, build an index key from the evaluation and
76153 ** of the memory cell in iColumn. If this is an EXISTS, write
76154 ** an integer 0 (not exists) or 1 (exists) into a memory cell
76200 ** Generate code for an IN expression.
76206 ** is an array of zero or more values. The expression is true if the LHS is
76268 /* In this case, the RHS is an index b-tree.
76333 ** Duplicate an 8-byte value
76345 ** Generate an instruction that will put the floating point
76367 ** Generate an instruction that will put the integer describe by
76452 /* Find an empty slot and replace it */
76574 ** There must be an open cursor to pTab in iTable when this routine
76617 ** Record the fact that an affinity change has occurred on iCount
77117 ** The expression is implemented using an OP_Param opcode. The p1
77118 ** parameter is set to 0 for an old.rowid reference, or to (i+1)
77151 /* If the column has REAL affinity, it may currently be stored as an
77283 ** Generate code to evaluate an expression and store the results
77360 ** Generate a human-readable explanation of an expression tree.
77591 ** Generate a human-readable explanation of an expression list.
77617 ** Return TRUE if pExpr is an constant expression that is appropriate
77628 ** We could factor them out, but then we would end up adding an
77658 ** up generating an OP_SCopy to move the value to the destination
78114 ** this routine is used, it does not hurt to get an extra 2 - that
78116 ** an incorrect 0 or 1 could lead to a malfunction.
78234 ** Make an entry for the column in pAggInfo->aCol[] if there
78235 ** is not an entry there already.
78273 /* There is now an entry for pExpr in pAggInfo->aCol[] (either
78364 ** Call sqlite3ExprAnalyzeAggregates() for every expression in an
78367 ** If an error is found, the analysis is cut short.
78506 /* Ran out of input before finding an opening bracket. Return NULL. */
78531 ** This C function implements an SQL user function that is used by SQL code
78773 ** pTab->zName if this function is being called to code part of an
78820 ** If the table is a system table, this function leaves an error message
78853 VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
78872 ** in database iDb. If so, this is an error.
79060 ** This function is called after an "ALTER TABLE ... ADD" statement
79101 ** for an SQL NULL default below.
79178 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
79214 /* Make sure this is not an attempt to ALTER a view. */
79228 ** the name by adding an "sqlite_altertab_" prefix. By adding this
79229 ** prefix, we insure that the name will not collide with an existing
79336 ** about the distribution of keys within an index. The index is identified by
79341 ** The sqlite_stat2 entries for an index that have sampleno between 0 and 9
79359 ** The sqlite_stat3 is an enhancement to sqlite_stat2. A new name is
79383 ** There can be an arbitrary number of sqlite_stat3 entries per index.
79486 ** share an instance of the following structure to hold their state
79698 ** Generate code to do an analysis of all indices associated with
79824 ** initialized to contain an SQL NULL.
79988 ** Generate code that will do an analysis of an entire database
80011 ** Generate code that will do an analysis of a single table in
80036 ** when it recognizes an ANALYZE command.
80055 /* Read the database schema. If an error occurs, leave an error message
80338 ** If an OOM error occurs, this function always sets db->mallocFailed.
80417 ** Resolve an expression that was part of an ATTACH or DETACH statement. This
80452 ** An SQL user-function registered to do the work of an ATTACH statement. The
80453 ** three arguments to the function come directly from an attach statement:
80459 ** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the
80633 /* Return an error if we get here */
80642 ** An SQL user-function registered to do the work of an DETACH statement. The
80757 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
80793 ** Called by the parser to compile an ATTACH statement.
80847 ** These routines are used to make sure that an index, trigger, or
80851 ** to an object in a different database, an error message is added to
80972 ** API. This facility is an optional feature of the library. Embedded
81021 ** will return with an error. SQLITE_IGNORE means that the SQL statement
81042 ** Write an error message into pParse->zErrMsg that explains that the
81043 ** user-supplied authorization function returned an illegal value.
81052 ** table zTab in database zDb. This function assumes that an authorization
81056 ** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE
81057 ** is treated as SQLITE_DENY. In this case an error is left in pParse.
81090 ** then generate an error.
81144 ** Do an authorization check using the code and arguments given. Return
81181 ** Push an authorization context. After this routine is called, the
81197 ** Pop an authorization context that was previously pushed
81304 ** Code an OP_TableLock instruction for each table locked by the
81332 ** Note that if an error occurred, it might be the case that
81497 ** database containing the table. Return NULL if not found. Also leave an
81501 ** routine leaves an error message in pParse->zErrMsg where
81512 /* Read the database schema. If an error occurs, leave an error message
81562 ** Reclaim the memory used by an index
81817 ** of a database ("main", "temp" or the name of an attached db). This
81838 ** "temp" or the name of an attached db). This routine returns the
82007 /* Make sure the new table name does not collide with an existing
82008 ** index or table name in the same database. Issue an error message if
82010 ** to an sqlite3_declare_vtab() call. In that case only the column names
82030 sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
82126 /* If an error occurs, we jump here */
82295 ** Default value expressions must be constant. Raise an exception if this
82332 ** a primary key (and this is the second primary key) then create an
82341 ** If the key is not an INTEGER PRIMARY KEY, then create a unique
82388 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "
82445 ** then an index may have been created on this column before the
82470 ** another error occurs, NULL is returned and an error message written into
82475 ** and generates an error message.
82540 ** The first parameter is a pointer to an output buffer. The second
82541 ** parameter is a pointer to an integer that contains the offset at
82548 ** characters, does not begin with a digit and is not an SQL keyword,
82815 /* Check to see if we need to create an sqlite_sequence table for
82947 ** of errors. If an error is seen leave an error message in pParse->zErrMsg.
83108 ** erasing iTable (this can happen with an auto-vacuum database).
83116 /* OP_Destroy stores an in integer r1. If this integer
83136 ** is also added (this can happen with an auto-vacuum database).
83151 ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the
83519 ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED
83538 ** content of an index in response to a REINDEX command.
83656 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
83658 ** be NULL for a primary key or an index that is created to satisfy a
83689 Token nullId; /* Fake token for an empty ID list */
83822 /* Check for authorization to create an index.
83858 /* Either pColl!=0 or there was an OOM failure. But if an OOM
83910 ** load the column indices into the Index structure. Report an error
83916 ** same column more than once cannot be an error because that would
83938 ** must exist or else there must have been an OOM error. But if there
83939 ** was an OOM error, we would never reach this point. */
83965 /* This routine has been called to create an automatic index as a
83973 ** Either way, check to see if the table already has such an index. If
84008 ** ON CONFLICT clauses this is an error. Otherwise, use the
84078 /* A named index with an explicit CREATE INDEX statement */
84089 /* Add an entry in sqlite_master for this index
84101 /* Fill the index with data and reparse the schema. Code an OP_Expire
84113 /* When adding an index to the list of indices for a table, make
84153 ** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the
84155 ** first column of the index. aiRowEst[2] is an estimate of the number
84184 ** This routine will drop an existing named index. This routine
84252 ** pArray is a pointer to an array of objects. Each object in the
84319 ** Delete an IdList.
84415 ** A SrcList is returned, or NULL if there is an OOM error. The returned
84417 ** a new one. If an OOM error does occurs, then the prior value of pList
84420 ** If pDatabase is not null, it means that the table has an optional
84496 ** Delete an entire SrcList including all its substructure.
84572 ** Add an INDEXED BY or NOT INDEXED clause to the most recently added
84594 ** Shifts all join operators from left to right for an entire FROM
84678 ** release or rollback an SQL savepoint.
84738 ** The first time this routine is called, we code an OP_Goto that
84794 ** Generate VDBE code that prepares for doing an operation that
84817 ** If an abort occurs after some of these writes have completed, then it will
84837 ** particular, it prevents us from writing an effective
84847 ** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT
84944 /* Read the database schema. If an error occurs, leave an error message
84994 ** pointer. If an error occurs (out of memory or missing collation
85141 ** an equivalent collating sequence that uses a text encoding different
85162 ** Locate and return an entry from the db.aCollSeq hash table. If the entry
85166 ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
85222 ** if necessary and generates an error message if the collating sequence
85405 /* If the createFlag parameter is true and the search did not reveal an
85504 ** the name of a single table, as one might find in an INSERT, DELETE,
85506 ** return a pointer. Set an error message and return NULL if the table
85533 ** writable, generate an error message and return 1. If it is
85545 ** In either case leave an error message in pParse and return non-zero.
85569 ** Evaluate a view and store its result in an ephemeral table. The
85570 ** pWhere argument is an optional WHERE clause that restricts the
85608 ** Generate an expression tree to implement the WHERE, ORDER BY,
85631 /* Check that there isn't an ORDER BY without a LIMIT clause.
85739 ** put in an SrcList structure because some of the subroutines we
85741 ** an SrcList* parameter instead of just a Table* parameter.
85870 ** because deleting an item can change the scan order. */
86088 ** Generate code that will assemble an index key and put it in register
86089 ** regOut. The key with be for index pIdx which is an index on pTab.
86278 ** abs(X) throws an integer overflow error since there is no
86444 ** raise an SQLITE_TOOBIG exception and return NULL.
86850 ** Otherwise, return an error.
86898 /* IMP: R-48699-48617 This function is an SQL wrapper around the
86914 /* IMP: R-24470-31136 This function is an SQL wrapper around the
86936 ** The result is an integer that identifies if the compiler option
86988 ** EXPERIMENTAL - This is not an official function. The interface may
87383 ** SUM might return an integer if it never encounters a floating point
87384 ** value. TOTAL never fails, but SUM might through an exception if
87385 ** it overflows an integer.
87618 ** pExpr points to an expression which implements a function. If
87778 ** If an immediate foreign key constraint is violated, SQLITE_CONSTRAINT
87788 ** time a statement is executed that removes an existing violation from
87836 ** If a delete caused by OR REPLACE violates an FK constraint, an exception
87844 ** and the statement transaction is rolled back. An exception is an INSERT
87846 ** instead of using a counter, an exception is thrown immediately if the
87848 ** an INSERT does not open a statement transaction.
87857 ** Before coding an UPDATE or DELETE row operation, the code-generator
87863 ** coding an INSERT operation. The functions used by the UPDATE/DELETE
87875 ** sqlite3FkDelete() - Delete an FKey structure.
87901 ** If successful, zero is returned. If the parent key is an INTEGER PRIMARY
87907 ** Otherwise, it is set to point to an allocated array of size N, where
87932 ** into pParse. If an OOM error occurs, non-zero is returned and the
87963 ** 1) There is an INTEGER PRIMARY KEY column and the FK is implicitly
87998 ** map to an explicit list of columns in table pParent. Check if this
88044 ** child table of foreign key constraint pFKey. If an SQL UPDATE is executed
88106 /* Invoke MustBeInt to coerce the child key value to an integer (i.e.
88115 ** to increment the constraint-counter (i.e. this is an INSERT operation),
88141 ** to increment the constraint-counter (i.e. this is an INSERT operation),
88176 /* Special case: If this is an INSERT statement that will insert exactly
88199 ** code for an SQL UPDATE operation, this function may be called twice -
88247 /* Create an Expr object representing an SQL expression like:
88314 ** clause. If the constraint is not deferred, throw an exception for
88341 ** Calling this function with table "t1" as an argument returns a pointer
88415 ** violations, halt the VDBE and return an error at this point, before
88435 ** first register in an array of (pTab->nCol+1) registers containing the
88440 ** For an INSERT operation, regOld is passed zero and regNew is passed the
88441 ** first register of an array of (pTab->nCol+1) registers containing the new
88444 ** For an UPDATE operation, this function is called twice. Once before
88483 ** schema items cannot be located, set an error in pParse and return
88497 ** If the parent table of an FK constraint on the current table is
88544 ** If the parent does not exist, removing the child row resolves an
88565 /* Inserting a single row into a parent table cannot cause an immediate
88592 ** on the parent table of this FK, then throw an exception
88637 ** parameter aChange is passed a NULL value. For an UPDATE, aChange points
88638 ** to an array of size N, where N is the number of columns in table pTab.
88661 /* This is an UPDATE. Foreign key processing is only required if the
88695 ** This function is called when an UPDATE or DELETE operation is being
88697 ** If the current operation is an UPDATE, then the pChanges parameter is
88916 ** refer to table pTab. If there is an action associated with the FK
89147 ** Locate or create an AutoincInfo structure associated with table pTab
89199 AutoincInfo *p; /* Information about an AUTOINCREMENT */
89234 ** Update the maximum rowid for an autoincrement calculation.
89250 ** Every statement that might do an INSERT into an autoincrement
89437 int appendFlag = 0; /* True if the insert is likely to be an append */
89535 /* If this is an AUTOINCREMENT table, look up the sequence number in the
89676 /* If the INSERT statement included an IDLIST term, then make sure
89680 ** If the table has an INTEGER PRIMARY KEY column and that column
89714 /* If there is no IDLIST term but the table has an integer primary
89788 /* build the NEW.* reference row. Note that if there is an INTEGER
89835 /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
89854 ** except when the table has an INTEGER PRIMARY KEY column, in which
90040 ** Generate code to do constraint checks prior to an INSERT or an UPDATE.
90057 ** is false, indicating an INSERT statement, then a non-zero rowidChng
90060 ** computed automatically in an insert or that the rowid value is not
90061 ** modified by an update.
90091 ** the stack and there is an immediate jump
90101 ** CHECK REPLACE Illegal. The results in an exception.
90123 int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
90207 /* If we have an INTEGER PRIMARY KEY, make sure the primary key
90209 ** is an UPDATE and the primary key is not changing, that is OK.
90311 /* Find out what action to take in case there is an indexing conflict */
90407 int appendBias, /* True if this is likely to be an append */
90518 ** for index pDest in an insert transfer optimization. The rules
90572 ** an unoptimized transfer. This routine also returns FALSE if there
90595 KeyInfo *pKey; /* Key information for an index */
90626 return 0; /* SELECT may not have an ORDER BY clause */
90629 ** there is no ORDER BY, we will get an error. */
90841 ** codes. Also write an error message into memory obtained from
91001 ** an SQLite instance. Shared libraries that intend to be loaded
91232 ** (part of the main SQLite library - not an extension) so that
91800 ** Attempt to load an SQLite extension library contained in the file
91807 ** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with
92039 ** If anything goes wrong, set an error in the database connection.
92094 ** 1 for ON or NORMAL and 2 for FULL. Return 1 for an empty or
92148 ** Interpret the given string as an auto-vacuum mode value.
92307 ** compiler (eg. count_changes). So add an opcode to expire all
92428 /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS
92524 /* Malloc may fail when setting the page-size, as there is an internal
92569 ** change. The only purpose is to provide an easy way to test
92740 ** as an auto-vacuum capable db.
92747 ** that this really is an auto-vacuum capable database.
93173 /* Pragma "quick_check" is an experimental reduced version of
93211 /* Do an integrity check on each database file */
93224 /* Do an integrity check of the B-Tree
93347 ** is created. If an existing main database file is opened, then the
93669 ** Fill the InitData structure with an error message that indicates
93754 /* If the SQL column is blank it means this is an index that
93763 /* This can occur if there exists an index on a TEMP table which
93905 ** For an attached db, it is an error if the encoding is not the same
93917 /* If opening an attached database, the encoding much match ENC(db) */
94010 /* Jump here for an error that occurs after successfully allocating
94011 ** curMain and calling sqlite3BtreeEnter(). For an error that occurs
94030 ** created using ATTACH statements. Return a success code. If an
94031 ** error occurs, write an error message into *pzErrMsg.
94404 ** and the statement is automatically recompiled if an schema change
94484 ** and the statement is automatically recompiled if an schema change
94627 ** type of join. Return an integer constant that expresses that type
94639 ** If an illegal or unsupported join type is seen, then still return
94640 ** a join type, but put an error in the pParse structure.
94762 int isOuterJoin, /* True if this is an OUTER join */
94793 ** The EP_FromJoin property is used on terms of an expression to tell
94862 "an ON or USING clause", 0);
94887 ** an AND operator.
94899 ** Report an error if any column mentioned in the USING clause is
95020 ** Generate an error message when a SELECT is used within a subexpression
95034 "a SELECT that is part of an expression");
95099 /* If the destination is an EXISTS(...) expression, the actual
95166 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
95197 /* If this is a scalar select that is part of an expression, then
95258 ** Given an expression list, generate a KeyInfo structure that records
95261 ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting
95269 ** freed. Add the KeyInfo structure to the P4 field of an opcode using
95317 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
95351 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
95504 ** declaration type for a ROWID field is INTEGER. Exactly when an expression
95695 /* If this is an EXPLAIN, skip this step */
95748 ** Given a an expression list (which is really the list of expressions
95779 /* Get an appropriate name for the column
95785 /* If the column contains an "AS <name>" phrase, use <name> as the name */
95925 ** If an error occurs, return NULL and leave a message in pParse.
95994 pParse->nMem++; /* Allocate an extra register for limit+offset */
96091 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
96139 /* Compound SELECTs that have an ORDER BY clause are handled separately.
96428 ** Code an output subroutine for a coroutine implementation of a
96479 /* Suppress the the first OFFSET entries if there is an OFFSET clause
96502 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
96519 #if 0 /* Never occurs on an ORDER BY query */
96529 /* If this is a scalar select that is part of an expression, then
96586 ** is an ORDER BY clause.
96632 ** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA
96633 ** causes an immediate jump to EofA and an EOF on B following nextB causes
96634 ** an immediate jump to EofB. Within EofA and EofB, and EOF on entry or
97139 ** (2) The subquery is not an aggregate or the outer query is not a join.
97179 ** (16) The outer query is not an aggregate or the subquery does
97188 ** * is not an aggregate or DISTINCT query, and
97195 ** operators have an implied DISTINCT which is disallowed by
97206 ** an ORDER BY clause. Ticket #3773. We could relax this constraint
97288 ** not used as the right operand of an outer join. Examples of why this
97311 ** effectively converts the OUTER JOIN into an INNER JOIN.
97599 ** Analyze the SELECT statement passed as an argument to see if it
97630 ** The select statement passed as the first argument is an aggregate query.
97664 ** If the source-list item passed as an argument was augmented with an
97667 ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate
97737 ** an entry of the FROM clause is a subquery instead of a table or view,
97955 ** If anything goes wrong, an error message is written into pParse.
98059 ** intermediate results while calculating an aggregate. This
98107 ** Update the accumulator memory cells for an aggregate based on
98172 ** values to an OP_Copy.
98244 ** SRT_EphemTab Create an temporary table pDest->iParm and store
98262 ** encountered, then an appropriate error message is left in
98286 int addrSortIndex; /* Address of an OP_OpenEphemeral instruction */
98287 int addrDistinctIndex; /* Address of an OP_OpenEphemeral instruction */
98357 ** an exact limit.
98370 /* Generate a subroutine that will fill an ephemeral table with
98440 /* If there is both a GROUP BY and an ORDER BY clause and they are
98443 ** an optimization - the correct answer should result regardless.
98452 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
98465 ** BY and DISTINCT, and an index or separate temp-table for the other.
98476 /* If there is an ORDER BY clause, then this sorting
98479 ** OP_OpenEphemeral instruction will be changed to an OP_Noop once
98535 ** into an OP_Noop.
98561 /* Change the OP_OpenEphemeral coded earlier to an OP_Integer. The
98695 ** This might involve two separate loops with an OP_Sort in between, or
98696 ** it might be a single loop that uses an index to extract information
98880 ** is better to execute the op on an index, as indexes are almost
98894 ** there is such an index, and it has less columns than the table
98901 ** (2011-04-15) Do not do a full scan of an unordered index.
98933 ** as if there was an "ORDER ON x" or "ORDER ON x DESC" clause.
98998 /* If there is an ORDER BY clause, then we need to sort the results
99015 /* Control jumps to here if an error is encountered above, or upon
99159 char *zErrMsg; /* Error message text, if an error occurs */
99194 /* If this is the first row, then generate an extra row containing
99413 IdList *pColumns, /* column list if this is an UPDATE OF trigger */
99491 ** drop so the trigger cannot be dropped. This results in an
99633 /* Make an entry in the sqlite_master table */
99694 ** If an OOM error occurs, NULL is returned and db->mallocFailed is set.
99715 ** Build a trigger step out of an INSERT statement. Return a pointer
99718 ** The parser calls this routine when it sees an INSERT inside the
99750 ** Construct a trigger step that implements an UPDATE statement and return
99752 ** sees an UPDATE statement inside the body of a CREATE TRIGGER.
99947 ** pEList is the SET clause of an UPDATE statement. Each entry
99949 ** in pEList have an <id> which matches an identifier in pIdList,
99966 ** one trigger that must be fired when an operation of type 'op' is
99967 ** performed on the table, and, if that operation is an UPDATE, if at
99974 ExprList *pChanges, /* Columns that change in an UPDATE statement */
100046 ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use
100123 ** (trigger program). If an error has occurred, transfer error information
100161 ** are freed if an error occurs, link them into the Parse.pTriggerPrg
100221 /* Insert an OP_Halt at the end of the sub-program. */
100266 ** process of being coded). If this is the case, then an entry with
100268 ** in the Parse.pTriggerPrg list. Search for such an entry. */
100274 /* If an existing TriggerPrg could not be located, create a new one. */
100321 ** This is called to code the required FOR EACH ROW triggers for an operation
100324 ** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then
100330 ** The reg argument is the address of the first in an array of registers
100350 ** are never accessed, and so are not allocated by the caller. So, for an
100358 ** raises an IGNORE exception.
100367 int reg, /* The first in an array of registers (see above) */
100402 ** old.* record into memory when executing an UPDATE or DELETE command.
100405 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
100408 ** with an index greater than 32 may be accessed, 0xffffffff is returned.
100485 ** The most recently coded instruction was an OP_Column to retrieve the
100491 ** was created, or added later to the table definition by an ALTER TABLE
100498 ** Column definitions created by an ALTER TABLE command may only have
100509 ** If parameter iReg is not negative, code an OP_RealAffinity instruction
100510 ** on register iReg. This is used when an equivalent integer value is
100511 ** stored in place of an 8-byte floating point value in order to save
100536 ** Process an UPDATE statement.
100560 ** an expression for the i-th column of the table.
100846 /* If there are triggers on this table, populate an array of registers
101034 ** Generate code for an UPDATE of a virtual table.
101036 ** The strategy is that we create an ephemerial table that contains
101149 ** Finalize a prepared statement. If there was an error, store the
101162 ** Execute zSql on database db. Return an error code.
101295 /* A VACUUM cannot change the pagesize of an encrypted database. */
101309 /* Begin a transaction and take an exclusive lock on the main database
101356 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
101400 ** transaction by sqlite3BtreeCopyFile() and the other by an explicit
101409 ** are an increment to apply to the meta value after the vacuum.
101452 /* Currently there is an SQL level transaction open on the vacuum
101495 ** sqlite3.pVtabCtx member variable is set to point to an instance of
101577 ** If an unlock is omitted, resources leaks will occur.
101634 ** above function sqlite3VtabUnlockList() for an explanation of why
101636 ** database connection that may have an entry in the p->pVTable list.
101842 ** The VM register number pParse->regRowid holds the rowid of an
101870 ** the first time the virtual table is used in an SQL statement. This
101891 ** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
101901 ** in an argument to the module name in a CREATE VIRTUAL TABLE statement.
102022 ** of the virtual table pTab. If an error occurs, an error code is returned
102023 ** and an error left in pParse.
102093 ** If an error occurs, *pzErr is set to point an an English language
102094 ** description of the error and an SQLITE_XXX error code is returned.
102111 ** invoke it now. If the module has not been registered, return an
102258 ** sqlite3DbFree() containing an error message, if one is available.
102348 ** virtual tables that currently have an open transaction. Pass iSavepoint
102354 ** an open transaction is invoked.
102356 ** If any virtual table method returns an error code other than SQLITE_OK,
102398 ** table implementation have an opportunity to overload the function.
102469 ** array so that an OP_VBegin will get generated for it. Add pTab to the
102497 ** within an xUpdate method.
102588 ** The query generator uses an array of instances of this structure to
102798 #define WHERE_INDEXED 0x000f0000 /* Anything that uses an index */
102800 #define WHERE_IN_ABLE 0x000f1000 /* Able to support an IN operator */
102810 #define WHERE_TEMP_INDEX 0x20000000 /* Uses an ephemeral index */
102951 ** Initialize an expression mask set (a WhereMaskSet object)
102984 ** This routine walks (recursively) an expression tree and generates
103048 ** allowed for an indexable WHERE clause term. The allowed operators are
103051 ** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
103162 /* Figure out the collation sequence required from an index for
103236 ** be the name of an indexed column with TEXT affinity. */
103364 ** term that is an equivalent IN expression. In other words, if the term
103383 ** A subterm is also indexable if it is an AND of two or more
103389 ** potentially be used with an index if an appropriate index exists.
103514 ** that there is no possibility of transforming the OR clause into an
103522 ** might be possible to form an IN operator with either table1.column
103538 ** such table and column. Set okToChngToIN if an appropriate table
103555 ** or follwed by an inverted copy (t2.b==t1.a). Skip this term
103604 ** pTerm converted into an IN operator.
103648 ** The input to this routine is an WhereTerm structure with only the
103707 extraRight = x-1; /* ON clause terms may not be used with an index
103767 ** skipped. Or, if the children are satisfied by an index, the original
103794 ** an OR operator.
103905 /* When sqlite_stat3 histogram data is available an operator of the
103907 ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a
103946 ** an index for tables to the left of the join.
103972 ** for an expression of type TK_COLUMN that refers to the same column and
103977 ** If such an expression is found, its index in pList->a[] is returned. If
104089 /* If any of the expressions is an IPK column on table iBase, then return
104132 ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the
104134 ** the table has a cursor number of "base". pIdx is an index on pTab.
104170 ** or an index structure allocated on the stack by bestBtreeIndex() to
104192 /* Can not use an index sort on anything that is not a column in the
104215 /* If an index column that is constrained by == fails to match an
104223 /* If an index column fails to match and is not constrained by ==
104293 ** Two routines for printing the content of an sqlite3_index_info
104344 ** This routine attempts to find an scanning strategy that can be used
104345 ** to optimize an 'OR' expression that is part of a WHERE clause.
104415 /* If there is an ORDER BY clause, increase the scan cost to account
104442 ** could be used with an index to access pSrc, assuming an appropriate
104484 /* There is no point in building an automatic index for a single scan */
104536 ** Generate code to construct the Index object for an automatic index
104557 int regRecord; /* Register holding an index record */
104593 ** covering index. A "covering index" is an index that contains all
104687 ** Allocate and populate an sqlite3_index_info structure. It is the
104798 ** If an error occurs, pParse is populated with an error message and a
104802 ** Whether or not an error is returned, it is the responsibility of the
104831 "table %s: xBestIndex returned an invalid plan", pTab->zName);
104876 ** wsFlags in an uninitialized state, the caller may behave unpredictably.
104900 ** be a pointer to an sqlite3_vtab structure. Otherwise
104922 ** For each attempt at picking an index, the order of tables in the
104959 /* If there is an ORDER BY clause, and the selected virtual table index
104988 ** to optimize an OR expression within the WHERE clause.
104996 ** Estimate the location of a particular key among all keys in an
105158 ** an sqlite3_value structure containing the same value, with affinity
105164 ** is an SQL variable that currently has a non-NULL value bound to it,
105165 ** create an sqlite3_value structure containing this value, again with
105170 ** If an error occurs, return an error code. Otherwise, SQLITE_OK.
105193 ** by scanning an index for a range of values. The range may have an upper
105220 ** The returned value is an integer divisor to reduce the estimated
105299 ** an equality constraint x=VALUE and where that VALUE occurs in
105301 ** column of an index and sqlite_stat3 histogram data is available
105306 ** If unable to make an estimate, leave *pnRow unchanged and return
105349 ** an IN constraint where the right-hand side of the IN operator
105355 ** If unable to make an estimate, leave *pnRow unchanged and return
105395 ** The lowest cost plan wins. The cost is an estimate of the amount of
105407 ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in
105443 ** use an index to satisfy IS NULL constraints on that table. This is
105507 ** The "in-multiplier". This is an estimate of how many seek operations
105513 ** SQLite must perform 9 lookups on an index on (a, b), so nInMul is
105540 ** Boolean. True if there is an ORDER BY clause that will require an
105549 ** used by the SELECT statement are present in the index (such an
105599 /* If the index being considered is UNIQUE, and there is an equality
105636 /* If there is an ORDER BY clause and the index being considered will
105638 ** in wsFlags. Otherwise, if there is an ORDER BY clause but the index
105658 /* If currently calculating the cost of using an index (not the IPK
105680 ** Estimate the number of rows of output. For an "x IN (SELECT...)"
105719 ** records being an important factor. Both moves and searches are
105732 ** We add an additional 4x penalty to full table scans. This causes
105733 ** the cost function to err on the side of choosing an index over
105734 ** choosing a full scan. This 4x full-scan penalty is an arguable
105744 /* For an index lookup followed by a table lookup:
105789 ** the notReady mask. When computing an "optimal" index, the notReady
105794 ** might be selected even when there exists an optimal index that has
105862 /* If there was an INDEXED BY clause, then only that one index is
105875 ** SQLite outputs rows in in the absence of an ORDER BY clause. */
105946 ** of the join. Disabling is an optimization. When terms are satisfied
105969 ** Code an OP_Affinity opcode to apply the column affinity string zAff
105972 ** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the
106074 ** Generate code that will evaluate all == and IN constraints for an
106080 ** example, the third "c" value is an inequality. So only two
106094 ** this routine allocates an additional nEq memory cells for internal
106130 /* This module is only called on query plans that use an index. */
106189 ** pStr holds the text of an expression that we are building up one term
106209 ** of the subset of table rows scanned by the strategy in the form of an
106216 ** is run and there is an index on (a, b), then this function returns a
106258 ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
106259 ** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single
106383 ** When there is an IN operator, we also have a "addrNxt" label that
106446 /* Case 1: We can directly reference a single row using an
106466 /* Case 2: We have an inequality comparison against the ROWID field.
106543 /* Case 3: A scan using an index.
106550 ** the right-most column can be an inequality - the rest must
106571 ** constraints but an index is selected anyway, in order
106572 ** to force the output order to conform to an ORDER BY.
106590 int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
106641 ** and store the values of those terms in an array of registers
106650 /* If we are doing a reverse order scan on an ascending index, or
106868 ** equivalent to an empty rowset.
106875 ** fall through to the next instruction, just as an OP_Next does if
106876 ** called on an uninitialized cursor.
107074 ** The return value is a pointer to an opaque structure that contains
107079 ** If an error occurs, this routine returns NULL.
107115 ** entire tables. Thus a three-way join is an O(N^3) operation. But if
107149 ** is called from an UPDATE or DELETE statement, then ppOrderBy is NULL.
107151 ** If an index can be used so that the natural output order of the table
107153 ** *ppOrderBy is set to NULL. This is an optimization that prevents an
107154 ** unnecessary sort of the result set if an index appropriate for the
107201 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
107202 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
107231 ** subexpression is separated by an AND operator.
107332 Bitmask notIndexed; /* Mask of tables that cannot use an index */
107344 ** to choose from. The first test looks for an "optimal" scan. In
107345 ** this context an optimal scan is one that uses the same strategy
107355 ** Note that the WhereCost.nRow parameter for an optimal scan might
107419 /* If an INDEXED BY clause is present, then the plan must use that
107435 ** the full-table-scan is an "optimal" plan as defined above.
107437 ** (3) All tables have an INDEXED BY clause or this table lacks an
107440 ** that a best-so-far is always selected even if an impossible
107496 /* Check that if the table scanned by this loop iteration had an
107499 ** Return an error.
107507 /* If an INDEXED BY clause is used, the bestIndex() function is
107509 ** if it find an index at all. */
107526 /* If the caller is an UPDATE or DELETE statement that is requesting
107754 /* If this scan uses an index, make code substitutions to read data
107906 /* Construct an expression node for a unary postfix operator
107931 /* Construct an expression node for a unary prefix operator
108049 ** functions that take a state number and lookahead value and return an
108574 ** the parse is retried before an error is thrown.
108669 /* The state of the parser is completely contained in an instance of
110469 /* When doing a nested parse, one can include terms in an expression
111111 ** <li> A pointer to the parser (an opaque structure.)
111132 int yyerrorhit = 0; /* True if yymajor has invoked an error */
111184 ** The response to an error depends upon whether or not the
111185 ** grammar defines an error token "ERROR".
111252 ** * Report an error message, and throw away the input token.
111289 ** This file contains C code that splits an SQL input string up into
111298 ** an upper-to-lower case map. On EBCDIC machines we also need
111329 ** The sqlite3KeywordCode function looks up an identifier to determine if
111348 ** or not a given identifier is really an SQL keyword. The same thing
111617 ** If X is a character that can be used in an identifier then
111621 ** allowed in an identifier. For 7-bit characters,
111930 ** passed in. An SQLITE_ status code is returned. If an error occurs
111931 ** then an and attempt is made to write an error message into
111943 int mxSqlLen; /* Max length of an SQL string */
112138 ** (1) START At the beginning or end of an SQL statement. This routine
112178 ** is look for a semicolon that is not part of an string or comment.
112497 ** returns an integer equal to SQLITE_VERSION_NUMBER.
112615 ** the pInitMutex mutex. Return an error in either case. */
112777 /* Specify an alternative mutex implementation */
112790 /* Specify an alternative malloc implementation */
112825 /* now an error */
112831 /* Specify an alternative page cache implementation */
112867 ** ENABLE_MEMSYS5 is defined, return an error.
113007 ** Configuration settings for an individual database connection
113173 ** Close an existing SQLite database
113344 /* SQLITE_OK */ "not an error",
113392 ** an integer number of milliseconds passed in as the first
113437 ** This routine is called when an operation failed with a lock.
113439 ** returns 0, the operation aborts with an SQLITE_BUSY error.
113454 ** This routine sets the busy callback for an Sqlite database to the
113472 ** This routine sets the progress callback for an Sqlite database to the
113522 ** that if a malloc() fails in sqlite3_create_function(), an error code
113576 /* Check if an existing function is being overridden or deleted. If so,
113599 /* If an older version of the function with a configured destructor is
113701 ** When virtual tables intend to provide an overloaded function, they
113823 ** is greater than sqlite3.pWalArg cast to an integer (the value configured by
113842 ** Configure an sqlite3_wal_hook() callback to automatically checkpoint
113904 /* Initialize the output variables to -1 in case an error occurs. */
113949 ** an error occurs while running the checkpoint, an SQLite error code is
113957 ** checkpointed. If an error is encountered it is returned immediately -
114095 ** Return the most recent error code generated by an SQLite routine. If NULL is
114149 /* Check if this call is removing or replacing an existing collation
114250 ** If an invalid limit index is supplied, report -1.
114314 ** If an error occurs, then an SQLite error code is returned and *pzErrMsg
114315 ** may be set to point to a buffer containing an English language error
114549 ** Throw an error if any non-sense combination is used. If we
114961 ** This function is now an anachronism. It used to be used to recover from a
115096 ** 2. The table is not a view and the column name identified an
115117 ** to whatever their local counterparts contain. If an error did occur,
115239 ** is an array of integers that defines the test. Return -1 on a
115240 ** memory allocation error, 0 on success, or non-zero for an error.
115274 ** an incompatible database file format. Changing the PENDING byte
115646 ** Register an unlock-notify callback.
115649 ** but has received an SQLITE_LOCKED error because another connection
115790 ** This is a difficult situation to handle. Returning an error
115791 ** code to the caller is insufficient, as even if an error code
115795 ** indefinitely for an unlock-notify callback that will never
115840 ** This is called when the database connection passed as an argument is
115866 ** This is an SQLite module implementing full-text search.
115872 ** * The FTS3 module is being built as an extension
115941 ** memory. A "position" is an index of a token in the token stream
115966 ** A bare doclist omits the position information, becoming an
116018 ** SegmentWriter creates new leaf nodes, or when an interior node
116035 ** Here, optional { X } means an optional element, while array { X }
116064 ** This could be either a leaf node or an interior node. If the top
116136 ** write an empty doclist (varint(docid) varint(POS_END)), for updates
116167 ** FTS4 is really an extension for FTS3. It is enabled using the
116169 ** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
116214 ** an sqlite3_tokenizer_module containing pointers to the callback
116215 ** functions that make up an implementation.
116217 ** When an fts3 table is created, it passes any arguments passed to
116220 ** implementation. The xCreate() function in turn returns an
116224 ** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()
116225 ** method is called. It returns an sqlite3_tokenizer_cursor object
116252 ** This method should return either SQLITE_OK (0), or an SQLite error
116265 ** Destroy an existing tokenizer. The fts3 module calls this method
116271 ** Create a tokenizer cursor to tokenize an input buffer. The caller
116282 ** Destroy an existing tokenizer cursor. The fts3 module calls this
116291 ** the end of the buffer has been reached, or an SQLite error code.
116372 /* A complete hash table is an instance of the following structure.
116392 /* Each element in the hash table is an instance of the following
116483 ** Macro to return the number of elements in an array. SQLite has a
116485 ** a collision when building an amalgamation with built-in FTS3.
116511 ** It is considered impossible for an index to use more than 1024 levels. In
116603 ** A connection to a fulltext index is an instance of the following
116604 ** structure. The xCreate and xConnect methods create an instance
116646 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
116648 ** is an index of prefixes of a specific length.
116673 ** virtual table cursor (an instance of the following structure) using
116779 ** matchinfo data. If it is not NULL, it points to an array of size nCol*3,
117037 ** Convert an SQL-style quoted string into a normal string by removing
117187 ** Otherwise, return an SQLite error code.
117199 ** Otherwise, if an error occurs, an SQLite error code is stored in *pRc
117241 ** If the p->bHasDocsize boolean is true (indicating that this is an
117242 ** FTS4 table, not an FTS3 table) then also create the %_docsize and
117309 ** Otherwise, if an error occurs, an SQLite error code is stored in *pRc
117369 ** Append the output of a printf() style formatting to an existing string.
117431 ** being returned directly each column of text data is passed to an SQL
117442 ** a NULL pointer is returned). Otherwise, if an OOM error is encountered
117489 ** is preceded by zFunc and an open bracket, and followed by a closed
117499 ** a NULL pointer is returned). Otherwise, if an OOM error is encountered
117531 ** Only decimal digits ('0'..'9') may be part of an integer value.
117552 ** This function is called to allocate an array of Fts3Index structures
117563 ** array. If an error does occur, an SQLite error code is returned.
117565 ** Regardless of whether or not an error is returned, it is the responsibility
117607 ** This function is called when initializing an FTS4 table that uses the
117621 ** *pazCol: Set to point to an array of *pnCol strings. Each string is
117627 ** If the table cannot be found, an error code is returned and the output
117628 ** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is
117775 /* Check if it is an FTS4 special argument. */
117987 /* If this is an xCreate call, create the underlying tables in the
118062 /* By default use a full table scan. This is an expensive option,
118088 ** it would lead to an "unable to use function MATCH in the requested
118142 /* Allocate a buffer large enough for an Fts3Cursor structure. If the
118173 ** compose and prepare an SQL statement of the form:
118178 ** it. If an error occurs, return an SQLite error code.
118244 ** If an OOM error occurs, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.
118267 ** varints from the buffer) does not risk an overread. If zNode is a
118347 ** The buffer pointed to by argument zNode (size nNode bytes) contains an
118365 ** If an error occurs, an error code other than SQLITE_OK is returned.
118443 /* The end of a position list is marked by a zero encoded as an FTS3
118508 ** Value used to signify the end of an position-list. This is safe because
118544 ** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by
118652 ** If isSaveLeft is 0, an entry is added to the output position list for
118771 ** position lists correspond to the left and right phrases of an expression
118909 ** This function does an "OR" merge of two doclists (output contains all
118915 ** If no error occurs, *paOut is set to point at an sqlite3_malloc'd buffer
118919 ** If an error occurs, an SQLite error code is returned. The output values
119069 ** of the entries from pList at position 0, and terminated by an 0x00 byte.
119120 ** If an OOM error occurs, return SQLITE_NOMEM. In this case it is
119166 ** as the first argument. The merge is an "OR" merge (see function
119175 ** This function returns SQLITE_OK if the merge is successful, or an
119176 ** SQLite error code (SQLITE_NOMEM) if an error occurs.
119258 ** This function returns SQLITE_OK if successful, or an SQLite error code
119278 ** made by an fts4aux module, not an FTS table. In this case calling
119355 /* "isScan" is only set to true by the ft4aux module, an ordinary
119370 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
119385 ** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,
119389 ** an SQLite error code.
119394 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
119395 ** Output parameter *ppSegcsr is set to 0 if an error occurs.
119410 int bFound = 0; /* True once an index has been found */
119452 ** Free an Fts3MultiSegReader allocated by fts3TermSegReaderCursor().
119544 ** subsequently to determine whether or not an EOF was hit.
119717 /* This call is a request for the "docid" column. Since "docid" is an
119841 ** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error
119933 ** where 't' is the name of an FTS3 table.
120023 ** Implementation of FTS3 xRename method. Rename an fts3 table.
120034 ** because an "ALTER TABLE RENAME TABLE" statement inside a transaction
120142 ** This function is registered as the module destructor (called when an
120258 ** Allocate an Fts3MultiSegReader for each token in the expression headed
120263 ** Fts3SegReader objects internally to provide an interface to seek or scan
120269 ** and merged incrementally. Otherwise, it has to be merged into an in-memory
120370 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120406 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120505 ** function has been called successfully on an Fts3Phrase, it may be
120512 ** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.
120607 ** If an error occurs, return an SQLite error code. Otherwise, return
120691 ** If an error occurs within this function, *pRc is set to an SQLite error
120740 ** This function is used to populate an allocated Fts3TokenAndCost array.
120743 ** Otherwise, if an error occurs during execution, *pRc is set to an
120792 ** an SQLite error code.
120796 ** of data that will fit on a single leaf page of an intkey table in
120858 ** called on each token to defer. Otherwise, an SQLite error code is
121109 ** If an error occurs, *pRc is set to an SQLite error code. Otherwise, if
121133 ** is advanced to the next row that contains an instance of "A * C",
121346 ** If an error occurs during execution of this function, *pRc is set to
121516 ** a no-op. If an error occurs within this function, *pRc is set to an
121598 ** populated. Otherwise, if an error occurs, an SQLite error code is returned.
121751 ** compression and is terminated by either an 0x01 or 0x00 byte. For example,
121914 /* The user should specify a single argument - the name of an fts3 table. */
122281 ** if successful or an error code if sqlite3_create_module() fails.
122352 ** than an implicit AND. When using the new, both implicity and explicit
122426 ** is defined to accept an argument of type int, its behaviour when passed
122427 ** an integer that falls outside of the range of the unsigned char type
122429 ** is defined to accept an argument of type char, and always returns 0 for
122478 ** and other information (column names etc.) in pParse. Create an Fts3Expr
122556 ** Enlarge a memory allocation. If an out-of-memory allocation occurs,
122569 ** that appeared as part of an fts3 query expression. Neither quote character
122571 ** input buffer and create an Fts3Expr structure of type FTSQUERY_PHRASE
122696 ** The output variable *ppExpr is populated with an allocated Fts3Expr
122699 ** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM
122701 ** If SQLITE_ERROR is returned, pContext is populated with an error message.
122731 /* Skip over any whitespace before checking for a keyword, an open or
122755 /* If this is a "NEAR" keyword, check for an explicit nearness. */
122767 ** the next byte must contain either whitespace, an open or close
122791 /* Check for an open bracket. */
122829 ** interface. Before doing so, figure out if there is an explicit
122834 ** an implementation artifact or an intentional decision when fts3 was
122857 ** The argument is an Fts3Expr structure for a binary operator (any type
122858 ** except an FTSQUERY_PHRASE). Return an integer value representing the
122919 ** returns either when the end of the buffer is reached or an unmatched
122951 /* Create an implicit NOT operator. */
122970 ** an expression contained in parenthesis is required. If a
122981 /* Insert an implicit AND operator. */
123002 ** Return an error in either case.
123067 ** an fts3 query expression, respectively. This function attempts to parse the
123070 ** of the parsed expression tree and SQLITE_OK is returned. If an error
123184 ** sqlite3_free() to release the memory. If an OOM condition is encountered,
123353 ** * The FTS3 module is being built as an extension
123469 ** with types "const void*" and "int" and returns an "int".
123495 /* Link an element into the hash table
123547 /* This function (for internal use only) locates an element in an
123630 ** Attempt to locate an element of the hash table pH with a key
123641 /* Insert an element into the hash table pH. The key is pKey,nKey
123736 ** * The FTS3 module is being built as an extension
123891 ** In prose: A word is an optional consonant followed by zero or
123892 ** vowel-consonant pairs followed by an optional vowel. "m" is the
123901 ** for an instance of of a consonant followed by a vowel.
124377 ** This is part of an SQLite module implementing full-text search.
124384 ** * The FTS3 module is being built as an extension
124409 ** an error is returned.
124743 ** in the README.tokenizer file as an example, so it is important to
124873 ** * The FTS3 module is being built as an extension
125122 ** it is always safe to read up to two varints from it without risking an
125326 ** This function is used to obtain an SQLite prepared statement handle
125329 ** Otherwise, an SQLite error code is returned and *pp is set to 0.
125331 ** If argument apVal is not NULL, then it must point to an array with
125467 ** Returns SQLITE_OK if the statement is successfully executed, or an
125567 ** return SQLITE_OK. If an error occurs while preparing the statement,
125568 ** return an SQLite error code.
125618 ** if successful, or an SQLite error code otherwise.
125668 ** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.
125732 ** Add an entry to one of the pending-terms hash tables.
125770 ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
125893 ** This function is called by the xUpdate() method as part of an INSERT
125919 ** This function is called by the xUpdate() method for an INSERT operation.
125976 ** In FTS3, this is an error. It is an error to specify non-NULL values
126038 ** (an integer) of a row about to be deleted. Remove all terms from the
126094 ** returned. Otherwise, an SQLite error code is returned.
126151 ** If an error occurs, or the table does not contain the specified row,
126152 ** an SQLite error code is returned. Otherwise, SQLITE_OK is returned. If
126156 ** This function may leave an open sqlite3_blob* handle in the
126263 ** Set an Fts3SegReader cursor to point at EOF.
126277 ** SQLITE_DONE. Otherwise, an SQLite error code.
126315 /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf
126431 /* A pending-terms seg-reader for an FTS4 table that uses order=desc.
126451 /* Pointer p currently points at the first byte of an offset list. The
126602 ** an array of pending terms by term. This occurs as part of flushing
126620 ** This function is used to allocate an Fts3SegReader that iterates through
126758 ** version, it is assumed that each SegReader points to an entry in
126820 ** Argument apSegment is an array of nSegment elements. It is known that
127061 ** blocks were written to the db). Otherwise, an SQLite error code is
127131 ** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
127269 ** returned. Otherwise, an SQLite error code.
127316 ** The first value in the apVal[] array is assumed to contain an integer.
127322 ** document pRowid, or false otherwise, and SQLITE_OK is returned. If an
127323 ** error occurs, an SQLite error code is returned.
127350 ** Return SQLITE_OK if successful, or an SQLite error code if not.
127392 ** SQLITE_OK is returned if successful, otherwise an SQLite error code.
127493 ** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered
127749 ** Similarly, if this is a search for an exact match, and the first term
127900 ** Otherwise, if successful, SQLITE_OK is returned. If an error occurs,
127901 ** an SQLite error code is returned.
128201 /* Compose and prepare an SQL statement to loop through the content table */
128409 ** Add an entry for token pToken to the pCsr->pDeferred list.
128491 int isRemove = 0; /* True for an UPDATE or DELETE */
128529 /* If this is an INSERT operation, or an UPDATE that modifies the rowid
128551 ** the statement is either an INSERT or an UPDATE that modifies the
128560 ** be losslessly converted to an integer. In this case, the eventual
128564 ** docid=$pNewRowid if $pNewRowid is not an integer value).
128585 /* If this is an INSERT or UPDATE operation, insert the new record. */
128679 ** Used as an fts3ExprIterate() context when loading phrase doclists to
128723 ** This type is used as an fts3ExprIterate() context object while
128753 ** element of the list is represented by an FTS3 varint that takes the value
128765 ** When this function is called, *pp points to the start of an element of
128802 ** Iterate through all phrase nodes in an FTS3 query, except those that
128821 ** This is an fts3ExprIterate() callback used while loading the doclists
128997 ** This function is an fts3ExprIterate() callback used by fts3BestSnippet().
128998 ** Each invocation populates an element of the SnippetIter.aPhrase[] array.
129532 ** Advance the iterator passed as an argument to the next position. Return
129560 ** Otherwise, if an error occurs, an SQLite error code is returned and the
129630 ** Populate the buffer pInfo->aMatchinfo[] with an array of integers to
129642 ** Return SQLITE_OK if successful, or an SQLite error code if an error
129747 ** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32).
129934 ** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().
130018 /* Retreive the text stored in column iCol. If an SQL NULL is stored
130020 ** If an OOM occurs while retrieving the data (this can happen if SQLite
130159 ** algorithms packaged as an SQLite virtual table module.
130177 ** an entry in the %_parent table associating the node with its parent.
130178 ** And for each row of data in the table, there is an entry in the %_rowid
130182 ** The root node of an r-tree always exists, even if the r-tree table is
130195 ** consists of a single 8-byte integer followed by an even number
130204 ** This file contains an implementation of a couple of different variants
130335 ** If an R*-tree "Reinsert" operation is required, the same number of
130346 ** 2^40 is greater than 2^64, an r-tree structure always has a depth of
130369 ** The argument is an RtreeCoord. Return the value stored within the RtreeCoord
130429 ** the right-hand-side of an SQL MATCH operator used to constrain an
130605 ** Obtain a reference to an r-tree node.
130806 ** an internal node, then the 64-bit integer is a child page number.
131033 ** Return SQLITE_OK if successful or an SQLite error code if an error
131085 ** Return SQLITE_OK if successful or an SQLite error code if an error
131311 ** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf
131312 ** to zero and return an SQLite error code.
131423 ** can be cast into an RtreeMatchArg object. One created using
131424 ** an sqlite3_rtree_geometry_callback() SQL user function.
131513 /* We have an equality constraint on the rowid. Use strategy 1. */
131523 /* This strategy involves a two rowid lookups on an B-Tree structures
131524 ** and then a linear search of an R-Tree node. This should be
131526 ** sqlite uses an internal cost of 0.0).
132331 /* Allocate an array and populate it with a copy of pCell and
132451 ** This operation is required when a row is deleted (or updated - an update
132452 ** is implemented as a delete followed by an insert). SQLite provides the
132878 /* Constraint handling. A write operation on an r-tree table may return
132938 /* If azData[0] is not an SQL NULL value, it is the rowid of a
133003 rtreeConnect, /* xConnect - connect to an existing table */
133099 ** The second argument to this function contains the text of an SQL statement
133102 ** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error
133124 ** Otherwise, an SQLite error code is returned.
133126 ** If this function is being called as part of an xConnect(), then the rtree
133130 ** Otherwise, for an xCreate(), use 64 bytes less than the database page-size.
133189 "Wrong number of columns for an rtree table", /* 1 */
133190 "Too few columns for an rtree table", /* 2 */
133191 "Too many columns for an rtree table" /* 3 */
133267 ** an r-tree node, and the number of dimensions the r-tree indexes.
133365 ** Each call to sqlite3_rtree_geometry_callback() creates an ordinary SQLite
133446 ** This file implements an integration between the ICU library
133447 ** ("International Components for Unicode", an open-source library
133520 ** 1. uPattern is an unescaped match-all character "%",
133521 ** 2. uPattern is an unescaped match-one character "_",
133522 ** 3. uPattern is an unescaped escape character, or
133523 ** 4. uPattern is to be handled as an ordinary character
133583 ** is implemented as like(B, A). If there is an escape character E,
133609 ** Otherwise, return an error.
133629 ** This function is called when an ICU function called from within
133630 ** the implementation of an SQL scalar function returns an error.
133633 ** loaded with an error message based on the following two args.
133659 ** argument is an SQL NULL, then NULL Is returned. Otherwise, the result
133722 ** leaving the regular expression object configured with an invalid
133748 ** of the locale to use. Passing an empty string ("") or SQL NULL value
133833 ** types to an SQLite database connection. It is intended to be called
133838 ** Where <locale> is a string containing an ICU locale identifier (i.e.