Lines Matching refs:this
3 ** version 3.40.1. By combining all the individual C code files into this
11 ** programs, you need this file and the "sqlite3.h" header file that defines
14 ** the text of this file. Search for "Begin file sqlite3.h" to find the start
33 ** The author disclaims copyright to this source code. In place of
52 ** NO_TEST - The branches on this line are not
85 ** compiler warnings due to subsequent content in this file and other files
86 ** that are included by this file.
93 ** The author disclaims copyright to this source code. In place of
143 ** The author disclaims copyright to this source code. In place of
182 ** system #includes. Hence, this block of code must be the very first
189 ** without this option, LFS is enable. But LFS does not exist in the kernel
264 ** version information, among other things. Normally, this internal MinGW
266 ** files; however, the contained version information is now required by this
268 ** this is the only known way to reliably obtain it. This entire #if block
314 ** The author disclaims copyright to this source code. In place of
324 ** or constant definition does not appear in this file, then it is
328 ** Some of the definitions that are in this file are marked as
335 ** from comments in this file. This file is the authoritative source
338 ** The name of this file under configuration management is "sqlite.h.in".
339 ** The makefile makes some minor changes to this file (such as inserting
348 ** Make sure we can call this stuff from C++.
357 ** Be aware that these macros may not be used within this particular
796 ** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]
1031 ** want to subclass this object by appending additional fields
1046 ** [sqlite3_file] object) with a pointer to an instance of this object.
1080 ** either in this process or in some other process, is holding a RESERVED,
1191 ** file space based on this hint in order to help writes to the database
1233 ** this file-control is NULL. However, if the database file is being synced
1236 ** do not need this signal should silently ignore this opcode. Applications
1237 ** should not call [sqlite3_file_control()] with this opcode as doing so may
1243 ** but before the database is unlocked. VFSes that do not need this signal
1244 ** should silently ignore this opcode. Applications should not call
1245 ** [sqlite3_file_control()] with this opcode as doing so may disrupt the
1276 ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
1286 ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
1304 ** all file-control actions, there is no guarantee that this will actually
1306 ** pointer in case this file-control is not implemented. This file-control
1315 ** ^When there are multiple VFS shims in the stack, this opcode finds the
1350 ** busy-handler, this function should be invoked with the second (void *) in
1379 ** SQLite stack may generate instances of this file control if
1403 ** available. The WAL subsystem issues this signal during rare
1405 ** Applications should <em>not</em> use this file-control.
1409 ** VFS should return SQLITE_NOTFOUND for this opcode.
1414 ** this opcode.
1435 ** ^Regardless of whether or not it is successful, this file control takes
1494 ** (void*) argument passed with this file-control should be a pointer to a
1508 ** database is not a temp db, then this file-control purges the contents
1625 ** structure used by this VFS. mxPathname is the maximum length of
1626 ** a pathname in this VFS.
1630 ** and [sqlite3_vfs_unregister()] interfaces manage this list
1637 ** or modify this field while holding a particular static mutex.
1685 ** the open of a journal file a no-op. Writes to this journal would
1718 ** this even if the open fails. SQLite expects that the sqlite3_file.pMethods
1738 ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
1740 ** to prevent this by setting mxPathname to a sufficiently large value.
1779 const char *zName; /* Name of this virtual file system */
1809 ** value will increment whenever this happens.
1826 ** [temp_store_directory pragma], though this could change in a future
1868 ** between 0 and this upper bound as its "offset" argument.
1870 ** lock outside of this range
1923 ** of SQLite may require this. In other words, the behavior exhibited
1961 ** applications and so this routine is usually not necessary. It is
1984 ** then this routine returns a non-zero [error code].
2010 ** An instance of this object defines the interface between SQLite
2014 ** A pointer to an instance of this object is the argument to
2017 ** By creating an instance of this object
2025 ** and that this object is only useful to a tiny minority of applications
2098 ** <dd>There are no arguments to this option. ^This option sets the
2109 ** <dd>There are no arguments to this option. ^This option sets the
2123 ** <dd>There are no arguments to this option. ^This option sets the
2124 ** [threading mode] to Serialized. In other words, this option enables
2127 ** In this mode (which is the default when SQLite is compiled with
2349 ** third parameter is passed NULL In this case. An example of using this
2364 ** ^If either argument to this option is negative, then that argument is
2391 ** [PRAGMA cache_size] setting and this value.
2398 ** exceeds this threshold, at which point they are written to disk.
2404 ** The default value for this setting is controlled by the
2418 ** value for this option is to never use this optimization. Specifying a
2419 ** negative value for this option restores the default behaviour.
2429 ** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this
2510 ** following this call. The second parameter may be a NULL pointer, in
2521 ** following this call. The second parameter may be a NULL pointer, in
2524 ** <p>Originally this option disabled all triggers. ^(However, since
2526 ** this option is off. So, in other words, this option now only disables
2538 ** following this call. The second parameter may be a NULL pointer, in
2541 ** <p>Originally this option disabled all views. ^(However, since
2543 ** this option is off. So, in other words, this option now only disables
2558 ** following this call. The second parameter may be a NULL pointer, in
2568 ** When the first argument to this interface is 1, then only the C-API is
2570 ** this interface is 0, then both the C-API and the SQL function are disabled.
2575 ** is disabled or enabled following this call. The second parameter may
2584 ** must ensure that the argument passed into this DBCONFIG option is unchanged
2591 ** database handle, SQLite checks if this will mean that there are now no
2594 ** override this behaviour. The first parameter passed to this operation
2611 ** The first argument to this setting is an integer which is 0 to disable
2615 ** following this call.
2621 ** option is used to set or clear (the default) a flag that governs this
2622 ** behavior. The first parameter passed to this operation is an integer -
2647 ** process requires the use of this obscure API and multiple steps to help
2669 ** The first argument to this setting is an integer which is 0 to disable
2673 ** is enabled or disabled following this call.
2691 ** default value of this setting is determined by the [-DSQLITE_DQS]
2700 ** default value of this setting is determined by the [-DSQLITE_DQS]
2727 ** the legacy file format flag. When activated, this flag causes all newly
2731 ** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
2735 ** all the way back to version 3.0.0, and so this setting is of little
2800 ** tables, the value returned by this function may be set explicitly by
2805 ** to disk). In this case subsequent calls to this function return the rowid
2808 ** tables in this way can avoid this problem by restoring the original
2812 ** ^(If an [INSERT] occurs within a trigger then this routine will
2815 ** by this routine reverts to what it was before the trigger was fired.)^
2818 ** successful [INSERT] and does not change the value returned by this
2820 ** and INSERT OR ABORT make no changes to the return value of this
2825 ** the return value of this interface.)^
2827 ** ^For the purposes of this routine, an [INSERT] is considered to
2887 ** upon completion as normal. Of course, this value will not include
2966 ** ^It is safe to call this routine from a thread different from the
2968 ** is not safe to call this routine with a [database connection] that
3068 ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
3101 ** ^Calling this routine with an argument less than or equal to zero
3107 ** this routine, that other busy handler is cleared.)^
3118 ** Use of this interface is not recommended.
3153 ** in an array named azResult. Then azResult holds this content:
3358 ** ^A call to this routine stores N bytes of randomness into buffer P.
3361 ** ^If this routine has not been previously called or if the previous
3365 ** ^If the previous call to this routine had an N of 1 or more and a
3448 ** database connections for the meaning of "modify" in this paragraph.
3498 ** the access attempt or NULL if this access attempt is directly from
3647 ** ignored, though this may change in future releases. Callback
3674 ** database connection D. An example use for this
3696 ** database connections for the meaning of "modify" in this paragraph.
3753 ** <dd>The filename can be interpreted as a URI if this flag is set.</dd>)^
3771 ** (Mutexes will block any actual concurrency, but in this mode
3780 ** this option is a no-op.
3792 ** the extended result code mode, this flag also causes [sqlite3_open_v2()]
3865 ** be used to access the database file on disk. ^If this option is set to
3938 ** C:. Note that the %20 escaping in this example is not strictly
3959 ** corresponding octet. If this process generates an invalid UTF-8 encoding,
4042 ** into the xOpen VFS method, then the behavior of this routine is undefined
4105 ** of this routine results in undefined and probably undesirable
4135 ** of 2*N pointers to strings. Each pair of pointers in this array corresponds
4215 ** this, each thread can obtain exclusive use of the [database connection] D
4235 ** An instance of this object represents a single SQL statement that
4243 ** The life-cycle of a prepared statement object usually goes like this:
4251 ** to step 2. Do this zero or more times.
4280 ** simply invoke this interface with the third parameter set to -1.
4329 ** the equivalent tries to allocate space for more than this many opcodes
4381 ** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]
4385 ** on this hint by avoiding the use of [lookaside memory] so as not to
4387 ** SQLite may act on this hint differently.
4394 ** prepared statements, regardless of whether or not they use this
4731 ** The application-defined SQL function implementation will pass this
4824 ** the application remains responsible for disposing of the object. ^In this
4906 ** parameter. For all forms except ?NNN, this will correspond to the
4968 ** ^Use this routine to reset all host parameters to NULL.
4977 ** [prepared statement]. ^If this routine returns 0, that means the
4979 ** ^However, just because this routine returns a positive number does not
5072 ** If this statement is a [SELECT] statement and the Nth column of the
5087 ** this routine would return the string "VARIANT" for the second result
5107 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
5131 ** successfully. sqlite3_step() should not be called again on this virtual
5149 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
5163 ** calling [sqlite3_reset()] automatically in this circumstance rather
5174 ** We admit that this is a goofy design. The problem has been fixed
5548 ** aggregate takes. ^If this parameter is -1, then the SQL function or
5555 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
5556 ** its parameters. The application should set this parameter to
5585 ** Without this flag, an attacker might be able to modify the schema of
5591 ** function can gain access to this pointer using [sqlite3_user_data()].)^
5756 ** Specifying this flag makes no difference for scalar or aggregate user
5978 ** Implementations of aggregate SQL functions use this
6054 ** of where this might be useful is in a regular-expression matching
6255 ** kind of [sqlite3_value] object can be used with this interface.
6457 ** The code to implement this API is not available in the public release
6472 ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
6475 ** The code to implement this API is not available in the public release
6511 ** ^SQLite implements this interface by calling the xSleep()
6522 ** ^(If this global variable is made to point to a string which is
6525 ** will be placed in that directory.)^ ^If this variable
6529 ** Applications are strongly discouraged from using this global variable.
6532 ** neither read nor write this variable. This global variable is a relic
6536 ** It is not safe to read or modify this variable in more than one
6537 ** thread at a time. It is not safe to read or modify this variable
6540 ** It is intended that this variable be set once
6542 ** routines have been called and that this variable remain unchanged
6545 ** ^The [temp_store_directory pragma] may modify this variable and cause
6548 ** that this variable points to is held in memory obtained from
6551 ** Hence, if this variable is modified directly, either it should be
6563 ** example of how to do this using C++ with the Windows Runtime:
6580 ** ^(If this global variable is made to point to a string which is
6584 ** to be relative to that directory.)^ ^If this variable is a NULL
6587 ** for the process. Only the windows VFS makes use of this global
6590 ** Changing the value of this variable while a database connection is
6593 ** It is not safe to read or modify this variable in more than one
6594 ** thread at a time. It is not safe to read or modify this variable
6597 ** It is intended that this variable be set once
6599 ** routines have been called and that this variable remain unchanged
6602 ** ^The [data_store_directory pragma] may modify this variable and cause
6605 ** that this variable points to is held in memory obtained from
6608 ** Hence, if this variable is modified directly, either it should be
6665 ** an error is to use this function.
6668 ** connection while this routine is running, then the return value
6703 ** threads should mutex-protect calls to this API and should make their own
6716 ** this function will return either a NULL pointer or an empty string.
6718 ** ^The string value returned by this routine is owned and managed by
6722 ** ^The filename returned by this function is the output of the
6727 ** If the filename pointer returned by this routine is not NULL, then it
6807 ** then this interface returns a pointer to the first prepared statement
6809 ** satisfies the conditions of this routine, it returns NULL.
6846 ** the database connections for the meaning of "modify" in this paragraph.
6856 ** ^For the purposes of this API, a transaction is said to have been
6911 ** were something like this:
6941 ** ^Any callback set by a previous call to this function
6954 ** ^In the case of an update, this is the [rowid] after the update takes place.
6964 ** The exceptions defined in this paragraph might change in a future
6972 ** database connections for the meaning of "modify" in this paragraph.
7006 ** ^(The cache sharing mode set by this interface effects all subsequent
7015 ** that way. In other words, do not use this routine. This interface
7056 ** [sqlite3_release_memory()] interface, this interface is in effect even
7138 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
7155 ** NULL pointer, then this routine simply checks for the existence of the
7162 ** this function. ^(The second parameter is either the name of the database
7168 ** ^The third and fourth parameters to this function are the table and column
7172 ** and subsequent parameters to this function. ^Any of these arguments may be
7251 ** should free this memory by calling [sqlite3_free()].
7256 ** prior to calling this API,
7260 ** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this
7269 sqlite3 *db, /* Load the extension into this database connection */
7296 ** rather than this interface, so the [load_extension()] SQL function
7363 ** If this is a problem for you, do not use the interface at this time.
7366 ** interface fixed, support it indefinitely, and remove this comment.
7386 ** instance of this structure and passing a pointer to that instance
7390 ** of this structure must not change while it is registered with
7507 ** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
7539 unsigned char usable; /* True if this constraint is usable */
7550 unsigned char omit; /* Do not code a test for this constraint */
7556 double estimatedCost; /* Estimated cost of using this index */
7689 sqlite3 *db, /* Remove modules from this connection */
7698 ** of this object to describe a particular instance
7701 ** The purpose of this superclass is to define certain fields that are
7712 const sqlite3_module *pModule; /* The module for this virtual table */
7736 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
7744 ** [virtual table module] call this interface
7761 ** before this API is called, a new function is created.)^ ^The implementation
7771 ** to a comment remarkably similar to this one) is currently considered
7773 ** If this is a problem for you, do not use the interface at this time.
7776 ** interface fixed, support it indefinitely, and remove this comment.
7783 ** An instance of this object represents an open BLOB on which
7785 ** ^Objects of this type are created by [sqlite3_blob_open()]
7807 ** rather the symbolic name of the database. For attached databases, this is
7820 ** on *ppBlob after this function it returns.
7838 ** ^Unless it returns SQLITE_MISUSE, this function sets the
7861 ** the opened blob. ^The size of a blob may not be changed by this
7916 ** unconditionally. Even if this routine returns an error code, the
7925 ** Calling this function with an argument that is not a NULL pointer or an
7926 ** open blob handle results in undefined behaviour. ^Calling this routine
7928 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
7946 ** to this routine results in undefined and probably undesirable behavior.
7973 ** to this routine results in undefined and probably undesirable behavior.
7989 ** ^Unless SQLITE_MISUSE is returned, this function sets the
7995 ** this function returns [SQLITE_READONLY].
7998 ** not possible to increase the size of a BLOB using this API.
8015 ** to this routine results in undefined and probably undesirable behavior.
8081 ** implementation is included with the library. In this case the
8154 ** sqlite3_mutex_try() as an optimization so this is acceptable
8177 ** An instance of this structure defines the low-level routines
8183 ** does not provide a suitable implementation. In this case, the application
8184 ** creates and populates an instance of this structure to pass
8186 ** Additionally, an instance of this structure can be used as an
8190 ** ^The xMutexInit method defined by this structure is invoked as
8195 ** ^The xMutexEnd method defined by this structure is invoked as
8197 ** implementation of this method is expected to release all outstanding
8202 ** ^(The remaining seven methods defined by this structure (xMutexAlloc,
8219 ** by this structure are not required to handle this case. The results
8324 ** ^If the [threading mode] is Single-thread or Multi-thread then this
8342 ** ^The third and fourth parameters to this routine
8345 ** method becomes the return value of this routine.
8382 ** on how the SQLite library is compiled, this interface might not exist.
8386 ** Unlike most of the SQLite API, this function is not guaranteed to
8471 ** but it is what SQL Server does and so lots of programmers use this
8668 ** this parameter. The amount returned is the sum of the allocation
8807 ** with the database connection are shared, this request returns the same
8809 ** shared, the value returned by this call will be smaller than that returned
8903 ** ^If the resetFlg is true, then the counter is reset to zero after this
8921 ** a table as part of a full table scan. Large numbers for this counter
8927 ** A non-zero value in this counter may indicate an opportunity to
8933 ** A non-zero value in this counter may indicate an opportunity to
8943 ** then the value returned by this statement status code is undefined.
8952 ** been run. A single "run" for the purposes of this counter is one
9002 ** page cache. The page cache will allocate instances of this
9004 ** of this object as parameters or as their return value.
9024 ** custom page cache using this API, an application can better control
9068 ** though this is not guaranteed. ^The
9093 ** parameter, the implementation is not required to do anything with this
9312 ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
9316 ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
9398 ** is not accessed while the backup is running. In practice this means
9453 ** If this happens, then the specified callback is invoked immediately,
9499 ** action (a reasonable assumption), then using this API may cause the
9505 ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
9525 ** returned. In this case there is no "blocking connection", so invoking
9530 ** One way around this problem is to check the extended error code returned
9564 ** Note that this routine returns zero on a match and non-zero if the strings
9587 ** Note that this routine returns zero on a match and non-zero if the strings
9670 ** ^The callback registered by this function replaces any existing callback
9673 ** configured by this function.
9675 ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface
9678 ** ^Checkpoints initiated by this mechanism are
9683 ** pages. The use of this interface
9743 ** ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
9765 ** busy-handler configured, it will not be invoked in this case.
9776 ** without blocking any further. ^SQLITE_BUSY is returned in this case.
9780 ** [database connection] db. In this case the
9800 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
9832 ** If this interface is invoked outside the context of an xConnect or
9861 ** support constraints. In this configuration (which is the default) if
9874 ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode
9882 ** return SQLITE_OK. Or, if this is not possible, it may return
9951 ** this hint as permission to substitute a return value that is less
10010 ** of a [virtual table] implementation. The result of calling this
10083 ** The result of invoking this interface from any other context is
10090 ** this constraint, it must set the corresponding
10100 ** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
10115 ** parameter (F) is non-negative, this interface is the mechanism by
10205 ** of a [virtual table] implementation. The result of calling this interface
10211 ** J being a 0-based index into P->aConstraint[], then this routine
10237 ** The "_rhs_" in the name of this routine is an abbreviation for
10285 ** then this value will approximate the quotient NVISIT/NLOOP and the
10286 ** product of this value for all prior loops with the same SELECTID will
10319 ** performance for pStmt. Advanced applications can use this
10323 ** Since this interface is expected to be rarely used, it is only
10329 ** of this interface is undefined.
10339 ** where there exist loops with no available statistics, this function behaves
10376 ** ^If this function needs to obtain extra database locks before dirty pages
10382 ** because locks cannot be obtained, but no other error occurs, this
10479 ** in this case the new values are not available. In this case, when a
10516 ** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be
10556 ** this function is called, one is opened automatically.
10558 ** The following must be true for this function to succeed. If any of
10561 ** in this case.
10615 ** snapshot has been overwritten by a [checkpoint]. In this case
10618 ** If there is already a read transaction open when this function is
10650 ** using this routine to avoid a memory leak.
10672 ** wal file was last deleted, the value returned by this function
10675 ** Otherwise, this API returns a negative value if P1 refers to an older
10764 ** a contiguous in-memory database, then this option causes
10821 ** and that SQLite should take ownership of this memory and automatically
10822 ** free it when it has finished using it. Without this flag, the caller
10828 ** Without this flag, the deserialized database cannot increase in size beyond
10855 ** The author disclaims copyright to this source code. In place of
10931 ** Note that the first 5 fields of this structure are identical to
10939 void *pUser; /* callback can use this, if desired */
10976 ** Make sure we can call this stuff from C++.
10986 ** An instance of this object is a [session] that can be used to
10994 ** An instance of this object acts as a cursor for iterating
11011 ** Session objects created using this function should be deleted using the
11067 ** computational overhead, this API is disabled by default. Argument
11075 ** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
11095 ** Passing zero to this function disables the session. Passing a value
11123 ** flag. If the second argument passed to this function is zero, then the
11145 ** executing "CREATE TABLE" statements) after this call is made, changes for
11239 ** no corresponding change is present in the changesets returned by this
11252 ** Within a changeset generated by this function, all changes related to a
11260 ** Following a successful call to this function, it is the responsibility of
11283 ** When this function is called, the requested changeset is created using
11331 ** By default, this function always returns 0. For it to return
11333 ** to enable this API using sqlite3session_object_config() with the
11336 ** When enabled, this function returns an upper limit, in bytes, for the size
11339 ** size in bytes returned by this function.
11348 ** argument, this function attaches table zTbl in the same manner as the
11350 ** does not have a primary key, this function is a no-op (but does not return
11355 ** a table compatible with the table attached to the session by this function.
11370 ** used to update the table in database zFrom (call this the "from-table")
11372 ** object (call this the "to-table"). Specifically:
11386 ** To clarify, if this function is called and then a changeset constructed
11395 ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
11397 ** message. It is the responsibility of the caller to free this buffer using
11450 ** Even if this function returns zero, it is possible that calling
11454 ** are restored. However, if this function returns non-zero, then it is
11478 ** iterator created by this function:
11497 ** this function, all changes that relate to a single table are visited
11530 ** It is an error to specify this flag with a patchset.
11546 ** is not empty, the first call to this function advances the iterator to
11564 ** The pIter argument passed to this function may either be an iterator
11567 ** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this
11568 ** is not the case, this function returns [SQLITE_MISUSE].
11590 ** be trusted in this case.
11621 ** If this function is called when the iterator does not point to a valid
11636 ** The pIter argument passed to this function may either be an iterator
11642 ** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.
11648 ** If successful, this function sets *ppValue to point to a protected
11651 ** returns SQLITE_OK. The name of the function comes from the fact that this
11667 ** The pIter argument passed to this function may either be an iterator
11673 ** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.
11679 ** If successful, this function sets *ppValue to point to a protected
11685 ** this is similar to the "new.*" columns available to update or delete
11703 ** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function
11711 ** If successful, this function sets *ppValue to point to a protected
11730 ** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case
11734 ** In all other cases this function returns SQLITE_MISUSE.
11750 ** [sqlite3changeset_start()] function. If an application calls this
11758 ** to that error is returned by this function. Otherwise, SQLITE_OK is
11797 ** call to this function.
11860 ** If successful, this function returns SQLITE_OK and populates (*pp) with
11896 ** If the buffer contains a patchset, then all prior calls to this function
11898 ** the buffer contains a changeset, so must have the earlier calls to this
11956 ** primary key columns for the table must be consistent. If this is not the
11957 ** case, this function fails with SQLITE_SCHEMA. If the input changeset
11959 ** returned. Or, if an out-of-memory condition occurs during processing, this
11978 ** table are grouped together in the output of this function. Tables appear
11988 ** pointer to the output buffer, respectively. In this case it is the
12020 ** For each table that is not excluded by the filter callback, this function
12148 ** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase)
12163 sqlite3 *db, /* Apply change to "main" db of this handle */
12178 sqlite3 *db, /* Apply change to "main" db of this handle */
12206 ** applied, or rolled back if an error occurs. Specifying this flag
12207 ** causes the sessions module to omit this savepoint. In this case, if the
12214 ** an error to specify this flag with a patchset.
12232 ** The conflicting row, in this case, is the database row with the matching
12240 ** There is no conflicting row in this case. The results of invoking the
12248 ** The conflicting row in this case is the database row with the matching
12269 ** There is no conflicting row in this case. The results of invoking the
12287 ** If a conflict handler returns this value no special action is taken. The
12293 ** handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this
12303 ** second attempt to apply the change is made. If this second attempt fails,
12307 ** If this value is returned, any changes applied so far are rolled back
12371 ** the conflicting remote UPDATE removed. If this means no columns would
12465 ** should be one call to this function for each successful invocation
12491 ** Normally this is convenient. However, if an application running in a
12495 ** In order to avoid this problem, instead of a single large buffer, input
12518 ** should be set to zero to indicate this. Or, if an error occurs, an SQLite
12531 ** pointer to a single large buffer. In this case, a pair of parameters such
12552 ** it should return some other SQLite error code. In this case processing
12557 ** parameter set to a value less than or equal to zero. Other than this,
12561 sqlite3 *db, /* Apply change to "main" db of this handle */
12576 sqlite3 *db, /* Apply change to "main" db of this handle */
12658 ** the effect of calling this function depends on the value of the first
12665 ** to set and query the value of this configuration setting. The pointer
12667 ** If this value is greater than 0, it is used as the new streaming data
12684 ** Make sure we can call this stuff from C++.
12697 ** The author disclaims copyright to this source code. In place of
12706 ** Interfaces to extend FTS5. Using the interfaces defined in this file,
12805 ** (i.e. if it is a contentless table), then this API always returns 0.
12864 ** If there is already an auxiliary data pointer when this function is
12866 ** was specified along with the original pointer, it is invoked at this
12872 ** If an error (e.g. an OOM condition) occurs within this function,
12884 ** (set to NULL) before this function returns. In this case the xDelete,
12900 ** to use, this API may be faster under some circumstances. To iterate
12913 ** modify this structure directly - it should only be used as shown above
12920 ** (i.e. if it is a contentless table), then this API always iterates
12945 ** then this API always iterates through an empty set (all calls to
12948 ** The information accessed using this API and its companion
12950 ** (or xInst/xInstCount). The chief advantage of this API is that it is
13012 ** The first argument passed to this function is a copy of the (void*)
13023 ** be returned. In this case, fts5 assumes that the final value of *ppOut
13028 ** allocated using xCreate(). Fts5 guarantees that this function will
13034 ** argument passed to this function is a pointer to an Fts5Tokenizer object
13071 ** synonyms. In this case see the discussion below for details.
13094 ** There are several ways to approach this in FTS5:
13096 ** <ol><li> By mapping all synonyms to a single token. In this case, using
13097 ** the above example, this means that the tokenizer returns the
13106 ** separately. In this case, when tokenizing query text, the
13126 ** Using this method, when tokenizing document text, the tokenizer
13171 ** For full prefix support, method (3) may be preferred. In this case,
13174 ** extra entries are added to the FTS index, this method uses more space
13177 ** Method (2) offers a midpoint between (1) and (3). Using this method,
13293 ** The author disclaims copyright to this source code. In place of
13340 ** It used to be the case that setting this value to zero would
13342 ** to turn this limit off.
13427 /* Maximum page size. The upper bound on this value is 65536. This a limit
13430 ** Earlier versions of SQLite allowed the user to change this value at
13515 ** places. The following macros try to make this explicit.
13542 ** integers to pointers. The way you do this varies from one compiler
13546 ** The correct "ANSI" way to do this is to use the intptr_t type.
13556 #if defined(HAVE_STDINT_H) /* Use this case if we have ANSI headers */
13613 ** for compile-time options at runtime (e.g. "PRAGMA compile_options"), this
13677 ** sizes of memory allocations below this value where possible.
13695 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
13753 ** to setup for a later assert() statement. We do not want this code to
13891 ** The author disclaims copyright to this source code. In place of
13910 ** The internals of this structure are intended to be opaque -- client
13911 ** code should not attempt to access or modify the fields of this structure
13912 ** directly. Change this structure only by using the routines below.
13914 ** accessing this structure are really macros, so we can't really make
13915 ** this structure opaque.
13918 ** Hash.first points to the head of this list.
13932 unsigned int count; /* Number of entries in this table */
13935 unsigned int count; /* Number of entries with this hash */
13936 HashElem *chain; /* Pointer to first entry with this hash */
13943 ** Again, this structure is intended to be opaque, but it can't really
13948 void *data; /* Data associated with this element */
13949 const char *pKey; /* Key associated with this element */
13962 ** like this:
14185 ** cachegrind. But this macro version of memcpy() is very slow so it
14216 ** afterward. Having this macro allows us to cause the C compiler
14325 ** Check to see if this machine uses EBCDIC. (Yes, believe it or
14337 ** types can be conveniently redefined at compile-type. Like this:
14414 ** not exact values, this imprecision is not a problem.
14694 ** this magic value that the code knows to handle differently. Any
14706 ** macro is used for this purpose. And instead of referencing the variable
14733 ** if it knows that this is enforced elsewhere.
14810 ** Changing this from a 64-bit to a 32-bit type limits the number of
14853 ** The author disclaims copyright to this source code. In place of
14881 ** The author disclaims copyright to this source code. In place of
14994 ** Temporary files are named starting with this prefix followed by 16 random
15008 ** For this reason, the default name prefix is changed to be "sqlite"
15080 ** Locking in windows is manditory. For this reason, we cannot store
15171 ** The author disclaims copyright to this source code. In place of
15278 ** The remainder of this file contains the declarations of the functions
15426 ** The author disclaims copyright to this source code. In place of
15468 sqlite3_vfs *pVfs, /* VFS to use with this b-tree */
15593 ** might be fetched with this cursor. The Expr* tree may contain
15644 ** by this, the native b-tree engine of SQLite, but it is available to
15645 ** alternative storage engines that might be substituted in place of this
15722 ** the information into this object helps to keep the interface more
15845 ** The author disclaims copyright to this source code. In place of
15866 ** of this structure.
15912 u32 cnt; /* Number of times this instruction was executed */
15913 u64 cycles; /* Total time spent executing this instruction */
15916 u32 iSrcLine; /* Source-code line that generated this opcode
16238 ** generated this include file strives to group all JUMP opcodes
16432 ** is responsible for keeping track of this and reporting byte-code branches
16483 ** The author disclaims copyright to this source code. In place of
16508 PCache *pCache; /* PRIVATE: Cache that owns this page */
16510 Pager *pPager; /* The pager this page is part of */
16511 Pgno pgno; /* Page number for this page */
16522 i16 nRef; /* Number of users of this page */
16534 ** writing this page to the database */
16678 ** The author disclaims copyright to this source code. In place of
16688 ** The sqliteInt.h header #includes this file so that it is available
16692 ** NOTE: source files should *not* #include this header file directly.
16694 ** include this one indirectly.
16706 ** mutual exclusion is provided. But this
16729 ** If this is a no-op implementation, implement everything as macros.
16789 char *zDbSName; /* Name of this database. (schema name, not filename) */
16790 Btree *pBt; /* The B*Tree structure for this database file */
16814 int schema_cookie; /* Database schema version number for this file */
16821 u8 file_format; /* Schema format version for this file */
16822 u8 enc; /* Text encoding used by this database */
16823 u16 schemaFlags; /* Flags associated with this schema */
17025 int errMask; /* & result codes with this before returning */
17127 i64 nDeferredCons; /* Net deferred constraints this transaction. */
17129 int *pnBytesFreed; /* If not NULL, increment this in DbFree() */
17256 /* TH3 expects this value ^^^^^^^^^^ to be 0x0000800. Don't change it */
17264 /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */
17270 /* TH3 expects this value ^^^^^^^^^^ See flatten04.test */
17300 ** a pointer to this structure is held in the sqlite3BuiltinFunctions object.
17301 ** For per-connection application-defined functions, a pointer to this
17327 ** a single object of this type is allocated. FuncDestructor.nRef is set to
17334 ** count on this object is decremented. When it reaches 0, the destructor
17347 ** are assert() statements in the code to verify this.
17416 ** optional SQLITE_FUNC_ flags for this function.
17422 ** optional SQLITE_FUNC_ flags for this function.
17435 ** Used for "pure" date/time functions, this macro is like DFUNCTION
17543 int nRefModule; /* Number of pointers to this object */
17546 Table *pEpoTab; /* Eponymous table for this module */
17575 char *zCnName; /* Name of this column */
17579 u8 szEst; /* Est size of value in this column. sizeof(INT)==1 */
17612 #define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */
17618 #define COLFLAG_NOEXPAND 0x0400 /* Omit this column when expanding "*" */
17689 ** An object of this type is created for each virtual table present in
17692 ** If the database schema is shared, then there is one instance of this
17726 ** The memory for objects of this type is always allocated by
17731 sqlite3 *db; /* Database connection associated with this table */
17734 int nRef; /* Number of pointers to this structure */
17754 Index *pIndex; /* List of SQL indexes on this table. */
17758 Pgno tnum; /* Root BTree page for this table */
17759 u32 nTabRef; /* Number of pointers to this Table */
17762 i16 nCol; /* Number of columns in this table */
17767 LogEst costMult; /* Cost multiplier for using this table */
17774 FKey *pFKey; /* Linked list of all foreign keys in this table */
17787 Trigger *pTrigger; /* List of triggers on this object */
17788 Schema *pSchema; /* Schema that contains this table */
17797 ** the TF_OOOHidden attribute would apply in this case. Such tables require
17821 #define TF_HasStat4 0x00002000 /* STAT4 info available for this table */
17878 ** Consider this example:
17906 int nCol; /* Number of columns in this key */
17972 u32 nRef; /* Number of references to this KeyInfo object */
17997 ** An instance of this object serves as a "key" for doing a search on
17999 ** is closed to the key described by this object. This object might hold
18003 ** The r1 and r2 fields are the values to return if this key is less than
18016 ** get and equal results when comparing this structure to a b-tree record.
18044 ** by the aiColumn[] field of this structure. For example, suppose
18060 ** it means this is not a unique index. Otherwise it is a unique index
18080 ** of this structure may be created. In this case the Index.tnum variable is
18086 char *zName; /* Name of this index */
18087 i16 *aiColumn; /* Which columns are used by this index. 1st is 0 */
18092 Schema *pSchema; /* Schema containing this index */
18097 Pgno tnum; /* DB Page containing root of this index */
18103 unsigned bUnordered:1; /* Use this index for == or IN queries only */
18106 unsigned isCovering:1; /* True if this is a covering index */
18109 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
18119 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
18147 ** using a structure of this type. See documentation at the top of the
18153 tRowcnt *anEq; /* Est. number of rows where the key equals this sample */
18154 tRowcnt *anLt; /* Est. number of rows where key is less than this sample */
18155 tRowcnt *anDLt; /* Est. number of distinct keys less than this sample */
18166 ** this structure. Tokens are also used as part of an expression.
18176 unsigned int n; /* Number of characters in this token */
18180 ** An instance of this structure contains information needed to generate
18184 ** pointer to this structure. The Expr.iAgg field is the index in
18222 u32 selId; /* Select to which this AggInfo belongs */
18243 ** of this structure.
18305 u8 op; /* Operation performed by this node */
18321 ** space is allocated for the fields below this point. An attempt to
18333 ** space is allocated for the fields below this point. An attempt to
18338 int nHeight; /* Height of the tree headed by this node */
18434 #define EP_NoReduce 0x01 /* Cannot EXPRDUP_REDUCE this Expr */
18435 #define EP_Immutable 0x02 /* Do not change this Expr node */
18504 Expr *pExpr; /* The parse tree for this expression */
18505 char *zEName; /* Token associated with this expression */
18537 ** An instance of this structure can hold a simple list of identifiers,
18576 ** and the next table on the list. The parser builds the list this way.
18591 Schema *pSchema; /* Schema to which this item is fixed */
18592 char *zDatabase; /* Name of database holding this table */
18601 u8 jointype; /* Type of join between this table and the previous */
18617 int iCursor; /* The VDBE cursor number used to access this table */
18727 AggInfo *pAggInfo; /* Information about aggregates at this level */
18732 int nRef; /* Number of names resolved by this context */
18791 /* Above this point is the parse tree for the ON CONFLICT clauses.
18828 u32 selId; /* Unique identifier number for this SELECT */
18829 int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */
18839 With *pWith; /* WITH clause attached to this select. Or NULL. */
18862 #define SF_Expanded 0x0000040 /* sqlite3SelectExpand() called on this */
18878 #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18921 ** this destination uses OP_OpenEphemeral to create
18951 ** table is an intkey table - in this case the first
18955 ** each index record in this case.
18983 ** An instance of this object describes where to put of the results of
19007 Table *pTab; /* Table this info block refers to */
19031 Trigger *pTrigger; /* Trigger this program was coded from */
19061 ** there is an instance of this object on the Parse.pIdxExpr list.
19064 ** this list is consulted and if a matching expression is found, the value
19091 ** An SQL parser context. A copy of this structure is passed through
19316 IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger,
19343 ** The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or
19352 ** pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ...
19353 ** statement, then this stores the column-names to be
19381 Trigger *pTrig; /* The trigger that this step is a part of */
19389 char *zSpan; /* Original SQL text of this command */
19428 ** A pointer to this structure is used to communicate information
19593 Schema *pSchema; /* Fix items to this schema */
19595 const char *zDb; /* Make sure all objects are contained in this database */
19635 char *zName; /* Name of this CTE */
19637 Select *pSelect; /* The definition of this CTE */
19639 CteUse *pUse; /* Usage information for this CTE */
19673 int nUse; /* Number of users of this CTE */
19697 ** (1) A single instance of this structure is attached to the
19706 ** (3) The terms of the WINDOW clause of a SELECT are instances of this
19710 ** of this object is stored in Expr.y.pWin with eFrmType set to
19711 ** TK_FILTER. In this case the only field used is Window.pFilter.
19728 Window **ppThis; /* Pointer to this object in Select.pWin list */
19729 Window *pNextWin; /* Next window function belonging to this SELECT */
19738 Expr *pOwner; /* Expression object this window is attached to */
19740 int iArgCol; /* Offset of first argument for this function */
20795 ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
20798 ** this case foreign keys are parsed, but no other functionality is
20938 ** this constraint.
20940 ** All of this is no-op for a production build. It only comes into
20992 ** The author disclaims copyright to this source code. In place of
21014 ** switch. The following code should catch this problem at compile-time.
21035 ** The author disclaims copyright to this source code. In place of
21109 ** and analysis configurations, not in any deliverable, so this
21194 ** To modify this header, edit any of the various lists in that script
21195 ** which specify categories of generated conditionals in this file.
21201 ** The author disclaims copyright to this source code. In place of
21241 ** only a handful of compile-time options, so most times this array is usually
21989 ** The author disclaims copyright to this source code. In place of
22058 ** this order: NE EQ GT LE LT GE. Various assert()s throughout the code
22173 Contact SQLite developers if this is a problem for you, and\
22174 delete this #error macro to continue with your build."
22178 /* The minimum PMA size is set to this value multiplied by the database
22190 ** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this
22292 ** database connections. After initialization, this table is
22302 ** Access to this global variable is not mutex protected. This might
22394 ** The author disclaims copyright to this source code. In place of
22412 ** The author disclaims copyright to this source code. In place of
22424 ** this header information was factored out.
22491 u8 seekOp; /* Most recent seek operation on this cursor */
22497 Bool noReuse:1; /* OpenEphemeral may not reuse this cursor */
22509 u32 cacheStatus; /* Cache is valid if this matches Vdbe.cacheCtr */
22513 ** on this cursor" and "the most recent seek was an exact match".
22536 u64 maskUsed; /* Mask of columns used by this cursor */
22557 ** When a sub-program is executed (OP_Program), a structure of this type
22570 ** this instead of deleting the VdbeFrame immediately is to avoid recursive
22579 Vdbe *v; /* VM this frame belongs to */
22580 VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */
22628 u8 eSubtype; /* Subtype for this value */
22687 ** Usually this is encoded in the same unicode encoding as the main
22753 ** of this structure. All such structures associated with a single VM
22767 ** instance of this structure is the first argument to the routines used
22770 ** There is a typedef for this structure in sqlite.h. So all routines,
22771 ** even the public interface to SQLite, can use a pointer to this structure.
22772 ** But this file is the only place where the internal details of this
22782 Vdbe *pVdbe; /* The VM that owns this context */
22804 int iSelectID; /* The "Select-ID" for this loop */
22827 ** is really a pointer to an instance of this structure.
22830 sqlite3 *db; /* The database connection that owns this statement */
22832 Parse *pParse; /* Parsing context used to create this Vdbe */
22841 i64 iCurrentTime; /* Value of julianday('now') for this statement */
22842 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
22847 VdbeCursor **apCsr; /* One element of this array for each open cursor */
22881 char *zSql; /* Text of the SQL statement that generated this */
22886 void *pFree; /* Free this when deleting the vdbe */
22937 ** An instance of this object is used to pass an vector of values into
22945 ** know how to use this object to step through all the values in the
23507 ** The author disclaims copyright to this source code. In place of
23518 ** There is only one exported symbol in this file - the function
23538 ** dates afterwards, depending on locale. Beware of this difference.
23603 ** D: the separator character, or \000 to indicate this is the
23902 ** Multiplying this by 86400000 gives 464269060799999 as the maximum value
24009 ** If the sqlite3GlobalConfig.bLocaltimeFault variable is non-zero then this
24014 ** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
24084 ** works for years between 1970 and 2037. For dates outside this range,
24085 ** SQLite attempts to map the year into an equivalent year within this
24130 float rLimit; /* Maximum NNN value for this transform */
24131 float rXform; /* Constant used for this transform */
24204 ** Always interpret the prior number as a julian-day value. If this
24255 int iErr; /* Guess is off by this much */
24287 ** date is already on the appropriate weekday, this is a no-op.
24377 /* If control reaches this point, it means the transformation is
24838 ** functions. This should be the only routine in this file with
24867 ** The author disclaims copyright to this source code. In place of
24942 ** of this would be completely automatic if SQLite were coded using
25002 ** transaction has been committed. Injecting a fault at this point
25317 ** The author disclaims copyright to this source code. In place of
25334 ** fatal. For example, if a malloc fails while resizing a hash table, this
25407 ** The author disclaims copyright to this source code. In place of
25443 ** This routine is the only routine in this file with external linkage.
25446 ** sqlite3GlobalConfig.m with pointers to the routines in this file.
25469 ** The author disclaims copyright to this source code. In place of
25484 ** this file is only used if SQLITE_SYSTEM_MALLOC is defined. The
25487 ** default configuration is to use memory allocation routines in this
25492 ** HAVE_MALLOC_USABLE_SIZE The configure script sets this symbol if
25494 ** on the target platform. Or, this symbol
25501 ** memory allocator. Set this symbol to enable
25504 ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of
25589 ** For this low-level routine, we are guaranteed that nByte>0 because
25623 ** For this low-level routine, we already know that pPrior!=0 since
25659 ** For this low-level interface, we know that pPrior!=0. Cases where
25702 ** Initialize this module.
25729 ** Deinitialize this module.
25737 ** This routine is the only routine in this file with external linkage.
25740 ** sqlite3GlobalConfig.m with pointers to the routines in this file.
25763 ** The author disclaims copyright to this source code. In place of
25802 ** Each memory allocation looks like this:
25815 i64 iSize; /* Size of this allocation */
25817 char nBacktrace; /* Number of backtraces on this alloc */
25836 ** All of the static variables used by this module are collected
25839 ** when this module is combined with other in the amalgamation.
26096 ** For this debugging implementation, we *always* make a copy of the
26097 ** allocation into a new place in memory. In this way, if the
26121 ** sqlite3GlobalConfig.m with pointers to the routines in this file.
26294 ** The author disclaims copyright to this source code. In place of
26320 ** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not
26356 ** this is done, the chunk index refers to the second block of
26357 ** the chunk. In this way, the first chunk has an index of 1.
26385 ** All of the static variables used by this module are collected
26388 ** when this module is combined with other in the amalgamation.
26415 ** occur off of this chunk. szKeyBlk is the size (in Mem3Blocks)
26599 ** this mem3.iKeyBlk replacement to work, the key chunk must be
26602 ** chunk before invoking this routine, then must unlink the (possibly
26603 ** changed) key chunk once this routine has finished.
26840 ** Initialize this module.
26865 ** Deinitialize this module.
26953 ** This routine is the only routine in this file with external
26957 ** sqlite3GlobalConfig.m with pointers to the routines in this file. The
26984 ** The author disclaims copyright to this source code. In place of
27023 ** proved that this memory allocator will never breakdown due to
27029 ** that an application can, at any time, verify this constraint.
27044 ** The size of this object must be a power of two. That fact is
27056 ** it is not actually possible to reach this limit.
27063 #define CTRL_LOGSIZE 0x1f /* Log2 Size of this block */
27067 ** All of the static variables used by this module are collected
27070 ** when this module is combined with other in the amalgamation.
27196 ** The caller has obtained a mutex prior to invoking this
27198 ** threads can be in this routine at the same time.
27349 ** The outer layer memory allocator prevents this routine from
27362 ** The outer layer memory allocator prevents this routine from
27368 ** (an allocation larger than 0x40000000) was requested and this
27394 ** the allocation is too large to be handled by this allocation system,
27441 int nByte; /* Number of bytes of memory available to this allocator */
27442 u8 *zByte; /* Memory usable by this allocator */
27448 /* For the purposes of this routine, disable the mutex */
27452 ** this is case.
27495 ** Deinitialize this module.
27547 ** This routine is the only routine in this file with external
27572 ** The author disclaims copyright to this source code. In place of
27618 ** or one of the static mutex identifiers. Or, if this is a recursive mutex
27905 ** this function is a no-op.
27936 ** The author disclaims copyright to this source code. In place of
27946 ** This implementation in this file does not provide any mutual
28004 ** In this implementation, error checking is provided for testing
28154 ** The author disclaims copyright to this source code. In place of
28167 ** The code in this file is only used if we are compiling threadsafe
28170 ** Note that this implementation requires a version of pthreads that
28198 volatile pthread_t owner; /* Thread that is within this mutex */
28551 ** The author disclaims copyright to this source code. In place of
28577 ** The author disclaims copyright to this source code. In place of
28668 ** The code in this file is only used if we are compiling multithreaded
28681 volatile DWORD owner; /* Thread holding this mutex */
28961 ** For that reason, we will omit this optimization for now. See
29045 ** The author disclaims copyright to this source code. In place of
29130 ** The return value is the value of the heap limit just before this
29172 ** calling this interface.
29246 ** checked out since either the beginning of this process
29667 ** code that do things like this:
29832 ** SQL statement. Make a copy of this phrase in space obtained form
29853 ** Call this routine to record the fact that an OOM (out-of-memory) error
29858 ** Always return a NULL pointer so that this routine can be invoked using
29918 ** The returned value is normally a copy of the second argument to this
30333 ** At this point, variables are initialized as follows:
30847 ** at this point. If the "!" flag was present on string conversions
30849 ** then the values have been translated prior to reaching this point.
30929 ** to avoid having to call this routine too often */
31226 ** this without breaking compatibility, so we just have to live with the
31335 ** The author disclaims copyright to this source code. In place of
31348 ** The interfaces in this file is only available when compiling
31355 ** Add a new subitem to the tree. The moreToFollow flag indicates that this
32102 ** trigger programs. In this case Expr.iTable is set to 1 for the
32628 ** The author disclaims copyright to this source code. In place of
32719 ** the first time this routine is called.
32788 ** The author disclaims copyright to this source code. In place of
33065 ** The author disclaims copyright to this source code. In place of
33213 ** For this routine, we assume the UTF8 string is always zero-terminated.
33436 ** changed by this function.
33603 ** The author disclaims copyright to this source code. In place of
33783 ** stored by this function into the database handle using sqlite3Error().
33829 ** input does not begin with a quote character, then this routine
33880 ** system should still return the correct answer even if this routine
34009 ** Convert this string to a double and write it into *pResult.
34032 ** If some prefix of the input string is a valid number, this routine
34263 ** Unlike memcmp() this routine is guaranteed to return the difference
34688 /* we can skip this cause it was (effectively) done above in calc'ing s */
34762 ** this function assumes the single-byte case has already been handled.
34865 /* We can only reach this point when reading a corrupt database
34988 ** NULL or which have been previously closed. If this routine returns
35238 ** int iValue; // Value for this entry
35239 ** int nSlot; // Slots used by this entry
35321 ** The author disclaims copyright to this source code. In place of
35349 ** Call this routine to delete a hash table or to reset a hash table
35438 ** only zeroes the requested number of bytes whereas this module will
35462 ** If pH is not NULL, then the hash for this key is written to *pH.
35531 ** that matches pKey. Return the data for this element if it is
35548 ** The key is not copied in this instance. If a malloc fails, then
35551 ** If the "data" parameter to this function is NULL, then the
35799 ** The author disclaims copyright to this source code. In place of
35835 ** Forward declaration of objects used by this VFS implementation
35839 /* A single open file. There are only two files represented by this
35845 int isJournal; /* True if this is a journal file */
36011 ** this routine is a no-op.
36031 ** If nBuf<=0 then this routine simply returns the size of the data without
36079 ** Maintenance reminder: if this struct changes in any way, the JSON
36099 ** the compiler can hopefully optimize this level of indirection out.
36102 ** Note that this is not explicitly flagged as static because the
36774 ** The author disclaims copyright to this source code. In place of
36786 ** There are actually several different VFS implementations in this file.
36887 ** None if this matters except when building on Apple products with
36980 int flags; /* Flags this file descriptor was opened with */
36991 sqlite3_vfs *pVfs; /* The VFS that created this unixFile */
36992 unixInodeInfo *pInode; /* Info about locks on this inode */
36994 unsigned char eFileLock; /* The type of lock held on this fd */
37018 unsigned iBusyTimeout; /* Wait this many millisec on locks */
37038 /* In test mode, increase the size of this structure a bit so that
37160 ** The safest way to deal with the problem is to always use this wrapper
37465 ** Do not accept any file descriptor less than this value, in order to avoid
37533 ** vxworksFileId objects used by this file, all of which may be
37652 ** All calls to ftruncate() within this file should be made through
37653 ** this wrapper. On the Android platform, bypassing the logic below
37710 ** the device number and the inode number. But this does not work on VxWorks.
37714 ** unique file ID in VxWorks. Each instance of this structure contains
37725 int nRef; /* Number of references to this one */
37732 ** All unique filenames are held on a linked list headed by this
37850 ** by the same process. It does not explicitly say so, but this implies
37852 ** file descriptor. Consider this test case:
37904 ** released. To work around this problem, each unixInodeInfo object
37946 ** To work around this, always allocate 64-bits for the inode number.
37947 ** On small machines that only have 32-bit inodes, this wastes 4 bytes,
37959 ** structure contains a pointer to an instance of this object and this
37981 sqlite3_mutex *pLockMutex; /* Hold this mutex for... */
37987 int nRef; /* Number of pointers to this structure */
37988 unixShmNode *pShmNode; /* Shared memory associated with this inode */
38003 ** Must hold unixBigLock in order to read or write this variable.
38049 /* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use
38113 ** Set the pFile->lastErrno. Do this in a subroutine as that provides
38139 ** The global mutex must be held when this routine is called, but the mutex
38175 ** The global mutex must held when calling this routine.
38210 ** around this problem (we consider it a bug in OS X, not SQLite)
38214 ** in the header of every SQLite database. In this way, if there
38330 ** file by this or any other process. If such a lock is held, set *pResOut
38345 /* Check if a thread in this process holds such a lock */
38381 ** There are two versions of this routine. If compiled with
38425 ** within this process, but all of that is handled in memory and the
38433 ** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).
38498 ** byte'. If this is successful, 'shared byte range' is read-locked
38503 ** Windows95 is now pretty much extinct, but this work-around for the
38522 ** within this range, this ensures that no other locks are held on the
38537 /* If there is already a lock of this type or more restrictive on the
38561 /* If some thread using this PID has a lock via a different unixFile*
38571 /* If a SHARED lock is requested, and some thread using this PID already
38609 /* If control gets to this point, then actually go ahead and make
38646 /* We are trying for an exclusive lock but another thread in this
38727 ** the requested locking level, this routine is a no-op.
38828 ** process is holding an incompatible lock. If it does, this
38830 ** protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning
38853 ** OS call only when all threads in this same process have released
38871 /* Decrement the count of locks against this same file. When the
38893 ** the requested locking level, this routine is a no-op.
38913 ** It is *not* necessary to hold the mutex when this routine is called,
38990 ** Of the various locking implementations available, this is by far the
38999 ** corruption if this locking mode is used in situations where multiple
39058 ** file by this or any other process. If such a lock is held, set *pResOut
39062 ** In dotfile locking, either a lock exists or it does not. So in this
39153 ** the requested locking level, this routine is a no-op.
39219 ** still works when you do this, but concurrency is reduced since
39222 ** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off
39242 ** file by this or any other process. If such a lock is held, set *pResOut
39255 /* Check if a thread in this process holds such a lock */
39368 ** the requested locking level, this routine is a no-op.
39432 ** file by this or any other process. If such a lock is held, set *pResOut
39445 /* Check if a thread in this process holds such a lock */
39534 ** the requested locking level, this routine is a no-op.
39601 ** Third-party implementations of AFP are available. But this code here
39622 int fd; /* file desc to assoc this lock with */
39675 ** file by this or any other process. If such a lock is held, set *pResOut
39694 /* Check if a thread in this process holds such a lock */
39759 /* If there is already a lock of this type or more restrictive on the
39783 /* If some thread using this PID has a lock via a different unixFile*
39793 /* If a SHARED lock is requested, and some thread using this PID already
39823 /* If control gets to this point, then actually go ahead and make
39861 /* We are trying for an exclusive lock but another thread in this
39892 /* Can't reestablish the shared lock. Sqlite can't deal, this is
39928 ** the requested locking level, this routine is a no-op.
39999 ** OS call only when all threads in this same process have released
40079 ** the requested locking level, this routine is a no-op.
40101 ** are gather together into this division.
40178 /* If this is a database file (not a journal, super-journal or temp
40188 /* Deal with as much of this read request as possible by transfering
40251 const void *pBuf, /* Copy data from this buffer to the file */
40314 /* If this is a database file (not a journal, super-journal or temp
40346 /* Deal with as much of this write request as possible by transfering
40475 ** FULLSYNC. This is used during testing to verify that this procedure
40502 ** isn't supported for this file system. So, attempt an fsync
40542 ** The ability to override this routine was added in support of the
40545 ** replace this routine with a harmless no-op. To make this routine
40583 ** If we do not do this and we encounter a power failure, the directory
40645 /* If the user has configured a chunk-size for this file, truncate the
40675 ** use read() and write() to access data beyond this point from now on.
40704 ** layers, we need to report this file size as zero even though it is
40725 ** nBytes or larger, this routine is a no-op.
40812 ** If *pArg is initially negative then this is a query. Set *pArg to
40947 /* The pager calls this method to signal that it has done
40977 ** If pFd->sectorSize is non-zero when this function is called, it is a
40982 ** There are two versions of this function. One for QNX and one for all
41088 ** SQLite code assumes this function cannot fail. It also assumes that
41123 ** This function should not be called directly by other code in this file.
41145 ** of this unixShmNode object. In other words, each wal-index is opened
41149 ** We could coalesce this object into unixInodeInfo, but that would mean
41151 ** open files) would have to carry around this extra information. So
41152 ** the unixInodeInfo object contains a pointer to this unixShmNode object
41156 ** this object or while reading or writing the following fields:
41167 ** in this structure.
41170 unixInodeInfo *pInode; /* unixInodeInfo that owns this SHM node */
41171 sqlite3_mutex *pShmMutex; /* Mutex to access this object */
41179 int nRef; /* Number of unixShm objects pointing to this */
41180 unixShm *pFirst; /* All unixShm objects pointing to this */
41190 ** Structure used internally by this VFS to record the state of an
41193 ** The following fields are initialized when this object is created and
41206 u8 id; /* Id of this connection within its unixShmNode */
41222 ** SQLite error code. The final value of *piOut is undefined in this
41263 unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */
41338 ** Usually, this is 1. The exception seems to be systems that are configured
41339 ** to use 64KB pages - in this case each mapping must cover at least two
41386 ** If the DMS cannot be locked because this is a readonly_shm=1
41396 ** a SHARED lock, then this process may also take a SHARED lock
41399 ** Or, if no other process is holding any lock, then this process
41400 ** is the first to open it. In this case take an EXCLUSIVE lock on the
41406 ** version of this code attempted the SHARED lock at this point. But
41407 ** this introduced a subtle race condition: if the process holding
41408 ** EXCLUSIVE failed just before truncating the *-shm file, then this
41460 ** in database corruption. Nevertheless, this tmpfs file usage
41470 ** file are currently open, in this process or in other processes, then
41561 /* If this process is running as root, make sure that the SHM file
41614 ** been allocated, it is allocated by this function.
41617 ** this call as described above, then it is mapped into this processes
41665 /* The requested region is not mapped into this processes address space.
41682 /* Alternatively, if bExtend is true, extend the file. Do this by
41707 /* Map the requested memory region into this processes address space. */
41837 /* Check that, if this to be a blocking lock, no locks that occur later
41844 ** In other words, if this is a blocking lock, none of the locks that
41907 /* Make sure no sibling connections hold locks that will block this
41960 ** If there is no shared memory associated with the connection then this
42034 ** If successful, this function sets the following variables:
42041 ** the three variables above are zeroed. In this case SQLite should
42114 ** in this case. */
42124 ** there already exists a mapping for this file, and there are still
42125 ** outstanding xFetch() references to it, this function is a no-op.
42169 ** value of *pp is undefined in this case.
42171 ** If this function does return a pointer, the caller must eventually
42196 ** If the third argument is non-NULL, then this function releases a
42198 ** argument passed to this function must be the same as the corresponding
42201 ** Or, if the third argument is NULL, then this function is being called
42256 ** (2) A constant pointer to this function named just "F".
42260 ** objects. We have to do this instead of letting pAppData point
42265 ** Each instance of this macro generates two objects:
42381 ** secondary files. For this reason, the division that implements
42604 ** descriptors on this file, then no malloc would be required by
42605 ** findInodeInfo(). If this is the case, it is quite safe to close
42760 /* It's odd to simulate an io-error here, but really this is just
42761 ** using the io-error infrastructure to test that SQLite handles this
42802 ** argument to this function.
42808 ** describing "Posix Advisory Locking" at the start of this file for
42827 /* A stat() call may fail for various reasons. If this happens, it is
42829 ** For this reason, if an error occurs in the stat() call here, it is
42889 ** In most cases, this routine sets *pMode to 0, which will become
42893 ** this function queries the file-system for the permissions on the
42894 ** corresponding database file and sets *pMode to this value. Whenever
42949 /* If this is a main database file and the file was opened using a URI
42964 ** Previously, the SQLite OS layer used three functions in place of this
42979 ** file handle closed. To achieve the same effect using this new
42984 sqlite3_vfs *pVfs, /* The VFS for which this is the xOpen method */
43010 /* If creating a super- or main-file journal, this function will open
43020 /* If argument zPath is a NULL pointer, this function is required to open
43021 ** a temporary file. Use this buffer to store the file name in.
43145 ** same as the owner of the database file. Try to ensure that this is
43148 ** this step, if a root process opens a database file, it can leave
43266 sqlite3_vfs *NotUsed, /* VFS containing this as the xDelete method */
43314 sqlite3_vfs *NotUsed, /* The VFS containing this xAccess method */
43384 ** of a pathname is allowed since this is important on windows. */
43400 /* If this is a "/.." directory component then back out the
43426 ** (in this case, MAX_PATHNAME bytes). The full-path is written to
43427 ** this buffer before returning.
43447 /* It's odd to simulate an io-error here, but really this is just
43448 ** using the io-error infrastructure to test that SQLite handles this
43526 ** SQLite calls this function immediately after a call to unixDlSym() or
43732 ** Proxy locking is a "uber-locking-method" in this sense: It uses the
43735 ** this reason, the division that implements of proxy locking is deferred
44004 ** 2. if that fails, and this is a lock file (not-conch), try creating
44370 /* update conch with host and path (this will fail if other process
44377 /* We are trying for an exclusive lock but another thread in this
44779 ** Within this division (the proxying locking implementation) the procedures
44780 ** above this point are all utilities. The lock-related methods of the
44787 ** file by this or any other process. If such a lock is held, set *pResOut
44852 ** the requested locking level, this routine is a no-op.
44927 ** should be the only routines in this file that are visible from other
44932 ** necessarily been initialized when this routine is called, and so they
44944 ** The FINDER parameter to this macro is the name of the pointer to the
45061 ** Some operating systems might need to do some cleanup in this routine,
45077 ** The author disclaims copyright to this source code. In place of
45298 ** Some Microsoft compilers lack this definition.
45338 sqlite3_vfs *pVfs; /* The VFS used to open this file */
45340 u8 locktype; /* Type of lock currently held on this file */
45345 winShm *pShm; /* Instance of shared memory on this file */
45347 const char *zPath; /* Full pathname of this file */
45353 winceLock local; /* Locks obtained by this instance of winFile */
45397 * If this is non-zero, an isolated heap will be created by the native Win32
45399 * setting has no effect when compiling for WinRT. By default, this is enabled
45403 * WARNING: It is important to note that when this setting is non-zero and the
45552 ** can manually set this value to 1 to emulate Win98 behavior.
46192 ** So do not try to make this is into a redefinable interface.
46318 ** If a Win32 native heap has been configured, this function will attempt to
46359 ** If a Win32 native heap has been configured, this function will attempt to
46375 ** At this point, there should be no outstanding memory allocations on
46485 ** this routine is used to determine if the host is Win95/98/ME or
46643 ** Initialize this module.
46692 ** Deinitialize this module.
46719 ** sqlite3GlobalConfig.m with pointers to the routines in this file. The
47203 ** retried. The argument to this macro should be a variable.
47224 ** If a ReadFile() or WriteFile() error occurs, invoke this routine
47653 ** Some Microsoft compilers lack this definition.
47698 ** Same as above, except that this implementation works for WinRT.
47795 void *pBuf, /* Write content into this buffer */
47797 sqlite3_int64 offset /* Begin reading at this offset */
47815 /* Deal with as much of this read request as possible by transfering
47893 /* Deal with as much of this write request as possible by transfering
47984 int rc = SQLITE_OK; /* Return code for this function */
47995 ** No real harm comes of this - the database file is not corrupted,
48004 ** can maybe revisit this decision in the future.
48015 /* If the user has configured a chunk-size for this file, truncate the
48231 ** Different API routines are called depending on whether or not this
48319 int newLocktype; /* Set pFile->locktype to this value before exiting */
48320 int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */
48328 /* If there is already a lock of this type or more restrictive on the
48363 ** If you are using this code as a model for alternative VFSes, do not
48364 ** copy this retry logic. It is a hack intended for Windows only.
48456 ** file by this or any other process. If such a lock is held, return
48489 ** the requested locking level, this routine is a no-op.
48491 ** It is not possible for this routine to fail if the second argument
48492 ** is NO_LOCK. If the second argument is SHARED_LOCK then this routine
48531 ** Of the various locking implementations available, this is by far the
48540 ** corruption if this locking mode is used in situations where multiple
48567 ** If *pArg is initially negative then this is a query. Set *pArg to
48721 ** SQLite code assumes this function cannot fail. It also assumes that
48753 ** this file, all of which may be shared by multiple threads.
48780 ** point to a single instance of this object. In other words, each
48784 ** this object or while reading or writing the following fields:
48796 ** in this structure.
48800 sqlite3_mutex *mutex; /* Mutex to access this object */
48815 int nRef; /* Number of winShm objects pointing to this */
48816 winShm *pFirst; /* All winShm objects pointing to this */
48826 ** The winShmMutexHeld() must be true while reading or writing this list.
48831 ** Structure used internally by this VFS to record the state of an
48834 ** The following fields are initialized when this object is created and
48850 u8 id; /* Id of this connection with its winShmNode */
48867 winShmNode *pFile, /* Apply locks to this open shared-memory segment */
48961 ** If the DMS cannot be locked because this is a readonly_shm=1
48991 ** file are currently open, in this process or in other processes, then
49175 /* See if any siblings hold this same lock */
49223 /* Make sure no sibling connections hold locks that will block this
49278 ** been allocated, it is allocated by this function.
49281 ** this call as described above, then it is mapped into this processes
49322 /* The requested region is not mapped into this processes address space.
49349 /* Map the requested memory region into this processes address space. */
49475 ** there already exists a mapping for this file, and there are still
49476 ** outstanding xFetch() references to it, this function is a no-op.
49581 ** value of *pp is undefined in this case.
49583 ** If this function does return a pointer, the caller must eventually
49619 ** If the third argument is non-NULL, then this function releases a
49621 ** argument passed to this function must be the same as the corresponding
49624 ** Or, if the third argument is NULL, then this function is being called
49827 /* It's odd to simulate an io-error here, but really this is just
49828 ** using the io-error infrastructure to test that SQLite handles this
49834 ** name for the temporary file. If this fails, we cannot continue.
49926 /* At this point, we know the candidate directory exists and should
50079 int flags, /* Type of test to make on this file */
50108 /* If argument zPath is a NULL pointer, this function is required to open
50109 ** a temporary file. Use this buffer to store the file name in.
50172 /* If the second argument to this function is NULL, generate a
50403 ** whatever it does. While this other process is holding the
50404 ** file open, we will be unable to delete it. To work around this
50520 int flags, /* Type of test to make on this file */
50614 ** non-zero is returned from this function, the calling function must simply
50626 ** so that callers of this function will simply use it verbatim.
50634 ** relative path or an absolute path. Callers of this function must not
50643 ** If we get to this point, the path name should almost certainly be a purely
50666 /* If this path name begins with "/X:" or "\\?\", where "X" is any
50751 /* It's odd to simulate an io-error here, but really this is just
50752 ** using the io-error infrastructure to test that SQLite handles this
50921 unsigned char *a; /* Gather entropy into this buffer */
51079 ** The idea is that this function works like a combination of
51082 ** function, SQLite calls this function with zBuf pointing to
51275 ** The author disclaims copyright to this source code. In place of
51294 ** Forward declaration of objects used by this utility
51351 int nRef; /* Number of users of this MemStore */
51359 int eLock; /* Most recent lock against this file */
51366 ** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object.
51575 ** reaching this point */
51893 ** files, none of which exist in memdb. So this routine is never used */
52199 ** The author disclaims copyright to this source code. In place of
52244 ** Setting this to the "natural word" size of your CPU may improve
52293 ** this would be 125. */
52297 /* For a BITVEC_SZ of 512, this would be 34,359,739. */
52384 /* if there wasn't a hash collision, and this doesn't */
52402 /* available free spot. check to see if this is going to */
52613 ** The author disclaims copyright to this source code. In place of
52626 ** A complete page cache is an instance of this structure. Every
52646 ** clear PGHDR_NEED_SYNC flag or to a page that is older than this one
52656 int szPage; /* Size of every page in this cache */
52843 /* If pSynced is NULL and this page has a clear NEED_SYNC flag, set
52859 ** being used for an in-memory database, this function is a no-op.
52926 ** to this module, the extra space really ends up being the MemPage
52953 ** are no outstanding page references when this function is called.
52994 ** routines are split this way for performance reasons. When separated
53000 PCache *pCache, /* Obtain the page from this cache */
53033 ** size limit has been reached, then this routine can be invoked to
53042 PCache *pCache, /* Obtain the page from this cache */
53092 ** initialized, this routine is invoked to do the initialization.
53098 PCache *pCache, /* Obtain the page from this cache */
53124 PCache *pCache, /* Obtain the page from this cache */
53287 ** If there is a reference to page 1 and the pgno parameter passed to this
53370 ** corrupted by this sort.
53493 ** Return the size of the header added by this middleware layer
53538 ** The author disclaims copyright to this source code. In place of
53553 ** A Page cache line looks like this:
53564 ** of which pages are "dirty". PgHdr1 is an extension added by this
53572 ** sizes of the extensions sum to 272 bytes on x64 for 3.8.10, but this
53585 ** with this module. Information is passed back and forth as PgHdr1 pointers.
53628 ** directly before this structure and is used to cache the page content.
53638 ** pointers must be either 4 or 8-byte aligned). As this structure is located
53641 ** read part of this structure before the corruption is detected. This
53657 PCache1 *pCache; /* Cache that currently owns this page */
53704 ** is an instance of this object.
53706 ** Pointers to structures of this type are cast and returned as
53716 PGroup *pGroup; /* PGroup this cache belongs to */
53748 ** Global data used by this cache.
53763 int nReserve; /* Try to keep nFreeSlot above this */
53771 ** (2) even if an incorrect value is read, no great harm is done since this
53777 ** All code in this file should access the global structure above via the
53861 pX->pLruPrev = 0; /* Initializing this saves a valgrind error */
53870 ** Malloc function used within this file to allocate space from the buffer
53872 ** such buffer exists or there is no space left in it, this function falls
53875 ** Multiple threads can run this routine at the same time. Global variables
53980 ** this mutex is not held. */
53997 p->pLruPrev = 0; /* Initializing this saves a valgrind error */
54023 ** exists, this function falls back to sqlite3Malloc().
54069 ** The PCache mutex must be held when this function is called.
54108 ** LRU list, then this function is a no-op.
54110 ** The PGroup mutex must be held when this function is called.
54135 ** The PGroup mutex must be held when this function is called.
54175 ** greater than or equal to iLimit. Any pinned pages that meet this
54178 ** The PCache mutex must be held when this function is called.
54182 unsigned int iLimit /* Drop pages with this pgno or larger */
54482 ** Whether or not a new page may be allocated by this function depends on
54531 ** There are two versions of this routine. pcache1FetchWithMutex() is
54559 /* Steps 3, 4, and 5 implemented by this subroutine */
54624 /* It is an error to call this function if the page is already
54748 ** Return the size of the header on each page of this PCACHE implementation.
54753 ** Return the global mutex used by this PCACHE implementation. The
54754 ** sqlite3_status() routine needs access to this mutex.
54766 ** nReq is the number of bytes of memory required. Once this much has
54821 ** The author disclaims copyright to this source code. In place of
54838 ** elements of the RowSet in sorted order. Once this extraction
54901 ** RowSet.pForest value points to the head of this forest list.
54904 i64 v; /* ROWID value for this entry */
54923 ** A typedef of this structure if found in sqliteInt.h.
54999 ** In an OOM situation, the RowSet.db->mallocFailed flag is set and this
55119 ** Convert this tree into a linked list connected by the pRight pointers
55169 ** is still generated without this branch, but the tree is wildly
55217 ** After this routine has been called, the sqlite3RowSetInsert()
55255 ** If this is the first test of a new batch and if there exist entries
55266 ** To save unnecessary work, only do this when the batch number changes.
55326 ** The author disclaims copyright to this source code. In place of
55350 ** The author disclaims copyright to this source code. In place of
55399 ** There is one object of this type for each pager.
55448 sqlite3 *db, /* Check this handle's interrupt flag */
55513 ** Within this comment block, a page is deemed to have been synced
55655 ** The pager starts up in this state. Nothing is guaranteed in this
55665 ** In this state all the requirements for reading the database in
55668 ** open. The database size is known in this state.
55670 ** A connection running with locking_mode=normal enters this state when
55674 ** this state even after the read-transaction is closed. The only way
55682 ** may not be trusted at this point.
55689 ** The pager moves to this state from READER when a write-transaction
55696 ** moving to this state, but the journal file is not written to or opened
55697 ** to in this state. If the transaction is committed or rolled back while
55718 ** A pager moves from WRITER_LOCKED state to this state when a page is
55733 ** never enter this state (since they do not modify the database file,
55745 ** It is not possible for a WAL connection to enter this state.
55749 ** database file. In this state the transaction may be committed simply
55751 ** not possible to modify the database further. At this point, the upper
55773 ** At this point it would be dangerous to change back to READER state
55777 ** file. To avoid this hazard, the pager switches into the ERROR state
55807 ** statement executed within a transaction. In this case, if the error
55861 ** from ERROR to OPEN state. At this point there may be a hot-journal file
55864 ** fails at this point and the pager is left holding an EXCLUSIVE lock, this
55869 ** lock held by this process or any others". So xCheckReservedLock may
55871 ** doesn't know it because of a previous error in xUnlock). If this happens
55876 ** To work around this, if a call to xUnlock() fails when unlocking the
55906 ** returns a value larger than this, then MAX_SECTOR_SIZE is used instead.
55930 Bitvec *pInSavepoint; /* Set of pages in this savepoint */
55961 ** locks), this variable is always set to EXCLUSIVE_LOCK. Since such
55962 ** databases always have Pager.exclusiveMode==1, this tricks the pager
55966 ** In some (obscure) circumstances, this variable may also be set to
56078 ** dbFileSize is not used when rolling back a transaction. In this case
56118 u8 useJournal; /* Use a rollback journal on this file */
56132 ** routine operation. Class members not in this block are either fixed
56174 u16 nExtra; /* Add this many bytes to each in-memory page */
56190 void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */
56266 ** The journal header size for this pager. This is usually the same
56273 ** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set,
56294 ** The argument to this macro is a file descriptor (type sqlite3_file*).
56380 ** this means an in-memory pager performs no IO at all, it cannot encounter
56639 ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is
56641 ** UNKNOWN_LOCK for an explanation of this.
56666 ** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is
56669 ** of this.
56687 ** atomic-batch-write optimizations can be used with this pager. The
56700 ** returned in this case.
56785 ** When this is called the journal file for pager pPager must be open.
56795 ** nul-terminator), then this is handled as if no super-journal name
56878 ** The journal file must be open when this function is called.
56891 ** journal file in bytes is larger than this value, then truncate the
56893 ** not need to be synced following this operation.
56916 /* At this point the transaction is committed but the write lock
56920 ** to sync the file following this operation.
56934 ** The journal file must be open when this routine is called. A journal
56943 ** - 4 bytes: Sector size used by the process that wrote this journal.
56974 ** Write the nRec Field - the number of page records that follow this
56975 ** journal header. Normally, zero is written to this value at this time.
56981 ** reading the journal this value tells SQLite to assume that the
56985 ** where this risk can be ignored:
56988 ** power failure in this case anyway.
57008 /* The assumed sector size for this process */
57028 ** However it has been discovered that on some systems this pattern can
57050 ** The journal file must be open when this is called. A journal header file
57057 ** page records following this header and *pDbSize is set to the size of the
57060 ** in this case.
57080 ** journal file is too small for there to be a header stored at this
57127 ** journal header to zero. In this case, assume that the Pager.pageSize
57145 ** crashed before the header was synced. In this case stop reading
57159 ** the process that created this journal. If this journal was
57160 ** created by a process other than this one, then this routine
57189 ** this call is a no-op.
57245 ** Easiest thing to do in this scenario is to truncate the journal
57321 ** If the pager is in ERROR state when this function is called, the
57326 ** is opened (by this or by any other connection).
57366 ** above the #define for UNKNOWN_LOCK for an explanation of why this
57411 ** value returned is a copy of the second argument to this function.
57481 ** transaction. Nor will it be considered to be a hot-journal by this
57501 ** If the pager is running in exclusive mode, this method of finalizing
57533 ** read-transaction, this function is called with eState==PAGER_READER
57575 ** a hot-journal was just rolled back. In this case the journal
57576 ** file should be closed and deleted. If this connection writes to
57625 ** At this point the journal has been finalized and the transaction
57654 ** the rollback at this time. Instead, pager_unlock() is called. The
57656 ** the database file and move the pager back to OPEN state. If this
57658 ** connection to obtain a shared lock on the pager (which may be this one)
57662 ** malloc error occurs during a rollback, then this will itself cause
57691 ** Changing the formula used to compute this checksum results in an
57697 ** correct and the middle be corrupt. Thus, this "checksum" scheme,
57772 ** If this is a savepoint rollback, then memory may have to be dynamically
57773 ** allocated by this function. If this is the case and an allocation fails,
57806 ** or savepoint rollback done at the request of the caller) or this is
57829 ** detect this invalid data (with high probability) and ignore it.
57846 /* If this page has already been played back before during the current
57859 /* If the pager is in CACHEMOD state, then there must be a copy of this
57860 ** page in the pager cache. In this case just update the pager cache,
57861 ** not the database file. The page is left marked dirty in this case.
57872 ** not dirty. Since this code is only executed in PAGER_OPEN state for
57947 /* If this is a rollback of a savepoint and data was not written to
57953 ** There are a couple of different ways this can happen. All are quite
57954 ** obscure. When running in synchronous mode, this can only happen
57989 /* If this was page 1, then restore the value of Pager.dbFileVers.
57990 ** Do this before any decoding. */
58011 ** available for use within this function.
58033 ** above, this function returns without doing anything. Otherwise, if
58037 ** If an IO error within this function, an error code is returned. This
58056 char *zFree = 0; /* Free this buffer */
58151 ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size
58159 ** currently is, so detect this case and write a single zero byte to
58260 ** in the journal. If this value is 0xffffffff, then compute the
58267 ** is this many bytes in size.
58290 ** in this case. But for things like temporary table (which will be
58372 /* If nRec is 0xffffffff, then this journal was created by a process
58375 ** the value of nRec based on this assumption.
58382 /* If nRec is 0 and this rollback is of a transaction created by this
58383 ** process and if this is the final header in the journal, then it means
58384 ** that this part of the journal was being filled but has not yet been
58401 /* If this is the first header read from the journal, truncate the
58465 /* If this playback is happening automatically as a result of an IO or
58468 ** modification may just have been reverted. If this happens in exclusive
58472 ** in case this has happened, clear the changeCountDone flag now.
58495 /* If there was a super-journal and this routine will return success,
58510 ** value. Reset it to the correct value for this process.
58521 ** file before this function is called.
58646 ** also copied into the backup databases) as part of this transaction,
58683 ** this function notifies any active backup processes that the pages have
58686 ** The list of pages passed into this routine is always sorted by page number.
58692 Pgno nTruncate, /* Database size after this commit */
58693 int isCommit /* True if this is a commit */
58843 ** The caller must hold a SHARED lock on the database file to call this
58845 ** a WAL on a none-empty database, this ensures there is no race condition
58909 ** journal file. There is no need for a bitvec in this case.
58913 ** (or transaction). No page with a page-number greater than this value
58944 ** journal. The actual file might be larger than this in
59093 ** single disk sector is atomic, then this mode provides
59240 ** If the pager is in the error state when this function is called, it
59256 ** If the page size is changed, then this function uses sqlite3PagerMalloc()
59257 ** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt
59262 ** conditions above is not true, the pager was in error state when this
59269 /* It is not possible to do a full assert_pager_state() here, as this
59273 ** At one point this function returned an error if the pager was in
59275 ** there is at least one outstanding page reference, this function
59352 /* OP_MaxPgcnt ensures that the parameter passed to this function is not
59353 ** less than the total number of valid pages in the database. But this
59388 ** zeroed and SQLITE_OK returned. The rationale for this is that this
59422 ** this is considered a 1 page file.
59433 ** a similar or greater lock is already held, this function is a no-op
59448 /* Check that this is either a no-op (because the requested lock is
59471 ** b) if the page content were written at this time, it would not
59474 ** If the condition asserted by this function were not true, and the
59478 ** this happened, the correct behavior would be to restore the current
59479 ** content of the page. However, since this content is not present in either
59483 ** this circumstance cannot arise.
59512 ** Once this function has been called, the transaction must either be
59513 ** rolled back or committed. It is not safe to call this function and
59522 ** ensure that all pages being truncated away by this operation are,
59525 ** back. This is no longer necessary as this function is now only
59542 ** content as this process.
59566 ** Page references obtained by calling this function should be released
59572 void *pData, /* xFetch()'d data for this page */
59663 ** If a transaction was in progress when this routine is called, that
59666 ** with this page cache after this function returns will likely
59701 ** If this is not done, then an unsynced portion of the open journal
59703 ** while this is happening, the database could become corrupt.
59757 ** If the Pager.noSync flag is set, then this function is a no-op.
59768 ** mode, then the journal file is synced before this field is updated.
59783 ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every
59807 ** that wrote to this database was operating in persistent-journal
59808 ** mode, then the journal file may at this point actually be larger
59812 ** occurs after nRec is updated but before this connection writes
59816 ** of this connections data, then proceed to rolling back the old,
59819 ** To work around this, if the journal file does appear to contain
59823 ** Variable iNextHdrOffset is set to the offset at which this
59851 ** SAFE_APPEND property. Because in this case it is not possible
59902 ** be NULL, representing an empty list. In this case this function is
59905 ** The pager must hold at least a RESERVED lock when this function
59906 ** is called. Before writing anything to the database file, this lock
59940 ** is not possible for rc to be other than SQLITE_OK if this branch
59965 ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to
59986 ** the value now stored in the database file. If writing this
59997 /* Update any backup objects copying the contents of this pager. */
60015 ** Ensure that the sub-journal file is open. If it is already open, this
60107 ** The job of this function is to make pPg clean by writing its contents
60136 ** while in the error state, hence it is impossible for this routine to
60154 /* Write a single frame for this page to the log. */
60226 ** first 8 bytes of this space are zeroed but the remainder is uninitialized.
60248 int flags, /* flags controlling this file */
60256 int memDb = 0; /* True if this is an in-memory file */
60262 int readOnly = 0; /* True if this is a read-only file */
60293 ** to by zPathname, length nPathname. Or, if this is a temporary file,
60510 ** In this case we accept the default page size and delay actually
60629 ** needs to be played back. According to this function, a hot-journal
60639 ** database with the same name. In this case the journal file is
60645 ** does not exist, then the journal file is not really hot. In this
60646 ** case this routine will return a false-positive. The pager_playback()
60681 ** is the case, this routine might think there is a hot journal when
60711 ** If there is, then we consider this journal to be hot. If not,
60751 ** It is illegal to call sqlite3PagerGet() until after this function
60753 ** this function is called, it is a no-op.
60755 ** The following operations are also performed by this function.
60815 /* Get an EXCLUSIVE lock on the database file. At this point it is
60819 ** database is safe to read while this process is still rolling the
60824 ** this point in the code and fail to obtain its own EXCLUSIVE lock
60828 ** downgraded to SHARED_LOCK before this function returns.
60844 ** this connection obtained the exclusive lock above. Or, it
60845 ** may mean that the pager was in the error-state when this
60893 ** In order to get pager_unlock() to do this, set Pager.eState to
60895 ** to ERROR state in the state diagram at the top of this file,
60915 ** flush the cache. The hasHeldSharedLock flag prevents this from
60945 ** to its original size while this process was not holding a lock.
60946 ** In this case there may exist a Pager.pMap mapping that appears
60947 ** to be the right size but is not actually valid. Avoid this
60955 /* If there is a WAL file in the file-system, open this database in WAL
60991 ** nothing to rollback, so this routine is a no-op.
61020 ** already in the cache when this function is called, then the extra
61026 ** actual disk read occurs. In this case the memory image of the
61049 ** See also sqlite3PagerLookup(). Both this routine and Lookup() attempt
61051 ** in memory, this routine goes to disk to read it in whereas Lookup()
61091 /* In this case the pcache already contains an initialized copy of
61262 ** See also sqlite3PagerGet(). The difference between this routine
61300 /* Do not use this routine to release the last reference to page1 */
61319 ** file when this routine is called.
61328 ** then this function just writes a journal header to the start of the
61331 ** Whether or not the journal file is opened by this function, the
61346 /* If already in the error state, this function is a no-op. But on
61347 ** the other hand, this routine is never called if we are already in
61414 ** write-transaction has already been opened, this function is a no-op.
61422 ** within this transaction will be opened as an in-memory file. This
61459 ** is true, then immediately upgrade this to an EXCLUSIVE lock. The
61560 ** been started. The journal file may or may not be open at this point.
61574 ** rollback journal might not yet be open. Open it now if this is the case.
61659 ** this function.
61730 ** of this function and be careful not to change any page data unless
61731 ** this routine returns SQLITE_OK.
61733 ** The difference between this function and pager_write() is that this
61735 ** fit on a single disk sector. In this case all co-resident pages
61771 ** A call to this routine tells the pager that it is not necessary to
61777 ** The overlying software layer calls this routine when all of the data
61781 ** Tests show that this optimization can quadruple the speed of large
61808 ** But this only happens if the pPager->changeCountDone flag is false.
61813 ** If the isDirectMode flag is zero, then this is done by calling
61815 ** page data. In this case the file will be updated when the current
61819 ** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case,
61833 ** atomic-write optimization is enabled in this build, then isDirect
61835 ** to this function. Otherwise, it is always set to zero.
61859 /* If page one was fetched successfully, and this function is not
61904 ** If successful, or if called on a pager for which it is a no-op, this
61921 ** rollback. If the connection is in WAL mode, this call is a no-op.
61964 ** Note that if zSuper==NULL, this does not overwrite a previous value
61970 ** journal file in this case.
62001 /* If this is an in-memory db, or no pages have been written to, or this
62042 ** does this depends on whether or not the atomic-update optimization
62043 ** was enabled at compile time, and if this transaction meets the
62054 ** is not applicable to this transaction, call sqlite3JournalCreate()
62061 ** in 'direct' mode. In this case the journal file will never be
62062 ** created for this transaction.
62079 ** property of the host file-system, this is safe.
62103 ** or if zSuper is NULL (no super-journal), then this call is a no-op.
62109 ** If the atomic-update optimization is being used, this sync will not
62115 ** on a system under memory pressure it is just possible that this is
62116 ** not the case. In this case it is likely enough that the redundant
62161 ** last page in the db image moved to the free-list. In this case the
62163 ** undersized. Fix this now if it is the case. */
62188 ** When this function is called, the database file has been completely
62191 ** though, and if a failure occurs at this point it will eventually
62196 ** for hot-journal rollback. Once this is done the transaction is
62218 ** this transaction, the pager is running in exclusive-mode and is
62219 ** using persistent journals, then this function is a no-op.
62248 ** If the pager is already in PAGER_ERROR state when this function is called,
62249 ** it returns Pager.errCode immediately. No work is performed in this case.
62251 ** Otherwise, in rollback mode, this function performs two functions:
62403 ** Return true if this is an in-memory or temp-file backed pager.
62413 ** equal to nSavepoint, then this function is a no-op.
62491 ** (Pager.nSavepoint-1), then this function is a no-op.
62493 ** If a negative value is passed to this function, then the current
62495 ** sqlite3PagerRollback() because this function does not terminate
62500 ** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE),
62519 int nNew; /* Number of remaining savepoints after this op. */
62521 /* Figure out how many savepoints will still be active after this
62522 ** operation. Store this value in nNew. Then free resources associated
62523 ** with any savepoints that are destroyed by this operation.
62545 /* Else this is a rollback operation, playback the specified savepoint.
62546 ** If this is a temp-file, it is possible that the journal file has
62547 ** not yet been opened. In this case there have been no changes to
62559 ** if the VFS used by this pager includes ZipVFS, the entire transaction
62585 ** The return value to this routine is always safe to use with
62630 ** Set or retrieve the codec for this pager
62660 ** page content. If a malloc fails, this function may return NULL.
62677 ** in the rollback journal, it is not put there by by this routine.
62683 ** A transaction must be active when this routine is called. It used to be
62684 ** required that a statement transaction was not active, but this restriction
62688 ** If the fourth argument, isCommit, is non-zero, then this page is being
62690 ** is being committed. In this case, it is guaranteed that the database page
62691 ** pPg refers to will not be written to again within this transaction.
62732 ** one or more savepoint bitvecs. This is the reason this function
62806 ** this transaction, it may be written to the database file before
62857 ** Get/set the locking-mode for this pager. Parameter eMode must be one
62880 ** Set the journal-mode for this pager. Parameter eMode must be one of:
62945 /* In this case we would like to delete the journal file. If it is
63021 ** in backup.c maintains the content of this variable. This module
63031 ** Unless this is an in-memory or temporary database, clear the pager cache.
63049 Pager *pPager, /* Checkpoint on this pager */
63061 ** used for this since it starts transactions on every database file,
63113 ** exclusive-locking mode when this function is called, take an EXCLUSIVE
63126 ** file, to make sure this is safe.
63132 /* Open the connection to the log file. If this operation fails,
63149 ** this function.
63196 ** Before closing the log file, this function attempts to take an
63197 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
63208 ** rollback mode. Open it now so this can happen.
63243 ** with the same db and bLock parameters as were passed to this function.
63267 ** If this is a WAL database, obtain a snapshot handle for the snapshot
63279 ** If this is a WAL database, store a pointer to pSnapshot. Next time a
63281 ** identifies. If this is not a WAL database, return an error.
63297 ** If this is a WAL database, call sqlite3WalSnapshotRecover(). If this
63312 ** If this is not a WAL database, SQLITE_ERROR is returned. Otherwise,
63313 ** this function takes a SHARED lock on the CHECKPOINTER slot and then
63346 ** A read-lock must be held on the pager when this function is called. If
63349 ** WAL frames. Otherwise, if this is not a WAL database or the WAL file
63365 ** The author disclaims copyright to this source code. In place of
63472 ** valid frame in the WAL. The reader uses this recorded "mxFrame" value
63484 ** and read performance suffers. To overcome this problem, a separate
63509 ** The purpose of the wal-index is to answer this question quickly: Given
63609 ** from the hash table at this point.
63627 ** that may be interpreted by this version of SQLite.
63672 ** The actual header in the wal-index consists of two copies of this
63843 /* WAL magic value. Either this value, or the same value with the least
63872 i64 mxWalSize; /* Truncate WAL to this size upon reset */
63888 u32 minFrame; /* Ignore wal frames before this one */
63930 ** The internals of this structure are only accessed by:
64069 ** The argument to this macro must be of type u32. On a little-endian
64241 ** all prior frams, the first 16 bytes of this frame-header,
64243 ** bytes of this frame-header.
64255 /* If we reach this point, the frame is valid. Return the page number
64360 ** number of the first frame indexed by this hash table. If a
64410 ** Return the page number associated with frame iFrame in this WAL.
64434 int iLimit = 0; /* Zero values greater than this */
64511 /* If this is the first entry to be added to this hash-table, zero the
64552 ** thing to check, so only do this occasionally - not on every
64580 ** that this thread is running recovery. If unable to establish
64581 ** the necessary locks, this routine returns SQLITE_BUSY.
64593 ** this function returns.
64623 int isValid; /* True if this frame is valid */
64706 /* If nTruncate is non-zero, this is a commit record. */
64727 ** is safe for this. Memcpy() is certainly a lot faster.
64733 ** setting the final value, this alternative copy routine is
64762 /* Reset the checkpoint-header. This is safe because this thread is
64824 ** A SHARED lock should be held on the database file when this function
64825 ** is called. The purpose of this SHARED lock is to prevent any other
64827 ** were to do this just after this client opened one of these files, the
64839 i64 mxWalSize, /* Truncate WAL to this size on reset */
64881 ** this source file. Verify that the #defines of the locking byte offsets
64943 ** has not been returned by any prior invocation of this method on the
65135 ** return SQLITE_OK. Otherwise, return an error code. If this routine
65169 ** of memory will be freed before this function returns.
65184 int nEntry; /* Number of entries in this segment */
65185 ht_slot *aIndex; /* Sorted index for this segment */
65325 ** The cache of the wal-index header must be valid to call this function.
65333 ** The following is guaranteed when this function is called:
65342 ** client to write to the database (which may be this one) does so by
65375 ** All I/O barrier operations (a.k.a fsyncs) occur in this routine when
65400 sqlite3 *db, /* Check for interrupts on this handle */
65468 /* If the database may grow as a result of this checkpoint, hint
65540 /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the
65561 ** In theory, it might be safe to do this without updating the
65567 ** file-system. To avoid this, update the wal-index header to
65615 ** ordinary, rollback-mode locking methods, this guarantees that the
65616 ** connection associated with this log file is the only connection to
65617 ** the database. In this case checkpoint the database and unlink both
65672 ** be writing the header at the same time this procedure is trying to
65689 /* The first page of the wal-index must be mapped at this point. */
65695 ** from the file. If this happens, return non-zero.
65748 ** changed by this operation. If pWal->hdr is unchanged, set *pChanged
65768 ** was openable but is not writable, and this thread is unable to
65830 ** this version of SQLite cannot understand.
65868 ** If this function returns SQLITE_OK, then the read transaction has
65869 ** been successfully opened. In this case output variable (*pChanged)
65904 ** thus making the shared-memory "reliable" again. Do this by invoking
65912 ** This step is important because, even though this connection is holding
65915 ** is active, wrap the WAL and start overwriting frames that this
65932 /* We reach this point only if the real shared-memory is still unreliable.
65951 ** since this client's last read transaction. */
66000 ** appended to this wal file. Set rc to WAL_RETRY and break out of
66036 ** checkpointed. If useWal==0 then this routine calls walIndexReadHdr()
66044 ** this routine during the current read attempt that returned WAL_RETRY.
66054 ** On success, this routine obtains a read lock on
66064 ** this routine will always set pWal->readLock>0 on success.
66100 ** calls to sqlite3OsSleep() have a delay of 1 microsecond. Really this
66130 ** WAL_RETRY this routine will be called again and will probably be
66135 ** We assume this is a transient condition, so return WAL_RETRY. The
66177 ** happening, this is usually correct.
66195 /* If we get this far, it means that the reader will want to use
66273 ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
66292 ** variable so that older snapshots can be accessed. To do this, loop
66371 ** instant in time. The current thread will continue to use this snapshot.
66377 ** Pager layer will use this to know that its cache is stale and
66397 ** concurrent with this code. If this is the case, it may be that the
66401 ** its intent. To avoid the race condition this leads to, ensure that
66426 /* At this point the client has a lock on an aReadMark[] slot holding
66433 ** In this case, the salt will have changed.
66437 ** checkpoint need not have completed for this to cause problems.
66485 ** Finish with a read transaction. All this does is release the
66510 u32 iLast = pWal->hdr.mxFrame; /* Last page in WAL for this reader */
66519 ** in this case as an optimization. Likewise, if pWal->readLock==0,
66533 ** that adds entries to the wal-index (and possibly to this hash
66643 ** the read transaction was started, then it is not possible for this
66644 ** thread to write as doing so would cause a fork. So this routine
66654 ** read-transaction was even opened, making this call a no-op.
66681 ** time the read transaction on this connection was started, then
66708 ** If any data has been written (but not committed) to the log file, this
66716 ** Otherwise, if the callback function does not return an error, this
66825 ** wal-index header to reflect this.
66828 ** at this point. But updating the actual wal-index header is also
66830 ** to handle if this transaction is rolled back. */
66860 sqlite3_int64 iSyncPoint; /* Fsync at this offset */
66877 sqlite3_int64 iOffset /* Start writing at this offset */
66985 Pgno nTruncate, /* Database size after this commit */
66986 int isCommit, /* True if this is a commit */
67003 /* If this frame set completes a transaction, then nTruncate>0. If
67004 ** nTruncate==0 then this frame set does not complete the transaction. */
67026 /* If this is the first frame written into the log, write the WAL
67028 ** this source file for a description of the WAL header format.
67084 /* Check if this page has already been written into the wal file by
67126 /* If this is the end of a transaction, then we might need to pad
67129 ** Padding and syncing only occur if this set of frames complete a
67161 /* If this frame set completes the first transaction in the WAL and
67175 ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index
67202 /* If this is a commit, update the wal-index header too. */
67223 ** callback. In this case this function runs a blocking checkpoint.
67227 sqlite3 *db, /* Check this handle's interrupt flag */
67263 ** it will not be invoked in this case.
67323 ** next time the pager opens a snapshot on this database it knows that
67380 ** WAL is already in exclusive-locking mode - meaning that this
67382 ** on the main database file before invoking this operation.
67385 ** not actually change anything. The pager uses this to see if it
67397 ** locks are taken in this case). Nor should the pager attempt to
67551 ** The author disclaims copyright to this source code. In place of
67570 ** The author disclaims copyright to this source code. In place of
67601 ** In this implementation, a single file can hold one or more separate
67692 ** The page headers looks like this:
67697 ** 3 2 number of cells on this page
67702 ** The flags define the format of this btree page. The leaf flag means that
67703 ** this page has no children. The zerodata flag means that this page carries
67729 ** 2 Bytes in this freeblock
67755 ** The content of a cell looks like this:
67775 ** unspecified. A trunk page looks like this:
67779 ** 4 Number of leaf pointers on this page
67806 ** You can change this value at compile-time by specifying a
67828 ** An instance of this object stores information about each a single database
67829 ** page that has been loaded into memory. The information in this object
67833 ** instance of this object and zeros the first 8 bytes. (This is the
67836 ** Access to all fields of this structure is controlled by the mutex
67843 Pgno pgno; /* Page number for this page */
67855 u16 nCell; /* Number of cells on this page, local and ovfl */
67860 BtShared *pBt; /* Pointer to BtShared that this page is part of */
67876 ** from this list when a transaction is committed or rolled back, or when
67880 Btree *pBtree; /* Btree handle holding this lock */
67893 ** this object for every database file that it has open. This structure
67895 ** see the internals of this structure and only deals with pointers to
67896 ** this structure.
67900 ** has it own instance of this object. But each instance of this object
67905 ** All fields in this structure are accessed under sqlite3.mutex.
67907 ** in the referenced BtShared that point back to this Btree since those
67908 ** cursors have to go through this Btree to find their BtShared and
67912 sqlite3 *db; /* The database connection holding this btree */
67913 BtShared *pBt; /* Sharable content of this btree */
67919 int nBackup; /* Number of backup operations reading this btree */
67957 ** An instance of this object represents a single database file.
67963 ** to this one BtShared object. BtShared.nRef is the number of
67964 ** connections currently sharing this database file.
67966 ** Fields in this structure are accessed under the BtShared.mutex
67993 sqlite3 *db; /* Database connection currently using this Btree */
68016 sqlite3_mutex *mutex; /* Non-recursive mutex required to access this object */
68017 Bitvec *pHasContent; /* Set of pages moved to free-list this transaction */
68019 int nRef; /* Number of references to this structure */
68021 BtLock *pLock; /* List of locks held on this shared-btree struct */
68043 ** about a cell. The parseCellPtr() function fills in this structure
68056 ** this will be declared corrupt. This value is calculated based on a
68060 ** If a tree that appears to be taller than this is encountered, it is
68076 ** Fields in this structure are accessed under the BtShared.mutex
68098 Btree *pBtree; /* The Btree to which this cursor belongs */
68105 BtShared *pBt; /* The BtShared this cursor points to */
68109 Pgno pgnoRoot; /* The root page of this tree */
68147 ** The table that this cursor was opened on still exists, but has been
68150 ** this state, restoreCursorPosition() can be called to attempt to
68155 ** on a different connection that shares the BtShared cache with this
68157 ** Do nothing else with this cursor. Any attempt to use the cursor
68184 ** this test.
68194 ** 0 or 1 parent pages. (In this context 'database page' refers
68205 ** used in this case.
68208 ** is not used in this case.
68212 ** contains the cell with a pointer to this overflow page.
68240 ** So, this macro is defined instead.
68265 int mxErr; /* Stop accumulating errors when this reaches zero */
68341 ** and this routine is a no-op. The underlying mutex is non-recursive.
68343 ** of this interface is recursive.
68383 ** into this routine, we avoid unnecessary stack pointer changes
68598 ** The author disclaims copyright to this source code. In place of
68619 ** Set this global variable to 1 to enable tracing using the TRACE
68666 ** Access to this variable is protected by SQLITE_MUTEX_STATIC_MAIN.
68698 ** of each BtShared structure and so this locking is not necessary.
68748 ** If SQLITE_DEBUG is not defined, then this macro is equivalent to
68789 ** as this module treats each table as a separate structure. To determine
68790 ** the table corresponding to the index being written, this
68807 /* If this database is not shareable, or if the client is reading
68827 ** b-trees, this is just the root page of the b-tree being read or
68916 ** transaction on this file. And, obviously, for this to be so there
68942 ** may hold a WRITE_LOCK on any table in this file (since there can
68988 ** obtain a read-lock using this function. The only read-lock obtained
68998 /* First search the list for an existing lock on this table. */
69073 ** than the writer must be about to drop to zero. In this case
69077 ** be zero already. So this next line is harmless in that case.
69154 ** table is about to be deleted. In this case invalidate all incrblob
69158 ** rowid iRow is being replaced or deleted. In this case invalidate
69273 ** when this function is called (i.e. have eState==CURSOR_VALID). This
69324 ** prior to calling this routine.
69370 ** pointless call to this routine.
69390 ** The common case is that no cursors need to be saved, so this routine is
69395 Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */
69396 BtCursor *pExcept /* Do not save this cursor */
69426 ** In this version of BtreeMoveto, pKey is a packed index record
69461 ** when saveCursorPosition() was called. Note that this call deletes the
69504 ** Calling this routine with a NULL cursor pointer returns false.
69507 ** back to where it ought to be if this routine returns true.
69609 ** If *pRC is initially non-zero (non-SQLITE_OK) then this routine is
69639 ** If that byte is set, it means this page is also being used
69734 CellInfo *pInfo /* Fill in this structure */
69797 CellInfo *pInfo /* Fill in this structure */
69814 CellInfo *pInfo /* Fill in this structure */
69896 CellInfo *pInfo /* Fill in this structure */
69933 CellInfo *pInfo /* Fill in this structure */
69957 /* The value returned by this function should always be the same as
69960 ** this function verifies that this invariant is not violated. */
69997 /* The value returned by this function should always be the same as
70000 ** this function verifies that this invariant is not violated. */
70019 /* The value returned by this function should always be the same as
70022 ** this function verifies that this invariant is not violated. */
70106 ** present in the page after this routine returns.
70143 ** or fewer fragmented bytes. In this case it is faster to move the
70315 ** the first two bytes past the cell pointer area since presumably this
70414 ** at the end of the page. So do additional corruption checks inside this
70456 /* At this point:
70625 ** the start of the cell content area. A zero value for this integer is
70666 /* At this point, nFree contains the sum of the offset to the start
70668 ** the cell-content area. If this is greater than the usable-size
70766 pPage->nFree = -1; /* Indicate that this value is yet uncomputed */
70833 ** about the content of the page at this time. So do not go to the disk
70835 ** If in the future we call sqlite3PagerWrite() on this page, that
70842 MemPage **ppPage, /* Return the page in this parameter */
70887 ** call. Do additional sanity checking on the page in this case.
70888 ** And if the fetch fails, this routine must decrement pCur->iPage.
70990 MemPage **ppPage, /* Return the page in this parameter */
71011 ** the transaction, for each page restored this routine is called.
71027 ** But no harm is done by this. And it is very important that
71071 sqlite3_vfs *pVfs, /* VFS to use for this b-tree */
71081 int rc = SQLITE_OK; /* Result code from this function */
71129 ** If this Btree is a candidate for shared cache, try to find an
71251 ** regular file-name. In this case the auto-vacuum applies as per normal.
71429 ** data is passed to system call write(). So to avoid this error,
71458 /* Close all cursors opened via this handle. */
71462 /* Verify that no other cursors have this Btree open */
71477 ** this handle.
71483 ** structure, return now. The remainder of this procedure cleans
71517 ** pages in the cache exceeds this soft limit. But the size of the
71518 ** cache is allowed to grow larger than this limit if it contains
71532 ** If the number of pages exceeds this limit during a write transaction,
71593 ** size supplied does not meet this constraint then the page size is not
71650 ** database handle that owns *p is not. In this case if sqlite3BtreeEnter()
71773 ** If the user has not set the safety-level for this database connection
71775 ** set to the value passed to this function as the second parameter,
71863 /* If the read version is set to 2, this database should be accessed
71866 ** The caller detects this and calls this function again. This is
71924 ** zero and return SQLITE_OK. The caller will call this function
71999 ** For the purposes of this routine, a cursor is any cursor that
72017 ** this routine unrefs the first page of the database file which
72020 ** If there is a transaction in progress, this routine is a no-op.
72098 ** upgraded to exclusive by calling this routine a second time - the
72137 ** is requested, this is a no-op.
72160 ** on this shared-btree structure and a second write transaction is
72209 ** file is not pBt->pageSize. In this case lockBtree() will update
72222 /* if there was no transaction opened when this function was
72268 ** this sooner rather than later means the database size can safely
72339 ** Somewhere on pPage is a pointer to page iFrom. Modify this pointer so
72356 /* The pointer is always the first 4 bytes of the page in this case. */
72449 ** pointer to a subsequent overflow page. If this is the case, then
72496 ** calling this function again), return SQLITE_DONE. Or, if an error
72499 ** More specifically, this function attempts to re-organize the database so
72502 ** Parameter nFin is the number of pages that this database would contain
72503 ** were this function called until it returns SQLITE_DONE.
72505 ** If the bCommit parameter is non-zero, this function assumes that the
72538 ** truncated to zero after this function returns, so it doesn't
72561 /* If bCommit is zero, this loop runs exactly once and page pLastPg
72630 ** A write-transaction must be opened before calling this function.
72633 ** If the incremental vacuum is finished after this function has run,
72700 ** is encountered, this indicates corruption.
72767 ** At the end of this call, the rollback journal still exists on the
72779 ** When this is called, the super-journal should already have been
72780 ** created, populated with this journal pointer and synced to disk.
72782 ** Once this is routine has returned, the only thing required to commit
72783 ** the write-transaction for this database file is to delete the journal.
72821 /* If there are other active statements that belong to this database
72840 ** pager if this call closed the only read or write transaction. */
72853 ** be invoked prior to calling this routine. The sqlite3BtreeCommitPhaseOne()
72855 ** contents so that they are written onto the disk platter. All this
72861 ** finalize the underlying journal file, this function returns an error and
72863 ** is non-zero then this b-tree transaction is part of a multi-file
72864 ** transaction. In this case, the transaction has already been committed
72865 ** (by deleting a super-journal file) and the caller will ignore this
72932 ** rolled back modified the database schema. In this case b-tree root
73079 ** The second argument to this function, op, is always SAVEPOINT_ROLLBACK
73085 ** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the
73137 ** the changes made by this write cursor would be visible to
73146 ** this cursor will only be used to seek to and delete entries of an index
73148 ** this implementation. But in a hypothetical alternative storage engine
73151 ** operations on this cursor can be no-ops and all READ operations can
73159 ** on pCur to initialize the memory space prior to invoking this routine.
73177 /* The following assert statements verify that if this is a sharable
73180 ** this lock. The iTable<1 term disables the check for corrupt schemas. */
73261 ** this routine.
73324 ** Using this cache reduces the number of calls to btreeParseCell().
73372 ** is invalid, the result of this routine is undefined.
73410 ** currently pointing to. For table btrees, this will be the amount
73411 ** of data. For index btrees, this will be the size of the key.
73428 ** This is an optimization. Everything will still work if this
73445 ** ovfl), this function finds the page number of the next page in the
73566 ** this function may allocate space for and lazily populate
73568 ** Subsequent calls use this cache to make seeking to the supplied offset
73582 u32 offset, /* Begin reading this far into payload */
73583 u32 amt, /* Read this many bytes */
73584 unsigned char *pBuf, /* Write the bytes into this buffer */
73591 BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
73684 /* The only reason to read this page is to obtain the page
73699 /* Need to read this page properly. It contains some of the
73710 ** 1) this is a read operation, and
73711 ** 2) data is required from the start of this overflow page, and
73831 ** pages. When that is so, this routine can be used to access the
73836 ** The pointer returned by this routine looks directly into the cached
73874 ** this routine.
73970 ** CURSOR_INVALID and this routine returns SQLITE_EMPTY. Otherwise,
73974 ** If this function returns successfully, it may be assumed that the
74026 /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
74028 ** NULL, the caller expects a table b-tree. If this is not the case,
74031 ** Earlier versions of SQLite assumed that this test could not fail
74032 ** if the root page was already loaded when this function was called (i.e.
74033 ** if pCur->iPage>=0). But this is not so if the database is corrupted
74144 /* If the cursor already points to the last entry, this is a no-op. */
74232 ** is still obtained without this case, only a little more slowely */
74274 /* pPage->nCell must be greater than zero. If this is the root-page
74275 ** the cursor would have been INVALID above and this for(;;) loop
74276 ** not run. If this is not the root-page, then the moveToChild() routine
74518 /* pPage->nCell must be greater than zero. If this is the root-page
74519 ** the cursor would have been INVALID above and this for(;;) loop
74520 ** not run. If this is not the root-page, then the moveToChild() routine
74557 ** this case the whole cell needs to be parsed, a buffer allocated
74564 ** case this happens. */
74666 /* Currently this interface is only called by the OP_IfSmaller
74694 ** cursor corresponds to an SQL index and this routine could have been
74697 ** this hint, but COMDB2 does.
74787 ** the cursor corresponds to an SQL index and this routine could have been
74790 ** use this hint, but COMDB2 does.
74883 Pgno nearby, /* Search for a page near this one */
74939 /* The code within this loop is run only once if the 'searchList' variable
74949 ** zero if this is the last freelist trunk page. */
74994 /* The list is being searched and this trunk page is the page
75017 ** page in this case.
75124 ** Normally, new pages allocated by this block can be requested from the
75129 ** that is required in the event of a rollback. In this case, do
75193 ** The value passed as the second argument to this function is optional.
75199 ** its reference count is not altered by this function.
75251 ** trunk page in the free-list is full, then this page will become a
75276 /* In this case there is room on the trunk page to insert the page
75309 /* If control flows to this point, then it was not possible to add the
75390 ** So if there exists more than one reference to this page, then it
75392 ** It is helpful to detect this before calling freePage2(), as
75394 ** enabled. If this 'overflow' page happens to be a page that the
75395 ** caller is iterating through or using in some other way, this
75436 ** be constructed in this temporary area then copied into pPage->aData
75496 /* If we reach this point, it means that some of the content will need
75511 /* At this point variables should be set as follows:
75580 ** If this is the first overflow page, then write a partial entry
75581 ** to the pointer-map. If we write nothing to this pointer-map slot,
75685 ** *pRC must be SQLITE_OK when this routine is called.
75693 Pgno iChild, /* If non-zero, replace first 4 bytes with this value */
75754 ** the source page. Make sure this does not cause problems by not
75803 ** The cells in this array are the divider cell or cells from the pParent
75808 ** which should be common to all pages that contribute cells to this array.
75913 ** function works around problems caused by this by making a copy of any
75916 ** The MemPage.nFree field is invalidated by this function. It is the
75996 ** that it is safe to overwrite this part of the cell-pointer array.
75998 ** When this function is called, *ppData points to the start of the
76004 ** end of the space required by this page for the cell-pointer area (for
76006 ** area must be extended to before this point in order to accomodate all
76124 ** pCArray->apCell[iOld]. After balancing, this page should hold nNew cells
76130 ** The pPg->nFree field is invalid when this function returns. It is the
76134 MemPage *pPg, /* Edit this page */
76232 /* Unable to edit this page. Rebuild it from scratch instead. */
76306 /* If this is an auto-vacuum database, update the pointer map
76311 ** That is Ok, at this point the parent page is guaranteed to
76328 ** cell on pPage. The first two fields of this cell are the
76413 ** The performance of this function is not critical. It is only used by
76450 /* If this is an auto-vacuum database, update the pointer-map entries
76472 ** Note that when this routine is called, some of the cells on the page
76479 ** may cause the parent page to become overfull or underfull. If this
76481 ** balancing routine to fix this problem (see the balance() routine).
76483 ** If this routine fails for any reason, it might leave the database
76484 ** in a corrupted state. So if this routine fails, the database should
76487 ** The third argument to this function, aOvflSpace, is a pointer to a
76489 ** page (pParent) the parent page becomes overfull, this buffer is
76490 ** used to store the parent's overflow cells. Because this function inserts
76496 ** If aOvflSpace is set to a null pointer, this function returns
76504 int bBulk /* True if this call is part of a bulk load */
76539 /* At this point pParent may have at most one overflow cell. And if
76540 ** this overflow cell is present, it must be the cell with
76541 ** index iParentIdx. This scenario comes about when this function
76615 ** four bytes of it, and this function does not need the first
76621 ** In this case, temporarily copy the cell into the aOvflSpace[]
76628 ** The call to dropCell() below will detect this. */
76669 ** into aSpace1[]. In this way, all cells in b.apCell[] are without
76706 ** with "NOTE 1" in the overflow cell insertion loop to prove this
76778 ** Store this number in "k". Also compute szNew[] which is the total
76783 ** Values computed by this block:
76957 ** When NB==3, this one optimization makes the database about 25% faster
77106 ** bytes, then it may actually be smaller than this
77135 ** is important, as this code needs to avoid disrupting any page from which
77136 ** cells may still to be read. In practice, this means:
77206 ** If this is an auto-vacuum database, the call to copyNodeContent()
77287 ** page and SQLITE_OK is returned. In this case the caller is required
77364 ** some way. This function figures out if this modification means the
77393 /* The root page of the b-tree is overfull. In this case call the
77435 ** into pParent, which may cause pParent overflow. If this
77437 ** use either balance_nonroot() or balance_deeper(). Until this
77442 ** single call to balance_quick() is made for each call to this
77443 ** function. If this were not verified, a subtle bug involving reuse
77452 /* In this case, call balance_nonroot() to redistribute cells
77456 ** will balance the parent page to correct this.
77460 ** A subsequent iteration of the do-loop will deal with this by
77463 ** different page). Once this subsequent call to balance_nonroot()
77481 ** balance_nonroot(), or just before this function returns, whichever
77622 ** In that case, this routine must seek the cursor to the correct insertion
77629 BtCursor *pCur, /* Insert data into the table of this cursor */
77631 int flags, /* True if this is likely an append */
77647 /* Save the positions of any other cursors open on this table.
77652 ** integer key to use. It then calls this function to actually insert the
77653 ** data into the intkey B-Tree. In this case btreeMoveto() recognizes
77687 /* Assert that the caller has been consistent. If this cursor was opened
77696 /* If this is an insert into a table b-tree, invalidate any incrblob
77843 ** We could also try to do this if the old cell is smaller, then add
77845 ** doing that is no faster then skipping this optimization and just
78053 ** The BTREE_AUXDELETE bit is a hint that is not used by this implementation,
78097 ** be preserved following this delete operation. If the current delete
78098 ** will cause a b-tree rebalance, then this is done by saving the cursor
78119 /* A b-tree rebalance will be required after deleting this entry.
78131 ** from the internal node. The 'previous' entry is used for this instead
78141 /* Save the positions of any other cursors open on this table before
78148 /* If this is a delete operation to remove a row from a table b-tree,
78198 ** then the cursor still points to that page. In this case the first
78206 ** be either under or overfull. In this case run the balancing algorithm
78288 ** to make room for the new tables root page. In case this page turns
78427 i64 *pnChange /* Add number of Cells freed to this counter */
78480 ** the page number of the root of the table. After this routine returns,
78532 ** is added to the freelist instead of iTable. In this say, all
78538 ** meta[3] is updated by this procedure.
78652 ** read it from this routine.
78669 /* If auto-vacuum is disabled in this build and this is an auto-vacuum
78733 /* If this is a leaf page or the tree is not an int-key tree, then
78734 ** this page contains countable entries. Increment the entry counter
78838 ** Add 1 to the reference count for page iPage. If this is the second
78841 ** if this is the first reference to the page.
78939 /* If this database supports auto-vacuum and iPage is not the last
78940 ** page in this overflow list, check that the pointer-map entry for
78968 ** The heap property is this: Every node is less than or equal to both
79031 i64 maxKey /* Error if integer primary key greater than this */
79290 ** this function.
79311 int mxErr, /* Stop reporting errors after this many */
79312 int *pnErr /* Write number of errors seen to this variable */
79324 /* aRoot[0]==0 means this is a partial check */
79447 /* Make sure this analysis did not leave any unref() pages. */
79467 ** Return the pathname of the journal file for this database. The return
79468 ** value of this routine is the same regardless of whether the journal file
79492 ** Return SQLITE_LOCKED if this or any other connection has an open
79528 ** The first time this is called on a shared-btree, nBytes bytes of memory
79601 ** change the length of the data stored. If this function is called with
79620 /* Save the positions of all other cursors open on this table. This is
79651 ** Mark this cursor as an incremental blob cursor.
79711 ** Return the size of the header added to each page by this module.
79737 ** this is always 1. For shared caches it may be 1 or greater.
79750 ** The author disclaims copyright to this source code. In place of
79824 ** If the "temp" database is requested, it may need to be opened by this
79902 ** handle is not locked in this routine, but it is locked in
79959 ** Argument rc is an SQLite error code. Return true if this error is
79969 ** page iSrcPg from the source database. Copy this data into the
79985 ** guaranteed that the shared-mutex is held by this thread, handle
80040 ** Then clear the Btree layer MemPage.isInit flag. Both this module
80041 ** and the pager code use this trick (clearing the first byte
80044 ** "MUST BE FIRST" for this purpose.
80061 ** this function is a no-op.
80076 ** Register this backup object with the associated source pager for
80125 ** before this function exits.
80132 /* If the destination database has not yet been locked (i.e. if this
80214 ** round up. In this case the call to sqlite3OsTruncate() below will
80260 ** journal synced to disk. So at this point we may safely modify
80317 /* If bCloseTrans is true, then this function opened a read transaction
80359 /* Detach this backup from the source pager. */
80432 ** corresponding to the source database is held when this function is
80467 ** connection. In this case there is no way of knowing which of the
80472 ** corresponding to the source database is held when this function is
80488 ** The size of file pTo may be reduced by this operation. If anything
80511 ** from this function, not directly by the user.
80524 ** file. By passing this as the number of pages to copy to
80527 ** checks this assumption - (p->rc) should be set to either SQLITE_DONE
80552 ** The author disclaims copyright to this source code. In place of
80579 ** this: assert( sqlite3VdbeCheckMemInvariants(pMem) );
80587 /* MEM_Dyn may only be set if Mem.szMalloc==0. In this way we
80735 ** If pMem is an object with a valid string representation, this routine
80740 ** representation is already stored using the requested encoding, then this
80838 ** If pMem->zMalloc already meets or exceeds the requested size, this
80865 ** Three bytes of zero are added. In this way, there is guaranteed
80962 ** A MEM_Null value will never be passed to this function. This function is
81056 ** invoking the external callback in Mem.xDel, then this routine
81101 ** Use this routine prior to clean up prior to abandoning a Mem, or to
81408 ** To free all resources, use sqlite3VdbeMemRelease(), which both calls this
81411 ** Use this routine to reset the Mem prior to insert a new value.
81568 ** copies of this cell as invalid.
81585 ** A significant change would indicated a missed call to this
81650 ** pFrom contains an SQL NULL when this routine returns.
81792 ** If this routine fails for any reason (malloc returns NULL or unable
81799 Mem *pMem /* OUT: Return data in this Mem structure. */
81821 Mem *pMem /* OUT: Return data in this Mem structure. */
81933 ** the second argument to this function is NULL, the object is allocated
81936 ** Otherwise, if the second argument is non-zero, then this function is
81991 ** then this routine attempts to invoke the SQL function. Assuming no
81999 ** If the conditions above are not met, this function returns SQLITE_OK
82277 ** * (pExpr==0). In this case the value is assumed to be an SQL NULL,
82279 ** * The expression is a bound variable, and this is a reprepare, or
82332 ** A single call to this function populates zero or more fields of the
82336 ** * (pExpr==0). In this case the value is assumed to be an SQL NULL,
82338 ** * The expression is a bound variable, and this is a reprepare, or
82349 ** this function returns, output parameter *pnExtract is set to the
82352 ** When this function is called, *ppRec must either point to an object
82353 ** allocated by an earlier call to this function, or must be NULL. If it
82404 ** is undefined in this case.
82437 Mem *pMem = *ppVal; /* Write result into this Mem object */
82538 ** The author disclaims copyright to this source code. In place of
82694 ** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain
82695 ** unchanged (this is so that any opcodes already allocated can be
82761 ** op The opcode for this instruction
82872 Vdbe *p, /* Add the opcode to this VM */
82934 Vdbe *p, /* Add the opcode to this VM */
82973 ** If the bPush flag is true, then make this opcode the parent for
83030 Vdbe *p, /* Add the opcode to this VM */
83271 ** OP_Clear. So this routine may end up returning true in the case
83289 ** true for this case to prevent the assert() in the callers frame
83315 ** Assert if an Abort at this point in time might result in a corrupt
83341 ** script numbers the opcodes correctly. Changes to this routine must be
83362 ** cases from this switch! */
83579 /* Check that sqlite3VdbeUsesBtree() was not called on this VM */
83720 ** strives to omit useless byte-code like this:
83966 /* Note: this cast is safe, because the origin data point was an int
84020 ** makes the code easier to read during debugging. None of this happens
84064 ** If a memory allocation error has occurred prior to the calling of this
84069 ** this routine is a valid pointer. But because the dummy.opcode is 0,
84110 ** absence of other comments, this synopsis becomes the comment on the opcode.
84416 ** this routine obtains the mutex associated with each BtShared structure
84426 ** If SQLite is not threadsafe and does not support shared-cache mode, this
84432 ** this routine is N*N. But as N is rarely more than 1, this should not
84541 ** After this routine returns, all Mem elements in the array will still
84565 ** callgrind, this causes a certain test case to hit the CPU 4.7
84567 ** sqlite3MemRelease() were called from here. With -O2, this jumps
84636 int nRow; /* Stop when row count reaches this */
84691 ** kept in p->aMem[9].z to hold the new program - assuming this subprogram
84788 /* Even though this opcode does not use dynamic strings for
84913 /* An instance of this object describes bulk memory available for use
84930 ** been allocated by a prior call to this routine, so just return a copy
85004 ** After this routine is called the VM has been "packaged" and is ready
85005 ** to run. After this routine is called, further calls to
85237 ** Set the number of result columns that will be returned by this SQL
85292 ** write-transaction spanning more than one database file, this routine
85304 /* With this option, sqlite3VtabSync() is defined to be simply
85311 ** virtual module tables written in this transaction. This has to
85385 ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
85387 ** but could happen. In this case abandon processing and return the error.
85454 ** super-journal file. If an error occurs at this point close
85479 ** flag is set this is not required.
85514 ** doing this the directory is synced again before any individual
85527 ** this is happening we don't really care. The integrity of the
85651 ** If there are outstanding FK violations and this function returns
85678 ** call this on a VM that is in the SQLITE_STATE_HALT state.
85690 ** execution of this virtual machine.
85749 ** so, abort any other statements this handle currently has active.
85764 /* If the auto-commit flag is set and this is the only active writer
85825 ** do so. If this operation returns an error, and the current statement
85844 /* If this was an INSERT, UPDATE or DELETE and no statement transaction
85860 /* We have successfully halted and closed the VM. Record this fact. */
85945 ** After this routine is run, the VDBE should be ready to be executed
85948 ** To look at it another way, this routine resets the state of the
85999 /* Save profiling information from this VDBE run.
86094 ** The difference between this function and sqlite3VdbeDelete() is that
86262 ** 2019-07-11: The primary user of this subroutine was the OP_MakeRecord
86263 ** opcode in the byte-code engine. But by moving this routine in-line, we
86265 ** this routine is now only used by the STAT3 logic and STAT3 support has
86371 ** For most architectures, this is a no-op.
86387 ** (2007-08-30) Frank van Vugt has studied this problem closely
86397 ** verify this, but Frank seems to know what he is talking about
86600 UnpackedRecord *p /* Populate this structure before returning. */
86620 /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
86643 ** this function deserializes and compares values using the
86676 ** impact, since this routine is a very high runner. And so, we choose
86677 ** to ignore the compiler warnings and leave this variable uninitialized.
86730 /* No memory allocation is ever used on mem1. Prove this using
86754 ** pKey,nKey. The verify that this count is less than or equal to the
86757 ** If this constraint is not satisfied, it means that the high-speed
86759 ** not work correctly. If this assert() ever fires, it probably means
86765 const KeyInfo *pKeyInfo /* Compare size with this KeyInfo */
86907 ** Two NULL values are considered equal by this function.
86983 /* The collation sequence must be defined at this point, even if
86985 ** compiled (this was not always the case).
87002 ** The first argument passed to this function is a serial-type that
87080 ** that this routine begins comparing at the second field. */
87258 /* No memory allocation is ever used on mem1. Prove this using
87287 ** To avoid concerns about buffer overreads, this routine is only used
87346 ** this code. Including it causes gcc to generate a faster switch
87370 ** fields. Return pPKey2->default_rc in this case. */
87462 ** buffer passed to varintRecordCompareInt() this makes it convenient to
87466 ** The easiest way to enforce this limit is to consider only records with
87520 ** this code can safely assume that nCellKey is 32-bits
87585 ** is ignored as well. Hence, this routine only compares the prefixes
87651 ** Internally, this function just sets the Vdbe.expired flag on all
87792 ** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call,
87866 ** The author disclaims copyright to this source code. In place of
88521 /* If this statement was prepared using saved SQL and an
88562 ** with version 3.7.0, we changed this so that sqlite3_reset() would
88622 /* If this statement was prepared using saved SQL and an
88764 ** If this routine is invoked from within an xColumn method of a virtual
88769 ** If this routine is called from any context other than within the
88773 ** Virtual table implements might use this routine to optimize their
88832 ** Set (*ppOut) to point to this value before returning.
88840 ** Set (*ppOut) to point to this value before returning.
89027 ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
89088 ** Specifically, this is called from within:
89230 /* A malloc may have failed inside of the _text() call. If this
89333 ** A successful evaluation of this routine acquires the mutex on p.
89362 /* If the bit corresponding to this variable in Vdbe.expmask is set, then
89363 ** binding a new value to this variable invalidates the current query plan.
89640 ** It is misuse to call this routine with statements from different
89641 ** database connections. But as this is a deprecated interface, we
89835 /* Test that this call is being made from within an SQLITE_DELETE or
90079 ** The author disclaims copyright to this source code. In place of
90100 ** bytes in this text up to but excluding the first character in
90274 ** The author disclaims copyright to this source code. In place of
90282 ** The code in this file implements the function that runs the
90285 ** Various scripts scan this source file in order to generate HTML
90287 ** of the code in this file is, therefore, important. See other comments
90288 ** in this file for details. If in doubt, do not deviate from existing
90295 ** Invoke this macro on memory cells just prior to changing the
90312 ** procedures use this information to make sure that indices are
90321 ** When this global variable is positive, it gets decremented once before
90334 ** is executed. The test procedures use this information to make sure that
90346 ** use this information to make sure that the zero-blob functionality
90415 ** M is the type of branch. I is the direction taken for this instance of
90443 ** Since only a line number is retained, not the filename, this macro
90469 ** fulfilled by this instance of the jump. 0x01 means
90517 ** required for this VdbeCursor structure. It is convenient to use a
90654 u8 enc /* Use this text encoding */
90746 ** Unlike applyNumericAffinity(), this routine does not modify pMem->flags.
91057 u64 nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */
91069 assert( p->eVdbeState==VDBE_RUN_STATE ); /* sqlite3_step() verifies this */
91207 ** big comment (similar to this one) will mark the point in the code where
91211 ** generates two C files "opcodes.h" and "opcodes.c" by scanning this
91224 ** Documentation about VDBE opcodes is generated by scanning this file
91231 ** Formatting is important to scripts that scan this file.
91243 ** The P1 parameter is not actually used by this opcode. However, it
91245 ** that this Goto is the bottom of a loop and that the lines from P2 down
91272 ** But that is not due to sloppy coding habits. The code is written this
91280 ** of VDBE ops have been executed (either since this invocation of
91318 ** register, then this accomplishes a return from a subroutine.
91324 ** this opcode is used in combination with OP_BeginSubrtn, and set to 0
91327 ** The value in register P1 is unchanged by this opcode.
91333 ** in the subroutine from which this opcode is returning. Thus the P2
91354 ** this opcode. So jump over the coroutine implementation to
91369 /* Most jump operations do a goto to this spot in order to update
91404 ** If the coroutine that is launched by this instruction ends with
91406 ** the coroutine launched by this instruction ends with
91428 ** parameter P1, P2, and P4 as if this were a Halt instruction. If the
91429 ** value in register P3 is not NULL, then this routine is a no-op.
91448 ** or sqlite3_finalize(). For a normal halt, this should be SQLITE_OK (0).
91452 ** then back out all changes that have occurred during this execution of the
91494 ** currently being halted. If the p2 instruction of this OP_Halt
91496 ** an IGNORE exception. In this case jump to the address specified
91583 ** this transformation, the length of string P4 is computed and stored
91655 ** is the same as the P2 operand to this opcode and that has P3 set to 1.
91724 ** P4 points to a blob of data P1 bytes long. Store this
91820 ** destination. The 0x0001 bit of P5 indicates that this Copy opcode cannot
91897 ** constraint violations, this is a no-op.
92188 ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will
92194 ** maximum. The P1 register is initialized to 0 by this instruction.
92197 ** to retrieve the collation sequence set by this opcode is not available
92198 ** publicly. Only built-in functions have access to this feature.
92368 ** A NULL value is not changed by this routine. It remains NULL.
92397 ** to coerce both inputs according to this affinity before the
92400 ** back into the input registers P1 and P3. So this opcode can cause
92441 ** to coerce both inputs according to this affinity before the
92444 ** back into the input registers P1 and P3. So this opcode can cause
92588 /* At this point, res is negative, zero, or positive if reg[P1] is
92590 ** the answer to this operator in res2, depending on what the comparison
92592 ** that the 6 comparison operators are consecutive integers in this
92622 ** opcodes are allowed to occur between this instruction and the previous
92633 /* Verify the preconditions of this opcode - that it follows an OP_Lt or
92670 ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this
92696 CollSeq *pColl; /* Collating sequence to use on this term */
92836 ** The logic is summarized like this:
92892 ** Fall through to the next instruction the first time this opcode is
92899 ** the P1 of this opcode equal to the P1 of OP_Init. If P1 values are
92908 u32 iAddr; /* Address of this instruction */
92979 ** then this opcode might give spurious results.
93097 ** If P1 is not an open cursor, then this opcode is a no-op.
93120 ** code generator. The P1, P2, and P3 operands to this opcode are the
93154 ** from this record. If there are less than (P2+1)
93168 ** equivalent. In this case, all content loading can be omitted.
93259 ** Do this now to avoid an oversize memory allocation.
93277 ** accept it for historical reasons. When aOffset[0]==0, the code this
93281 ** this overread is harmless. Similar overreads can occur for a corrupt
93375 ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are
93465 ** This opcode is similar to OP_Affinity except that this opcode
93640 i64 nByte; /* Data space required for this record */
93653 ** like this:
93715 ** out how much space is required for the new record. After this loop,
94013 /* This call is Ok even if this savepoint is actually a transaction
94015 ** If this is a transaction savepoint being opened, it is guaranteed
94029 /* If there is no open transaction, then mark this as a special
94070 /* Determine whether or not this is a transaction savepoint. If so,
94071 ** and this is a RELEASE command, then the current transaction
94121 /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all
94165 ** VMs (apart from this one), then a ROLLBACK fails. A COMMIT fails if
94178 assert( db->nVdbeActive>0 ); /* At least this one VM is active */
94187 /* If this instruction implements a COMMIT and other VMs are writing
94239 ** true (this flag is set if the Vdbe may modify more than one row and may
94243 ** active statements. A statement transaction allows the changes made by this
94248 ** If P5!=0 then this opcode also checks the schema cookie against P3
94315 ** the value of this counter needs to be restored too. */
94336 ** If virtual-tables are in use, this is not just an optimization.
94352 ** from being modified in sqlite3VdbeHalt(). If this statement is
94370 ** executing this instruction.
94399 ** A transaction must be started before executing this opcode.
94471 ** b-tree and if it is this opcode becomes a no-op. In other words,
94587 ** before reaching this instruction. */
94613 ** SQLite used to check if the root-page flags were sane at this point
94614 ** and report database corruption if they were not, but this check has
94659 ** opened for a database. Since there is already an open cursor when this
94696 ** by this opcode will be used for automatically created transient
94826 ** A pseudo-table created by this opcode is used to hold a single
94844 /* Give this pseudo-cursor a fake BtCursor pointer so that pCx
94856 ** currently open, this instruction is a no-op.
94897 ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this
94900 ** this opcode must be followed by an IdxLE opcode with the same arguments.
94901 ** The IdxGT opcode will be skipped if this opcode succeeds, but the
94903 ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this
94964 ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this
94967 ** this opcode must be followed by an IdxLE opcode with the same arguments.
94968 ** The IdxGE opcode will be skipped if this opcode succeeds, but the
94970 ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this
95158 ** see if this is the case.
95179 ** This opcode is a prefix opcode to OP_SeekGE. In other words, this
95186 ** the P1, P2 and P5 operands of this opcode are also used, and are called
95192 ** of the b-tree instead. A correct answer is obtained if this opcode
95197 ** to. Call this SeekGE.P3/P4 row the "target".
95200 ** then this opcode is a no-op and control passes through into the OP_SeekGE.
95205 ** currently before the target row, then this opcode attempts to position
95220 ** Possible outcomes from this opcode:<ol>
95440 ** opcodes do not work after this operation.
95449 ** In other words, the operands to this opcode are the same as the
95452 ** This opcode is an optimization attempt only. If this opcode always
95469 ** In such a case, we abandon the IN clause search early, using this
95494 ** opcodes do not work after this operation.
95609 ** the P3 register must be guaranteed to contain an integer value. With this
95617 ** not work following this opcode.
95640 ** not work following this opcode.
95710 ** The sequence number on the cursor is incremented after this
95731 ** If P3>0 then P3 is a register in the root frame of this VDBE that holds
95733 ** allowed to be less than this value. When this value reaches its maximum,
95836 assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is
95879 ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
95880 ** UPDATE operation. Otherwise (if the flag is clear) then this opcode
95891 ** value of register P2 will then change. Make sure this does not
96014 ** the next Next instruction will be a no-op. As a result, in this case
96019 ** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this
96031 ** If P4 is not NULL then it points to a Table object. In this case either
96033 ** have been positioned using OP_NotFound prior to invoking this opcode in
96034 ** this case. Specifically, if one is configured, the pre-update hook is
96073 ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was
96197 ** parameter P3. Clearing the P3 column cache as part of this opcode saves
96229 ** If P3!=0 then this opcode is allowed to make an ephemeral pointer
96261 ** If this where not the case, on of the following assert()s
96262 ** would fail. Should this ever change (because of changes in the code
96289 ** be a separate OP_VRowid opcode for use with virtual tables, but this
96457 ** identified by P1, invoke this opcode to actually do the sorting.
96541 ** been opened prior to this opcode or the program will segfault.
96544 ** means P1 is an SQL index and that this instruction could have been
96569 ** means P1 is an SQL index and that this instruction could have been
96651 ** that this insert is likely to be an append.
96654 ** incremented by this instruction. If the OPFLAG_NCHANGE bit is clear,
96734 ** this (self-correcting and non-critical) error if in writable_schema mode.
96794 ** the rowid of the table entry to which this index entry points.
96859 ** already occurred, this instruction is a no-op.
96877 ** key that omits the PRIMARY KEY. Compare this key value against the index
96888 ** key that omits the PRIMARY KEY. Compare this key value against the index
96899 ** key that omits the PRIMARY KEY or ROWID. Compare this key value against
96910 ** key that omits the PRIMARY KEY or ROWID. Compare this key value against
97169 /* Any prepared statement that invokes this opcode will hold mutexes
97459 ** of a memory cell in this (the parent) VM that is used to allocate the
97481 ** disabled for backwards compatibility (p5 is set if this sub-program
97505 ** the trigger program. If this trigger has been fired before, then pRt
97511 ** variable nMem (and later, VdbeFrame.nChildMem) to this value.
97590 MemSetTypeFlag(&aMem[i], MEM_Undefined); /* Fault if this reg is reused */
97670 ** P1 is a register in the root frame of this VM (the root frame is
97671 ** different from the current frame if this instruction is being executed
97843 ** the opcode is changed. In this way, the initialization of the
97900 /* If this function is inside of a trigger, the register array in aMem[]
97956 ** P4 is a pointer to the FuncDef for this function. The P2
97957 ** argument is not used by this opcode. It is only there to disambiguate
97968 ** P4 is a pointer to the FuncDef for this function. The P2
97969 ** argument is not used by this opcode. It is only there to disambiguate
98044 ** modes (delete, truncate, persist, off and memory), this is a simple
98122 ** mode, this transaction always uses a rollback journal.
98287 ** Also, whether or not P4 is set, check that this is not being called from
98756 ** invocation of this opcode.
98775 ** invocation of this opcode.
98795 /* If this function is inside of a trigger, the register array in aMem[]
98932 ** Programs contain a single instance of this opcode as the very first
98942 ** first time they are evaluated for this run.
99045 ** Verify that an Abort can happen. Assert if an Abort at this point
99063 ** the registers is unreliable after this opcode completes.
99078 ** P5 ought to be set on every call to this opcode.
99085 ** not generated for release builds. The purpose of this opcode is to help
99125 ** The cases of the switch statement above this line should all be indented
99127 ** readability. From this point on down, the normal indentation rules are
99169 /* If we reach this point, it means that execution is finished with
99209 /* This is the only way out of this procedure. We have to
99261 ** The author disclaims copyright to this source code. In place of
99285 u16 iCol; /* Table column this handle is open on */
99471 ** key columns must be indexed. The check below will pick up this
99568 ** does. An OP_Column to retrieve this imaginary column will
99657 ** already been invalidated. Return SQLITE_ABORT in this case.
99669 /* If a pre-update hook is registered and this is a write cursor,
99672 ** TODO: The preupdate-hook is passed SQLITE_DELETE, even though this
99674 ** incorrect, but is convenient because at this point the new.* values
99679 ** using the incremental-blob API, this works. For the sessions module
99738 ** database handle error code and message set. If this happens, then all
99753 ** already been invalidated. Return SQLITE_ABORT in this case.
99780 ** The author disclaims copyright to this source code. In place of
99797 ** Here is the (internal, non-API) interface between this module and the
99850 ** an in-memory merge sort. In this case, no temporary files are required
99857 ** A PMA created at this point is known as a "level-0 PMA". Higher levels
99870 ** N is the configured number of worker threads. In this case, instead of
99882 ** final PMA. So at this point the data is stored in some number of sorted
99888 ** MergeEngine object, described in further detail below, performs this
99918 ** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various
99928 ** to a level 0 PMA. The purpose of this limit is to prevent various integer
99990 ** For the purposes of this comparison, EOF is considered greater than any
100034 SortSubtask *pTask; /* Used by this thread only */
100041 ** Exactly VdbeSorter.nTask instances of this object are allocated
100045 ** single-threaded operation, there is exactly one instance of this object
100048 ** Essentially, this structure contains all those fields of the VdbeSorter
100074 VdbeSorter *pSorter; /* Sorter that owns this sub-task */
100085 ** Main sorter structure. A single instance of this is allocated for each
100090 ** this variable is updated so as to be set to the size on disk of the
100128 i64 iEof; /* 1 byte past EOF for this PmaReader */
100159 ** the contents of the aFile[0] and aFile[1] variables within this structure,
100173 SortSubtask *pTask; /* Task that owns this merger */
100178 int bUseThread; /* True to use a bg thread for this object */
100183 ** An instance of this object is used for writing a PMA.
100205 ** by this module. If using a separate allocation for each in-memory record
100224 /* The data for the record immediately follows this header */
100260 ** next call to this function.
100302 /* The requested data is available in the in-memory buffer. In this
100309 ** In this case, allocate space at p->aAlloc[] to copy the requested
100387 ** *pp is undefined in this case.
100505 i64 *pnByte /* IN/OUT: Increment this value by PMA size */
100552 ** If IN/OUT parameter *pbKey2Cached is true when this function is called,
100693 ** statement. In this case, keys are always delivered to the sorter in
100805 #undef nWorker /* Defined at the top of this function */
100911 SortSubtask *pTask, /* Thread will use this task object */
100929 ** If this function is being called after SorterRewind() has been called,
100932 ** condition where this thread also attempts to join the same object, join
101083 i64 nExtend, /* Attempt to extend file to this size */
101277 ** The results of using the PMA-writer after this call are undefined.
101331 ** This is used by an assert() statement at the end of this function. */
101425 ** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this
101506 /* Use the foreground thread for this operation */
101509 /* Launch a background thread for this operation */
101720 ** For single-threaded objects, this is accomplished by literally reading
101726 ** been exhausted, this function also launches a new background thread
101767 ** If an OOM condition is encountered, return NULL. In this case free the
101873 ** Initialize the MergeEngine object passed as the second argument. Once this
101880 ** set the PmaReader objects up to read from it. In this case all that is
101900 ** invoking this routine */
101914 ** reading from the same temp file this makes for more linear file IO.
101918 ** on this PmaReader before any of the multi-threaded PmaReaders takes
101945 ** to be a multi-threaded PmaReader and this function is being called in a
101946 ** background thread. In this case all PmaReaders in the sub-tree are
101952 ** The reason this function does not call vdbePmaReaderNext() immediately
101955 ** this entire function is being run by thread (pTask->thread), that will
101961 ** In this case vdbePmaReaderNext() is called on all child PmaReaders and
102006 /* Use the current thread to populate aFile[1], even though this
102007 ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object,
102008 ** then this function is already running in background thread
102011 ** If this is the INCRINIT_ROOT object, then it is running in the
102014 ** first results are ready from this merger object anyway.
102045 ** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes
102047 ** this routine to initialize the incremental merge.
102078 ** When this function is called, *piOffset is set to the offset of the
102220 MergeEngine *pRoot = 0; /* Root node of tree for this task */
102355 ** this function is called to prepare for iterating through the records
102382 ** So the list is never empty at this point. */
102511 int nKeyCol, /* Compare this many columns */
102549 ** The author disclaims copyright to this source code. In place of
102843 ** Return the rowid for the current row. In this implementation, the
102976 ** The author disclaims copyright to this source code. In place of
103013 u8 zChunk[8]; /* Content of this chunk */
103017 ** By default, allocate this many bytes of memory for each FileChunk object.
103028 ** An instance of this object serves as a cursor into the rollback journal.
103038 ** is an instance of this class.
103062 sqlite_int64 iOfst /* Begin reading at this offset */
103145 ** before this function was called. */
103163 sqlite_int64 iOfst /* Begin writing at this offset into the file */
103179 /* If the contents of this write should be stored in memory */
103182 ** access writes are not required. The only exception to this is when
103184 ** atomic-write optimization. In this case the first 28 bytes of the
103321 ** but may be flushed to disk later on. In this case the journal file is
103337 ** it using the sqlite3OsOpen() function of the underlying VFS. In this
103338 ** case none of the code in this module is executed as a result of calls
103382 /* While this appears to not be possible without ATOMIC_WRITE, the
103399 ** Return true if this "journal file" is currently stored in heap memory,
103419 ** The author disclaims copyright to this source code. In place of
103476 ** The return value from this routine is WRC_Abort to abandon the tree walk
103531 ** This is a no-op callback for Walker->xSelectCallback2. If this
103614 ** If the Walker does not have an xSelectCallback() then this routine
103654 ** When this routine is the Walker.xExprCallback then expression trees
103656 ** when this routine is used for Walker.xExprCallback then
103679 ** The author disclaims copyright to this source code. In place of
103747 Expr *pExpr, /* Transform this into an alias to the result set */
103784 ** Check to see if the zSpan given to this routine matches the zDb, zTab,
103859 ** iColumn. Append this new expression term to the FULL JOIN Match set
103860 ** in *ppList. Create a new *ppList if this is the first term in the
103894 ** pExpr->pLeft Any expression this points to is deleted
103895 ** pExpr->pRight Any expression this points to is deleted.
103913 Expr *pExpr /* Make this EXPR node point to the selected column */
103940 ** resulting in an appropriate error message toward the end of this routine
103982 /* In this case, pItem is a subquery that has been formed from a
104231 ** In cases like this, replace pExpr with a copy of the expression that
104313 ** I now sorely regret putting in this hack. The effect of this hack is
104318 ** Someday, I hope to get rid of this hack. Unfortunately there is
104392 ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes
104475 ** Expr *pExpr // Invalidate this expression on error
104486 Expr *pExpr, /* Invalidate this expression on error */
104487 Expr *pError /* Associate error with this expression */
104507 ** Return 1024 times this value. Or return -1 if p is not a floating point
104575 ** if we can prove that "expr" is never NULL. Call this the
104578 ** If this optimization occurs, also restore the NameContext ref-counts
104738 ** all this. */
104982 ** this routine return an integer between 1 and N where N is the number of
104984 ** no match, or if pE is not a simple identifier, then this routine
105018 ** At the point this routine is called, we already know that the
105151 ** by pSelect. In the usual case this is done by duplicating the
105157 ** If this is running as part of an ALTER TABLE operation and
105236 assert( pEList!=0 ); /* sqlite3SelectNew() guarantees this */
105319 /* If an AS-name match is found, mark this ORDER BY column as being
105346 /* Since this expresion is being changed into a reference
105361 NameContext *pOuterNC; /* Context that contains this SELECT */
105362 NameContext sNC; /* Name context of this SELECT */
105381 ** already expanded this SELECT. However, if this is a subquery within
105384 ** sqlite3SelectPrep() do all of the processing for this SELECT.
105386 ** this routine in the correct order.
105413 /* If the SF_Converted flags is set, then this Select object was
105415 ** In this case the ORDER BY clause (p->pOrderBy) should be resolved
105483 ** Minor point: If this is the case, then the expression will be
105527 /* If this is a converted compound query, move the ORDER BY clause from
105528 ** the sub-query back to the parent query. At this point each term
105577 /* If this is part of a compound SELECT, check that it has the right
105741 ** sqlite3SelectExpand() prior to invoking this routine.
105817 ** The author disclaims copyright to this source code. In place of
105912 Expr *pExpr, /* Add the "COLLATE" clause to this expression */
105928 Expr *pExpr, /* Add the "COLLATE" clause to this expression */
106152 ** Argument pRight (but not pLeft) may be a null pointer. In this case,
106290 ** In that case, this routine works like sqlite3ExprDup().
106298 ** or a scalar expression, then it can be deleted as soon as this routine
106325 ** can be attached to pRight to cause this node to take ownership of
106378 ** already been generated using the exprCodeSubselect() routine. In this
106383 ** is generated. In this case (*pRegFree) may be set to the number of
106430 int dest, /* Write results into this register */
106539 ** If this maximum height is greater than the current value pointed
106635 ** for this node and for the pToken argument is a single allocation
106956 ** as the previous instance of the same wildcard. Or if this is the first
107145 ** of this routine with 0xfff. The flags can be found by masking the
107148 ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size
107156 ** to enforce this constraint.
107226 ** portion of the buffer copied into by this function.
107665 ** clause of an UPDATE statement. Like this:
107685 ** exit prior to this routine being invoked */
107881 ** always "fails". By "fail" in this case, we mean set
108081 ** For the purposes of this function, a double-quoted string (ex: "abc")
108098 ** When this routine returns true, it indicates that the expression
108129 ** (Is there some way to relax this constraint?)
108196 ** alternative collating sequences are uncommon, and this is only an
108228 ** For the purposes of this function, a double-quoted string (ex: "abc")
108474 ** The job of this routine is to find or create a b-tree object that can
108481 ** The returned value of this function indicates the b-tree type, as follows:
108499 ** existing table. In this case, the creation and initialization of the
108522 ** if the RHS of the IN operator is a list (not a subquery) then this
108571 /* If the RHS of this IN(...) operator is a SELECT, and if it matters
108651 /* Search for an existing index that will work for this IN operator */
108695 /* If we reach this point, that means the index pIdx is usable */
108821 ** it is not permitted. If pExpr is a sub-select vector, this routine
108867 int iTab /* Use this cursor number */
108891 /* If this routine has already been coded, but the previous code
108920 /* Check to see if this is a vector IN operator */
108951 ** error will have been caught long before we reach this point. */
109013 ** this code only executes once. Because for a non-constant
109014 ** expression we need to rerun this code each time.
109081 /* If this routine has already been coded, then invoke it as a
109106 ** If all of the above are false, then we can run this code just once
109117 ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
109241 int nVector; /* Size of vectors for this IN operator */
109263 /* Attempt to compute the RHS. After this step, if anything other than
109268 assert( v!=0 ); /* OOM detected prior to this routine */
109393 /* In this case, the RHS is the ROWID of table b-tree and so we also
109460 /* Step 7: If we reach this point, we know that the result must
109547 int regOut /* Store the index column value in this register */
109571 int regOut /* Put the result in this register */
109598 int regOut /* Extract the value into this register */
109646 ** There must be an open cursor to pTab in iTable when this routine
109726 ** so that a subsequent copy will not be merged into this one.
109742 int target /* Store function result in this register */
109905 ** With this routine, there is no guarantee that results will
109915 int regFree1 = 0; /* If non-zero free this temporary register */
109916 int regFree2 = 0; /* If non-zero free this temporary register */
110068 ** Expr node to be passed into this function, it will be handled
110269 u8 enc = ENC(db); /* The text encoding used by this database */
110471 ** trigger programs. In this case Expr.iTable is set to 1 for the
110699 ** result is not reusable. If regDest<0 then this routine is free to
110709 int regDest /* Store the value in this register */
110761 ** If pExpr is a constant, then this routine might generate this
110827 ** in register target. If the expression is constant, then this routine
110871 assert( pParse->pVdbe!=0 ); /* Never gets this far otherwise */
110969 ** it into the Parse.pConstExpr list. We should use a new bit for this,
111014 if( NEVER(pExpr==0) ) return; /* No way this can happen */
111382 ** Sometimes this routine will return 2 even if the two expressions
111384 ** identical, we return 2 just to be safe. So if this routine
111388 ** this routine is used, it does not hurt to get an extra 2 - that
111494 ** only consequence will be disabled optimizations. But this routine
112086 /* If we reach this point, it means that pExpr refers to a table
112292 ** Always invoke this procedure after coding a subroutine or co-routine
112330 ** The author disclaims copyright to this source code. In place of
112344 ** The code in this file only exists if we are not omitting the
112352 ** If the table is a system table, this function leaves an error message
112382 int bTemp, /* True if this is the temp db */
112463 VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */
112479 ** in database iDb. If so, this is an error.
112486 "there is already another table or index with this name: %s", zName);
112569 /* If the sqlite_sequence table exists in this database, then update
112594 /* If this is a virtual table, invoke the xRename() function if
112826 /* Make sure this is not an attempt to ALTER a view. */
112842 ** the name by adding an "sqlite_altertab_" prefix. By adding this
113055 ** The point of this is to prevent comparisons of invalid pointer values.
113056 ** Even though this always seems to work, it is undefined according to the
113091 ** The pPtr argument is returned so that this routine can be used
113282 ** If the second argument passed to this function is not NULL and a matching
113356 ** the input SQL is parsed from left to right. Repeated calls to this routine
113451 ** is initialized by this function before it is used.
113546 /* At this point pRename->pList contains a list of RenameToken objects
113569 /* Dequote the double-quoted token. Then requote it again, this time
113628 ** error would have been hit before this point */
114086 /* If this is the table being altered, fix any table refs in CHECK
114292 ** reloaded, this function is called on each SQL statement in the schema
114466 /* Make sure this is not an attempt to ALTER a view, virtual table or
114610 ** The author disclaims copyright to this source code. In place of
114652 ** a string consisting of a list of integers. The first integer in this
114775 int iStatCur, /* Open the sqlite_stat1 table on this cursor */
114776 const char *zWhere, /* Delete entries for this table or index */
115107 ** the same column (pNew->iCol==pOld->iCol). Ignoring this column and
115108 ** considering only any trailing columns and the sample hash value, this
115182 ** added a sample that shares this prefix, there is no need to add
115183 ** this one. Instead, upgrade the priority of the highest priority
115184 ** existing sample that shares this prefix. */
115250 ** Field iChng of the index being scanned has changed. So at this point
115253 ** correct at this point.
115259 ** into IndexSample.a[] at this point. */
115297 ** The purpose of this routine is to collect statistical data and/or
115324 /* This is the first call to this function. Do initialization. */
115359 /* Check if this is to be a periodic sample. If so, add it. */
115415 ** STAT_GET_STAT1 and is hence omitted and this routine becomes
115426 /* STAT4 has a parameter on this routine. */
115440 ** table for this index.
115579 Index *pOnlyIdx, /* If not NULL, only analyze this one index */
115646 ** this time though. */
115995 ** Generate code for the ANALYZE command. The parser calls this routine
116074 Index *pIndex /* Handle extra flags for this index, if not NULL */
116172 ** sqlite_stat1 entries for this index. In that case just clobber
116237 /* If this is stat4 data, then calculate aAvgEq[] values for all
116264 ** occur in the stat4 table for this index. Set sumEq to the sum of
116413 ** a corrupt record. Adding the two 0x00 bytes prevents this from causing
116460 ** is returned. In this case, even if SQLITE_ENABLE_STAT4 was defined
116466 ** returned. However, in this case, data is read from the sqlite_stat1
116469 ** If an OOM error occurs, this function always sets db->mallocFailed.
116550 ** The author disclaims copyright to this source code. In place of
116651 /* This is not a real ATTACH. Instead, this routine is being called
116700 ** it to obtain the database schema. At this point the schema may
116784 ** If this fails, or if opening the file failed, then close the file and
116964 /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
117190 ** The author disclaims copyright to this source code. In place of
117200 ** systems that do not need this facility may omit it by recompiling
117206 ** All of the code in this file may be omitted by defining a single
117217 ** is a copy of the 3rd argument to this routine. The second argument
117253 ** Setting the auth function to NULL disables this hook. The default
117288 ** is treated as SQLITE_DENY. In this case an error is left in pParse.
117320 ** Check to see if it is OK to read this particular column.
117428 ** Push an authorization context. After this routine is called, the
117430 ** popped. Or if pParse==0, this routine is a no-op.
117461 ** The author disclaims copyright to this source code. In place of
117470 ** when syntax rules are reduced. The routines in this file handle the
117886 ** The difference between this routine and sqlite3FindTable() is that this
117948 ** sqlite3LocateTable() and this function is that this function restricts
118257 ** Table. No changes are made to disk by this routine.
118276 ** lookaside, this number should not change.
118280 ** that no lookaside memory is used in this case either. */
118288 /* Delete all indices associated with this table. */
118444 /* The table or view or trigger name is passed to this routine via tokens
118511 ** When parsing the sqlite_schema table, this routine also checks to
118518 const char *zType, /* Type of this object */
118583 ** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro.
118615 ** V means VIRTUAL. Suppose the CREATE TABLE has columns like this:
118620 ** Then the mapping from this function is as follows:
118625 ** So, in other words, this routine shifts all the virtual columns to
118629 ** this routine is a no-op macro. If the pTab does not have any virtual
118630 ** columns, then this routine is no-op that always return iCol. If iCol
118631 ** is negative (indicating the ROWID column) then this routine return iCol.
118671 ** to a CREATE TABLE statement. In particular, this routine is called
118680 ** routines will be called to add more information to this record.
118688 int isTemp, /* True if this is a TEMP table */
118689 int isView, /* True if this is a VIEW */
118690 int isVirtual, /* True if this is a VIRTUAL table */
118914 ** When this routine is called, we do not yet know if the RETURNING clause
118962 ** The parser calls this routine once for each column declaration
118964 ** first to get things going. Then this routine is called for each
118989 ** with "generated always". Check for this case and omit the surplus
119090 ** on this column. */
119198 ** Default value expressions must be constant. Raise an exception if this
119292 ** a primary key (and this is the second primary key) then create an
119432 ** then an index may have been created on this column before the
119433 ** collation type was added. Correct this if it is the case.
119725 ** collating sequence must match for this routine, but for hasColumn() only
119757 ** 2019-10-24: For the purpose of this computation, virtual columns are
119786 ** has a WITHOUT ROWID clause. The job of this routine is to convert both
119839 /* Locate the PRIMARY KEY index. Or, if this table was originally
120024 ** zName is temporarily modified while this routine is running, but is
120025 ** restored to its original value prior to this routine returning.
120046 ** index definition are tagged this way to help ensure that we do
120077 ** this is a temporary table or db->init.busy==1. When db->init.busy==1
120080 ** recently changed, so the entry for this table already exists in
120083 ** If the pSelect argument is not NULL, it means that this routine
120116 ** If the root page number is 1, that means this is the sqlite_schema
120243 ** If this is a TEMPORARY table, write the entry into the auxiliary
120273 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
120403 /* If this is the magic sqlite_sequence table used by autoincrement,
120404 ** then record a pointer to this table in the main database structure
120428 ** The parser calls this routine in order to create a new VIEW
120459 ** setting fixes this problem. But the fix can be disabled by compiling
120546 /* A positive nCol means the columns names for this view are
120553 ** trying to compute the column names. If we enter this routine with
120554 ** a negative nCol, it means two or more views form a loop, like this:
120559 ** Actually, the error above is now caught prior to reaching this point.
120573 /* If we get this far, it means we need to compute the table names.
120719 ** erasing iTable (this can happen with an auto-vacuum database).
120728 /* OP_Destroy stores an in integer r1. If this integer
120731 ** reflect this.
120749 ** is also added (this can happen with an auto-vacuum database).
121049 ** to sqlite3DeferForeignKey() might change this to DEFERRED.
121053 ExprList *pFromCol, /* Columns in this table that point to other table */
121214 int iPartIdxLabel; /* Jump to this label to skip a row */
121215 Vdbe *v; /* Generate code into this virtual machine */
121228 /* Require a write-lock on the table to perform this operation */
121310 ** pointer to this extra space in *ppExtra.
121369 ** pList is a list of columns to be indexed. pList will be NULL if this
121374 Parse *pParse, /* All information about this parse */
121380 Token *pStart, /* The CREATE token that begins this statement */
121424 ** to search for the table. 'Fix' the table name to this db
121434 ** is a temp table. If so, set the database to 1. Do not do this
121501 ** index, then we will continue to process this index.
121545 ** The "vtab_err.test" test demonstrates the need of this statement. */
121565 /* If pList==0, it means this routine was called to make a primary
121567 ** So create a fake list to simulate this.
121710 ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For
121711 ** normal tables (when pPk==0) this will be the rowid.
121735 /* If this index contains every column of its table, then mark
121760 ** so, don't bother creating this one. This only applies to
121793 ** However the ON CONFLICT clauses are different. If both this
121795 ** ON CONFLICT clauses this is an error. Otherwise, use the
121845 /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
121849 ** content. But, do not do this if we are simply reading the sqlite_schema
121850 ** table to parse the schema, or if this index is the PRIMARY KEY index
121853 ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY
121870 ** Index.tnum. This is required in case this index is actually a
121893 /* Add an entry in sqlite_schema for this index
121935 ** The list was already ordered when this routine was entered, so at this
122004 ** Failure to do this can cause the indexes for which we do not have
122100 ** When this function is called, *pnEntry contains the current size of
122107 ** returned. *pIdx is set to the index of the new array entry in this case.
122211 ** To append 3 new entries onto the end, do this:
122287 ** that is input to this routine is automatically freed.
122290 ** database name prefix. Like this: "database.table". The pDatabase
122297 ** In other words, if call like this:
122302 ** like this:
122316 SrcList *pList, /* Append to this SrcList. NULL creates a new SrcList */
122403 ** if this is the first term of the FROM clause. pTable and pDatabase
122501 ** are deleted by this function.
122543 ** Example: Suppose the join is like this:
122762 ** The code generator calls this routine if is discovers that it is
122764 ** perform this abort without corrupting the database, we need to make
122771 ** go a little faster. But taking advantage of this time dependency
123109 /* Check that the CTE name is unique within this WITH clause. If
123159 ** The author disclaims copyright to this source code. In place of
123203 ** of this collation function (for other text encodings) available. Use one
123229 ** If required, this routine calls the 'collation needed' callback to
123230 ** request a definition of the collating sequence. If this doesn't work,
123259 ** the collation sequence name. A pointer to this string is stored in
123308 ** this routine. sqlite3LocateCollSeq() invokes the collation factory
123373 /* No collation sequence of this type for this encoding is registered.
123424 /* During the search for the best function definition, this procedure
123701 ** The author disclaims copyright to this source code. In place of
123716 ** (as in the FROM clause of a SELECT statement) in this case it contains
123765 ** 3) It is a system table (i.e. sqlite_schema), this call is not
124148 ** this optimization caused the row change count (the value returned by
124206 ** to indicate the strategy used to implement this delete:
124258 /* Add the PK key for this row to the temporary table */
124272 /* Unless this is a view, open cursors for the table we are
124273 ** deleting from and all its indices. If this is a view, then the
124274 ** only effect this statement has is to fire the INSTEAD OF
124360 /* Return the number of rows that were deleted. If this routine is
124380 ** they may interfere with compilation of other functions in this file
124381 ** (or in another file, if this file becomes part of the amalgamation). */
124413 ** then this function must seek iDataCur to the entry identified by iPk
124416 ** If eMode is ONEPASS_MULTI, then this call is being made as part
124417 ** of a ONEPASS delete that affects multiple rows. In this case, if
124427 ** Except, this optimization is disabled if there are BEFORE triggers since
124448 /* Vdbe is guaranteed to have been allocated by this stage. */
124453 /* Seek cursor iCur to the row to delete. If this row no longer exists
124454 ** (this can happen if a trigger program has already deleted it), do
124515 ** refer to this table (i.e. constraints attached to other tables)
124516 ** are not violated by deleting this row. */
124520 /* Delete the index and table entries. Skip this step if pTab is really
124524 ** If variable 'count' is non-zero, then this OP_Delete instruction should
124588 int iIdxNoSeek /* Do not delete from this cursor */
124626 ** this routine returns.
124651 int regOut, /* Put the new key into this register if not 0 */
124653 int *piPartIdxLabel, /* OUT: Jump to this label to skip partial index */
124691 ** But we are getting ready to store this value back into an index, where
124706 ** because it was a partial index, then this routine should be called to
124720 ** The author disclaims copyright to this source code. In place of
124753 ** Indicate that the accumulator load should be skipped on this
125226 ** However, we still need some kind of function implementation for this
125227 ** routines in the function table. The noopFunc macro provides this.
125247 ** number of you get the same value back again. To do this
125404 ** The comments within this routine usually assume glob matching.
125439 ** recursive search in this case, but it is an unusual case. */
125450 /* At this point variable c contains the first character of the
125775 ** we might relax this requirement in the future, but that will
126148 ** When the "sqlite3" command-line shell is built using this functionality,
126942 ** After this routine runs
126947 ** defined in this file.
126950 ** FuncDef.pHash elements at start-time. The elements of this array
127127 ** The author disclaims copyright to this source code. In place of
127169 ** transaction is opened, this may cause the mechanism to malfunction.
127171 ** Despite these problems, this approach is adopted as it seems simpler
127217 ** statement that inserts a single row only (no triggers). In this case,
127236 ** generation code to query for this information are:
127324 /* If this is a non-composite (single column) foreign key, check if it
127357 ** column of pFKey, then this index is a winner. */
127360 /* If zKey is NULL, then this foreign key is implicitly mapped to
127371 /* If zKey is non-NULL, then this foreign key was declared to
127372 ** map to an explicit list of columns in table pParent. Check if this
127384 ** the default collation sequence for the column, this index is
127385 ** unusable. Bail out early in this case. */
127421 ** on the child table of pFKey, this function is invoked twice for each row
127425 ** Each time it is called, this function generates VDBE code to locate the
127441 ** These operations are identified in the comment at the top of this file
127452 int nIncr, /* Increment constraint counter by this */
127468 ** to check if deleting this row resolves any outstanding violations.
127490 ** apply the affinity of the parent key). If this fails, then there
127500 ** to increment the constraint-counter (i.e. this is an INSERT operation),
127527 ** to increment the constraint-counter (i.e. this is an INSERT operation),
127533 ** of the parent-key values are NULL (at this point it is known that
127568 /* Special case: If this is an INSERT statement that will insert exactly
127647 ** code for an SQL UPDATE operation, this function may be called twice -
127650 ** Parameter nIncr is passed -1 when inserting a row (as this may decrease
127651 ** the number of FK violations in the db) or +1 when deleting one (as this
127654 ** The code generated by this function scans through the rows in the child
127668 ** These operations are identified in the comment at the top of this file
127725 ** to the WHERE clause that prevent this entry from being scanned.
127726 ** The added WHERE clause terms are like this:
127794 ** Calling this function with table "t1" as an argument returns a pointer
127796 ** "t2". Calling this function with "t2" as the argument would return a
127845 ** to this function contains a single entry guaranteed to resolve to
127856 ** the table from the database. Triggers are disabled while running this
127868 /* Search for a deferred foreign key constraint for which this table
127872 ** when this statement is run. */
127887 ** violations, halt the VDBE and return an error at this point, before
127891 ** If the SQLITE_DeferFKs flag is set, then this is not required, as
127926 int bChngRowid /* True if rowid is modified by this update */
128000 ** zero in this case.
128006 ** For an UPDATE operation, this function is called twice. Once before
128013 Table *pTab, /* Row is being deleted from this table */
128028 /* If foreign-keys are disabled, this function is a no-op. */
128053 /* Find the parent table of this foreign key. Also find a unique index
128066 /* If isIgnoreErrors is true, then a table is being dropped. In this
128127 ** If this operation is being performed as part of a trigger program
128128 ** that is actually a "SET NULL" action belonging to this very
128129 ** foreign key, then omit this scan altogether. As all child key
128131 ** this row to cause an FK violation. */
128138 /* Loop through all the foreign key constraints that refer to this table.
128154 ** an immediate foreign key violation. So do nothing in this case. */
128180 /* If this is a deferred FK constraint, or a CASCADE or SET NULL
128183 ** So do not set the "may-abort" flag in this case.
128186 ** may-abort flag will eventually be set on this statement anyway
128187 ** (when this function is called as part of processing the UPDATE
128250 ** If any foreign key processing will be required, this function returns
128251 ** non-zero. If there is no foreign key related processing, this function
128254 ** For an UPDATE, this function returns 2 if:
128352 Index *pIdx = 0; /* Parent key index for this FK */
128393 ** The final WHEN clause will be like this:
128539 ** for this operation (either update or delete), invoke the associated
128589 /* Delete any triggers created to implement actions for this FK. */
128606 ** The author disclaims copyright to this source code. In place of
128629 Parse *pParse, /* Generate code into this VDBE */
128748 ** which were then optimized out) then this routine becomes a no-op.
128927 ** this is a two-pass algorithm. On the first pass, mark all generated
128990 ** triggers. A new AutoincInfo structure is created if this is the
129067 assert( v ); /* We failed long ago if this is not so */
129126 ** table (either directly or through triggers) needs to call this
129208 ** once straight down through. Pseudo-code follows (we call this
129226 ** See the xferOptimization() function for the implementation of this
129242 ** The generated code follows this template:
129263 ** the select. The template is like this:
129296 Vdbe *v; /* Generate code into this virtual machine */
129304 int srcTab = 0; /* Data comes from this temporary cursor if >=0 */
129431 /* If this is an AUTOINCREMENT table, look up the sequence number in the
129456 ** PRIMARY KEY in the original table is pTab->iPKey.) After this
129648 /* If this is not a view, open the table and and all indices */
129732 ** Only ordinary columns are computed in this loop. The rowid
129746 ** using excess space. The file format definition requires this extra
129861 /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
129863 ** If this is a real table, attempt conversions as required by the
129953 ** constraints or (b) there are no triggers and this table is not a
130020 ** Return the number of rows inserted. If this routine is
130038 ** they may interfere with compilation of other functions in this file
130039 ** (or in another file, if this file becomes part of the amalgamation). */
130058 * Set bit 0x01 of pWalker->eCode if pWalker->eCode to 0 and if this
130083 ** return true if this CHECK constraint must be validated for
130087 ** The operation of this routine is the same - return true if an only if
130118 ** this.
130130 struct { /* Use this object for eType==0: A Index.pNext list */
130133 struct { /* Use this object for eType==1; Array of IndexListTerm */
130145 int ix; /* Which entry in the original Table.pIndex list is this index*/
130183 ** pTab->nCol+1 registers in this range. The first register (the one
130206 ** The code generated by this routine will store new index entries into
130277 u8 overrideError, /* Override onError to this if not OE_Default */
130278 int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
130294 u8 isUpdate; /* True if this is an UPDATE operation */
130304 int lblRecheckOk = 0; /* Each recheck jumps to this label if it passes */
130328 /* Record that this module has started */
130344 if( onError==OE_None ) continue; /* No NOT NULL on this column */
130496 ** Constraint checking code is generated in this order:
130624 /* figure out whether or not upsert applies in this case */
130687 /* If there are DELETE triggers on this table and the
130699 ** also invoke MultiWrite() to indicate that this VDBE may require
130767 int iThisCur; /* Cursor for this UNIQUE index */
130796 /* Create a record for this index entry as it should appear after
130828 /* In an UPDATE operation, if this index is the PRIMARY KEY index
130849 /* Figure out if the upsert clause applies to this index */
130921 ** KEY values of this row before the update. */
131004 /* Bypass the recheck if this partial index is not defined
131151 ** The arguments to this routine should be the same as the first six
131162 int appendBias, /* True if this is likely to be an append */
131239 ** If pTab is a virtual table, then this routine is a no-op and the
131247 int iBase, /* Use this for the table cursor, if there is one */
131373 ** case, this routine generates code for the xfer optimization but also
131375 ** xfer optimization code if the test fails. In that case, this routine
131407 /* Do not attempt to process this query if there are an WITH clauses
131458 /* At this point we have established that the statement is of the
131459 ** correct syntactic form to participate in this optimization. Now
131498 ** generated columns, then this statement is semantically incorrect:
131506 ** Nevertheless, this is a useful notational shorthand to tell SQLite
131509 ** We could, in theory, disable this (except for internal use by the
131569 /* The sqlite3FaultSim() call allows this corruption test to be
131585 ** the extra complication to make this rule less restrictive is probably
131597 /* If we get this far, it means that the xfer optimization is at
131622 ** DBFLAG_Vacuum flag is set, this block generates code to make
131709 ** order. In this case, instead of seeking within the b-tree as part
131715 ** BINARY, this optimization is disabled. This is because the user
131767 ** The author disclaims copyright to this source code. In place of
131775 ** Main file for the SQLite library. The routines in this file
131796 sqlite3_callback xCallback, /* Invoke this callback routine */
131822 /* this happens for a comment or white-space */
131911 ** The author disclaims copyright to this source code. In place of
131931 ** The author disclaims copyright to this source code. In place of
131942 ** as extensions by SQLite should #include this file instead of
131954 ** interfaces to the end of this structure only. If you insert new
131955 ** interfaces in the middle of this structure, then older different
132742 ** A pointer to this structure is passed into extensions when they are
132746 ** When adding new APIs, add them to the bottom of this structure
133166 ** error message text. The calling function should free this memory
133170 sqlite3 *db, /* Load the extension into this database connection */
133321 sqlite3 *db, /* Load the extension into this database connection */
133335 ** Call this routine when the database connection is closing in order
133369 ** mutex must be held while accessing this list.
133438 ** is currently on the list. If xInit is not on the list, then this
133535 ** The author disclaims copyright to this source code. In place of
134312 ** remainder of this file is specific to PRAGMA processing. So omit
134545 int isBuiltin, /* True if this is a built-in function */
134607 ** Pragmas are of this form:
134649 ** index of the database this pragma is being applied to in db.aDb[]. */
134861 ** second form attempts to change this setting. Both
134910 ** of the PRAGMA command. In this case the locking-mode must be
135021 ** incr-vacuum flags. This is required in case this connection
135030 ** that this really is an auto-vacuum capable database.
135151 ** database file. If this parameter is set to zero, then memory mapping
135199 ** override this setting
135264 ** by this setting, regardless of its value.
135476 ** schema: Name of attached database hold this table
135818 ** regRow..regRow+n. If any of the child key values are NULL, this
135820 ** this case. */
135904 Table *pObjTab = 0; /* Check only this one table, if not NULL */
135910 ** In this case, the integrity of database iDb only is verified by
135914 ** "PRAGMA quick_check"), then iDb is set to 0. In this case, set iDb
136311 ** In its first form, this pragma returns the encoding of the main
136314 ** The second form of this pragma is a no-op if the main database file
136315 ** has not already been initialized. In this case it sets the default
136323 ** is executed, this is done before the ATTACH operation.
136325 ** In the second form this pragma sets the text encoding to be used in
136326 ** new database files created using this database handle. It is only
136401 ** Subverting this mechanism by using "PRAGMA schema_version" to modify
136455 ** Return the names of all compile-time options used in this build,
136535 ** The details of optimizations performed by this pragma are expected
136537 ** this pragma will perform new optimizations in future releases.
136682 ** limit. The hard heap limit can be activated or lowered by this
137147 ** The author disclaims copyright to this source code. In place of
137309 /* If the SQL column is blank it means this is an index that
137401 ** will be closed before this function returns. */
137538 ** this situation the current sqlite3_prepare() operation will fail,
137543 ** The primary purpose of this is to allow access to the sqlite_schema
137689 ** created by a sub-select). In this case the return value of this
137746 ** Use this mechanism for uncommon cleanups. There is a higher setup
137747 ** cost for this mechansim (an extra malloc), so it should not be used
137755 ** that test cases exist for which this happens, to guard against possible
137756 ** use-after-free errors following an OOM. The preferred way to do this is
137757 ** to immediately follow the call to this routine with:
137764 ** Or, stop using the pPtr parameter with this call and use only its
137765 ** return value thereafter. Something like this:
137770 Parse *pParse, /* Destroy when this Parser finishes */
137794 ** Call sqlite3ParseObjectReset() to undo this operation.
137796 ** Caution: Do not confuse this routine with sqlite3ParseObjectInit() which
137861 ** back and different changes are made in their place, then when this
137868 ** while this routine is running. Hence, we do not need to hold
137873 ** but it does *not* override schema lock detection, so this all still
137953 /* Delete any TriggerPrg structures allocated while parsing this statement. */
138214 ** The author disclaims copyright to this source code. In place of
138597 ** the OUTER JOIN processing logic that this term is part of the
138606 ** for cases like this:
138712 /* If this is a NATURAL join, synthesize an approprate USING clause
138746 ** A and B and the USING clause names X, Y, and Z, then add this
138778 ** JOINs. If only a single table on the left side of this join
138779 ** contains the zName column, then this branch is a no-op.
138838 ** An instance of this object holds information (beyond pParse and pSelect)
138921 ** by a prior OP_MakeRecord. In this case nData==1 and regData
138929 ** regOrigData is 0 to prevent this routine from trying to copy
138996 /* At this point the values for the new sorter entry are stored
139040 Vdbe *v, /* Generate code into this VM */
139062 ** be opened before the VM code generated by this routine is executed.
139068 ** The returned value in this case is a copy of parameter iTab.
139071 ** In this case rows are being delivered sorted order. The ephermal
139077 ** The returned value in this case is the register number of the first
139079 ** it can be compared to the next. The caller must ensure that this
139081 ** will take care of this initialization.)
139084 ** In this case it has already been determined that the rows are distinct.
139088 ** contents of each row. It is used by this routine to determine (a)
139218 ** retrieved directly from table t1. If the values are very large, this
139295 ** are evaluated in order to get the data for this row. If srcTab is
139302 int srcTab, /* Pull data from this table if non-negative */
139319 ** containing the current result row. In this case regOrig is set to the
139322 ** from this array. In this case regOrig is set to zero. */
139425 ** from the sorter by the optimizations in this branch */
139468 ** and this row has been seen before, then do not make this row
139493 /* In this mode, write each query result to the key of the temporary
139585 ** then there should be a single item on the stack. Write this
139591 ** ORDER BY in this case since the order of entries in the set
139616 /* If this is a scalar select that is part of an expression, then
139767 ** can only be changed if this is just a single reference to the object.
139785 ** function is responsible for seeing that this structure is eventually
139790 ExprList *pList, /* Form the KeyInfo object from this ExprList */
139791 int iStart, /* Begin with this column of pList */
139792 int nExtra /* Add this many extra columns to the end */
139828 ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
139842 ** Assign expression b to lvalue a. A second, no-op, version of this macro
140086 ** considered a column by this function.
140146 ** cause this condition to run. Since then, we have restructured how
140147 ** trigger code is generated and so this condition is no longer
140155 ** sub-select. In this case, set the column type to NULL, even
140276 ** column specific strings, in case the schema is reset before this
140299 ** when modifying this routine to avoid breaking legacy.
140305 ** applications should operate this way. Nevertheless, we need to support the
140323 Select *pSelect /* Generate column names for this SELECT statement */
140335 /* If this is an EXPLAIN, skip this step */
140410 ** when modifying this routine to avoid breaking legacy.
140532 Table *pTab, /* Add column type information to this table */
140643 ** prior to calling this routine.
140650 ** redefined. The UNION ALL operator uses this property to force
140721 ** this far */
140734 ** function is responsible for ensuring that this structure is eventually
140965 ** VALUES clause. By handling this as a special case, we avoid deep
141028 ** in which case this routine will be called recursively.
141046 ** So if this routine is called with p equal to the t3 query, then
141047 ** pPrior will be the t2 query. p->op will be TK_UNION in this case.
141059 Vdbe *v; /* Generate code to this VDBE */
141067 assert( p && p->pPrior ); /* Calling function guarantees this much */
141348 ** SELECT statements to the left always skip this part. The right-most
141349 ** SELECT might also skip this part if it has no ORDER BY clause and
141505 /* If this is a scalar select that is part of an expression, then
141615 ** output value. A comparison is made against this value and the output
141619 ** subroutines first, then put the control logic at the bottom. Like this:
141655 Vdbe *v; /* Generate code to this VDBE */
141689 assert( pKeyDup==0 ); /* "Managed" code needs this. Ticket #3382. */
141942 /* Jump to the this point in order to terminate the query.
141988 ** Example where this is needed:
142002 int iTable; /* Replace references to this table */
142205 ** If pSrc contains any sub-selects, call this routine recursively
142313 ** The default way of implementing this query is to execute the
142321 ** a single flat select, like this:
142325 ** The code generated for this simplification gives the same result
142355 ** sub-queries that were excluded from this optimization. Restriction
142429 ** an ORDER BY clause. Ticket #3773. We could relax this constraint
142446 ** or max() functions. (Without this restriction, a query like:
142466 ** In this routine, the "p" parameter is a pointer to the outer query.
142470 ** If flattening is not attempted, this routine is a no-op and returns 0.
142471 ** If flattening is attempted this routine returns 1.
142474 ** the subquery before this routine runs.
142545 ** subquery may not be a join itself (3a). Example of why this is not
142606 /* Without this restriction, the JT_LTORJ flag would end up being
142647 /***** If we reach this point, flattening is permitted. *****/
142677 ** using UNION ALL operators. In this case N is the number of simple
142699 ** We call this the "compound-subquery flattening".
142762 ** then this loop only runs once.
142765 ** the FROM clause of the outer query. Before doing this, remember
142835 /* At this point, any non-zero iOrderByCol values indicate that the
142841 ** Not doing this may cause an error if a subsequent call to this
142843 ** (the only way this can happen is if the compound sub-query is
142884 ** One is tempted to try to add a and b to combine the limits. But this
143113 ** and collating sequence interactions. Consider this example:
143123 ** To work around this, the expression tree is not actually changed from
143127 ** column value. Also, to avoid collation problems, this optimization is
143139 ** resulting in a false positive. To avoid this, constant propagation for
143200 ** this may change the results of the window functions.
143202 ** At the time this function is called it is guaranteed that
143231 ** Do not attempt this optimization if:
143234 ** disallow this optimization for aggregate subqueries, but now
143275 ** filter out entire partitions, as this does not change the
143283 ** or EXCEPT. (We could, perhaps, relax this restriction to allow
143284 ** this case if none of the comparisons operators between left and
143370 /* Restriction 6c has prevented push-down in this case */
143450 ** does match this pattern, then a pointer to the Table object representing
143455 ** this routine returns NULL when it could have returned a table pointer.
143560 ** by this function is not required in this case. */
143568 /* If we reach this point, that means the transformation is required. */
143650 ** onto the top of the stack. If argument bFree is true, then this
143658 ** then this routine return NULL.
143661 ** calling this routine, Instead, use only the return value.
143738 /* If pCte->zCteErr is non-NULL at this point, then this is an illegal
143740 ** early. If pCte->zCteErr is NULL, then this is not a recursive reference.
143741 ** In this case, proceed. */
143783 /* Check if this is a recursive CTE. */
144161 Table *pTab = pFrom->pTab; /* Table for this data source */
144163 char *zTabName; /* AS name for this data source */
144164 const char *zSchemaName = 0; /* Schema name for this data source */
144165 int iDb; /* Schema index for this data src */
144415 ** Use this routine after name resolution.
144566 /* If this is the first row of the group (regAcc contains 0), clear the
144569 ** invocation of min() or max() altogether. Or, if this is not
144660 ** Otherwise, return WRC_Prune. In this case, also check if the
144673 ** clause in this obscure case, as doing so may corrupt the outer Select
144730 SrcList *pTabList, /* Search for self-joins in this FROM clause */
144731 SrcItem *pThis /* Search for prior reference to this subquery */
144776 ** Into this:
144817 /* If we reach this point then it is OK to perform the transformation */
144910 int rc = 1; /* Value to return from this function */
144975 /* If the SF_UFSrcCheck flag is set, then this function is being called
144977 ** In this case, it is an error if the target object (pSrc->a[0]) name
144980 ** Postgres disallows this case too. The reason is that some other
144981 ** systems handle this case differently, and not all the same way,
144982 ** which is just confusing. To avoid this, we follow PG's lead and
144995 ** and leaving this flag set can cause errors if a compound sub-query
144996 ** in p->pSrc is flattened into this query and this function called
145051 /* No futher action if this term of the FROM clause is no a subquery */
145111 ** restriction allows SQL constructs like this:
145164 /* Do the WHERE-clause constant propagation optimization if this is
145165 ** a join. No need to speed time on this operation for non-join queries
145237 ** tree referred to by this, the parent select. The child select
145316 ** this same FROM clause. Reuse it. */
145384 ** if the select-list is the same as the ORDER BY list, then this query
145385 ** can be rewritten as a GROUP BY. In other words, this:
145422 ** do the sorting. But this sorting ephemeral index might end up
145571 int addrEnd; /* End of processing for this SELECT */
145846 ** disable this optimization for testing purposes. */
145879 ** block. If there were no changes, this block is skipped.
145926 ** the processing calls for the query to abort, this subroutine
146030 ** The code generated by updateAccumulator() uses this to ensure
146062 /* If this query is a candidate for the min/max optimization, then
146118 /* Jump here to skip this query
146165 ** The author disclaims copyright to this source code. In place of
146210 ** we need to remember from this invocation of the callback.
146225 /* If this is the first row, then generate an extra row containing
146273 ** from malloc(). But the caller cannot free this memory directly.
146365 ** The author disclaims copyright to this source code. In place of
146471 IdList *pColumns, /* column list if this is an UPDATE OF trigger */
146508 /* A long-standing parser bug is that this syntax was allowed:
146716 /* If this is a new CREATE TABLE statement, and if shadow tables
146788 ** The parser calls this routine when it finds a SELECT statement in
146845 ** The parser calls this routine when it sees an INSERT inside the
146890 ** a pointer to that trigger step. The parser calls this routine when it
146930 ** a pointer to that trigger step. The parser calls this routine when it
146975 ** same job as this routine except it takes a pointer to the trigger
147405 /* Figure out the ON CONFLICT policy that will be used for this step
147406 ** of the trigger program. If the statement that caused this trigger
147637 /* It may be that this trigger has already been coded (or is in the
147638 ** process of being coded). If this is the case, then an entry with
147657 ** table pTab. The reg, orconf and ignoreJump parameters passed to this
147685 ** recursive invocation of this trigger program is disallowed. Recursive
147701 ** operation on pTab, this function is a no-op.
147724 ** ON INSERT trigger, the value passed to this function as parameter reg
147760 /* Determine whether we should code this trigger. One of two choices:
147844 ** The author disclaims copyright to this source code. In place of
147990 ** Assuming both the pLimit and pOrderBy parameters are NULL, this function
147997 ** this function, they must be deleted by the caller.
148013 ** PRIMARY KEY. In this case <other-columns> are the primary key columns
148232 ** clause if this function is being called to generate code for part of
148308 /* If this is an UPDATE with a FROM clause, do not resolve expressions
148399 ** So reset the colUsed mask. Unless this is a virtual table. In that
148500 /* Jump to labelBreak to abandon further processing of this UPDATE */
148556 /* If this is an UPSERT, then all cursors have already been opened by
148762 ** this UPDATE statement and (b) not accessed by new.* references. The
148789 ** if there are one or more BEFORE triggers that use this value via
148810 ** verified. One could argue that this is wrong.
148818 /* The row-trigger may have deleted the row being updated. In this
148836 ** in case this has happened. Only unmodified columns are reloaded.
148993 ** they may interfere with compilation of other functions in this file
148994 ** (or in another file, if this file becomes part of the amalgamation). */
149017 ** Then loop through the contents of this ephemeral table executing a
149195 ** The author disclaims copyright to this source code. In place of
149440 ** In this case parameter iCur is a cursor open on the table b-tree that
149514 ** The author disclaims copyright to this source code. In place of
149524 ** Most of the code in this file may be omitted by defining the
149716 ** can be set to 'off' for this file, as it is not recovered if a crash
149846 /* At this point, there is a write transaction open on both the
149848 ** both transactions are closed by this block - the main database
149875 /* GetMeta() and UpdateMeta() cannot fail in this context because
149940 ** The author disclaims copyright to this source code. In place of
149956 ** this struct allocated on the stack. It is used by the implementation of
149968 ** Construct and install a Module object for a virtual table. When this
149977 const char *zName, /* Name assigned to this module */
150025 const char *zName, /* Name assigned to this module */
150046 const char *zName, /* Name assigned to this module */
150061 const char *zName, /* Name assigned to this module */
150126 ** this virtual-table, if one has been created, or NULL otherwise.
150176 ** this makes it safe to access the sqlite3.pDisconnect list of any
150234 ** 1) By this function. In this case, all BtShared mutexes and the mutex
150238 ** the sqlite3.pDisconnect list. In this case either the BtShared mutex
150318 ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
150381 ** The parser calls this routine after the CREATE VIRTUAL TABLE statement
150420 ** entry in the sqlite_schema table tht was created for this vtab
150464 ** The parser calls this routine when it sees the first token
150474 ** The parser calls this routine for each token after the first token
150491 ** to this procedure.
150700 ** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.
150740 ** valid to call this function from within the xCreate() or xConnect() of a
150768 /* We should never be able to reach this point while loading the
150958 ** than zero, then this function is being called from within a
150960 ** virtual module tables in this case, so return SQLITE_LOCKED.
151009 ** processing is abandoned and the error returned to the caller of this
151050 ** second parameter (pExpr) is the first argument to this function.
151089 ** to see if the implementation wants to overload this function.
151092 ** with an all lower-case function name. Continue in this tradition to
151128 ** array if it is missing. If pTab is already in the array, this routine
151154 ** exists when this routine returns or if an attempt to create it failed
151219 ** The results of this routine are undefined unless it is called from
151288 ** The author disclaims copyright to this source code. In place of
151310 ** The author disclaims copyright to this source code. In place of
151368 ** Contrast this object with WhereLoop. This object describes the
151373 ** The WhereInfo object contains a single instance of this object for
151388 int addrBody; /* Beginning of the body of this loop */
151404 int iCur; /* The VDBE cursor used by this IN operator */
151414 Bitmask notReady; /* FROM entries not usable at this level */
151421 ** Each instance of this object represents an algorithm for evaluating one
151438 char cId; /* Symbolic ID of this loop for debugging use */
151440 u8 iTab; /* Position in FROM clause of table for this loop */
151480 LogEst rRun; /* Cost of running this subquery */
151481 LogEst nOut; /* Number of outputs for this subquery */
151495 ** Each instance of this object holds a sequence of WhereLoop objects
151513 Bitmask maskLoop; /* Bitmask of all WhereLoop objects in this path */
151515 LogEst nRow; /* Estimated number of rows generated by this path */
151516 LogEst rCost; /* Total cost of this path */
151517 LogEst rUnsorted; /* Total cost of this path ignoring sorting costs */
151519 WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */
151523 ** The query generator uses an array of instances of this structure to
151548 ** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR
151574 Expr *pExpr; /* Pointer to the subexpression that is this term */
151575 WhereClause *pWC; /* The clause this term is part of */
151576 LogEst truthProb; /* Probability of truth for this expression */
151581 int iParent; /* Disable pWC->a[iParent] when this term disabled */
151607 #define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
151627 Expr *pIdxExpr; /* Search for this index expression */
151628 int k; /* Resume scanning at this->pWC->a[this->k] */
151630 char idxaff; /* Must match this affinity, if zCollName!=NULL */
151639 ** WHERE clause. Mostly this is a container for one or more WhereTerms.
151702 ** above, the mapping might go like this: 4->3, 5->1, 8->2, 29->0,
151719 WhereInfo *pWInfo; /* Information about this WHERE */
151740 ** particular query. If this parameter is unlimited, then certain
151762 ** this structure is returned by the first half and passed
151765 ** An instance of this object holds the complete state of the query
151795 WhereMemBlock *pMemToFree;/* Memory to free when this object destroyed */
151817 Bitmask notReady, /* RHS must not overlap with this mask */
151819 Index *pIdx /* Must be compatible with this index, if not NULL */
151828 SrcList *pTabList, /* Table list this loop refers to */
151835 const WhereLevel *pLevel /* Bloom filter on this level */
152008 ** is run and there is an index on (a, b), then this function returns a
152049 SrcList *pTabList, /* Table list this loop refers to */
152063 u32 flags; /* Flags that describe this loop */
152157 ** required and this routine is a no-op.
152165 const WhereLevel *pLevel /* Bloom filter on this level */
152257 ** automatically disabled. In this way, terms get disabled if derived
152311 ** to modify zAff after this routine returns.
152438 ** of the subroutines do not handle this case. */
152477 ** this is only guaranteed for TK_ISNULL and TK_IN constraints. If the
152483 ** this routine sets up a loop that will iterate over all values of X.
152489 int iEq, /* Index of the equality term within this level */
152491 int iTarget /* Attempt to leave results in this register */
152648 ** Suppose the WHERE clause is this: a==5 AND b IN (1,2,3) AND c>5 AND c<10
152649 ** The index has as many as three equality constraints, but in this
152655 ** In the example above nEq==2. But this subroutine works for any value
152656 ** of nEq including 0. If nEq==0, this routine is nearly a no-op.
152667 ** calls this routine will use that memory range to store keys for
152670 ** this routine allocates an additional nEq memory cells for internal
152686 ** string in this example would be set to SQLITE_AFF_BLOB.
152698 Index *pIdx; /* The index being used for this loop */
152804 ** expression: "x>='ABC' AND x<'abd'". But this requires that the range
152811 ** only the one pass through the string space is required, so this routine
152837 ** the expression tree (by sqlite3WalkExpr()) using an instance of this
152929 /* An aggregate function in the WHERE clause of a query means this must
152931 ** the parent context. Do not walk the function arguments in this case.
152933 ** todo: It should be possible to replace this node with a TK_REGISTER
152935 ** register at this point. The same holds for TK_AGG_COLUMN nodes. */
152948 WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */
152981 ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms
152989 ** pushed down to the cursor, this row is filtered out, causing
153033 /* If we survive all prior tests, that means this term is worth hinting */
153054 ** Normally, this is just:
153064 ** enable this optimization, the P3 of OP_DeferredSeek is set to iIdxCur
153069 ** to 0. The OP_Column opcode can check this array to see if the column it
153115 ** this case, generate code to evaluate the expression and leave the
153202 ** vvvvv--' pLevel->regFilter if this were true. */
153262 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
153304 /* If this is the right table of a LEFT OUTER JOIN, allocate and
153305 ** initialize a memory cell that records if this table matches any
153318 ** this loop is empty and can never contribute content. */
153742 ** point to a valid row for the first iteration of this loop. */
154023 ** The top of the loop looks like this:
154078 ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
154106 ** over the top of the loop into the body of it. In this case the
154172 ** op==TK_AND comparison inside of sqlite3PExpr() false, and this
154241 /* Check if the temp table already contains this key. If so,
154275 /* The pSubWInfo->untestedTerms flag means that this OR term
154284 ** by each call to sqlite3WhereBegin() made by this loop, it may
154288 ** uses an index, and this is either the first OR-connected term
154331 ** loop to point to this spot, which is the top of the next containing
154333 ** indent everything in between the this point and the final OP_Return.
154428 ** can skip the call to the like(A,B) function. But this only works
154562 ** loop will run that invokes this subroutine for unmatched rows
154701 ** The author disclaims copyright to this source code. In place of
154750 ** This is true even if this routine fails to allocate a new WhereTerm.
154754 ** calling this routine. Such pointers may be reinitialized by referencing
154871 Expr *pExpr, /* Test this expression */
154955 ** Getting this right has been a persistent source of bugs in the
155050 Expr *pExpr, /* Test this expression */
155103 ** names. But for this use case, xFindFunction is expected to deal
155230 /* If we reach this point, it means the two subterms can be combined */
155283 ** then create a new virtual term like this:
155410 /* Skip this term for now. We revisit it when we process the
155494 ** current term is from the first iteration. So skip this term. */
155502 ** or follwed by an inverted copy (t2.b==t1.a). Skip this term
155554 /* At this point, okToChngToIN is true if original pTerm satisfies
155605 ** If this routine returns TRUE, that means that the RHS can be substituted
155668 ** If pExpr is a TK_COLUMN column reference, then this routine always returns
155704 /* If this expression is a vector to the left or right of a
155728 ** The input to this routine is an WhereTerm structure with only the
155729 ** "pExpr" field filled in. The job of this routine is to analyze the
156052 ** inequality. To avoid this, make sure to also run the full
156217 ** The original WHERE clause in pExpr is unaltered. All this routine
156249 WhereClause *pWC, /* Add the constraint to this WHERE clause */
156425 ** the more complex analysis done by this routine. Hence, the
156426 ** computations done by this routine are broken out into a separate
156554 ** The author disclaims copyright to this source code. In place of
156566 ** so is applicable. Because this module is responsible for selecting
156567 ** indices, you might also think of this module as the "query optimizer".
156604 ** Return one of the WHERE_DISTINCT_xxxxx values to indicate how this
156633 ** label returned by this function.
156640 ** It is always safe for this routine to return the continuation of the
156708 ** If the ONEPASS optimization is used (if this routine returns true)
156979 ** form X=Y then this routine might also return terms of the form
156992 Index *pIdx /* Must be compatible with this index */
157054 Bitmask notReady, /* RHS must not overlap with this mask */
157056 Index *pIdx /* Must be compatible with this index, if not NULL */
157149 ** this query, then it will not be possible to show that the DISTINCT
157156 ** true. Note: The (p->iTable==iBase) part of this test may be false if the
157219 int iStart, /* Translate from this opcode to the end */
157220 int iTabCur, /* OP_Column/OP_Rowid references to this table */
157221 int iRegister, /* The first column is in this register */
157472 /* Construct the Index object to describe this index */
157590 ** this recursive initialization if the SQLITE_BloomPulldown optimization has
157607 WhereLevel *pLevel, /* Make a Bloom filter for this FROM term */
157715 ** by passing the pointer returned by this function to freeIndexInfo().
157744 /* Find all WHERE clause constraints referring to this virtual table.
157872 ** following asserts verify this fact. */
157929 ** The table object reference passed as the second argument to this function
157932 ** comes in as the 3rd argument to this function.
157942 ** that this is required.
157978 ** is greater than or equal to pRec. Note that this index is not an index
158025 ** the code actually searches this set:
158048 ** it is extended to two fields. The duplicates that this creates do not
158134 /* At this point, the (iCol+1) field prefix of aSample[i] is the first
158170 ** If the user explicitly specified a likelihood() value for this term,
158172 ** input rows. Otherwise, this function assumes that an "IS NOT NULL" term
158214 ** on the stat4 data for the index. this scan will be peformed multiple
158218 ** It does this by scanning through all stat4 samples, comparing values
158231 ** Normally, this function sets *pbDone to 1 before returning. However,
158243 WhereLoop *pLoop, /* Update the .nOut value of this loop */
158290 ** using the method described in the header comment for this function. */
158340 ** When this function is called, *pnOut is set to the sqlite3LogEst() of the
158408 /* Note: this call could be optimized away - since the same values must
158552 ** of this one, no estimate can be made. Return SQLITE_NOTFOUND. */
158869 const WhereLoop *pY /* Compare against this WhereLoop */
158966 ** rSetup. Call this SETUP-INVARIANT */
159089 /* If we reach this point it means that either p[] should be overwritten
159155 ** TODO --> Perhaps this is something that could be improved by better
159159 ** value corresponds to -1 in LogEst notation, so this means decrement
159257 ** then this function would be invoked with nEq=1. The value returned in
159258 ** this case is 3.
159326 ** When this function is called, pBuilder->pNew->nOut contains the
159328 ** terms only. If it is modified, this value is restored before this
159449 ** In this case there is a separate term for each of (x) and (y).
159479 ** the index. Do not bother with this optimization on very small
159559 /* At this point pNew->nOut is set to the number of rows expected to
159642 ** seek only. Then, if this is a non-covering index, add the cost of
159819 ** If this node does not disprove that the index can be a covering index,
159873 ** colMask that columns greater than 62 are used, so this is not a
159893 ** The costs (WhereLoop.rRun) of the b-tree loops added by this function
159917 ** of uncertainty. For this reason, scoring is designed to pick plans that
159926 Bitmask mPrereq /* Extra prerequesites for using this table */
159959 ** variable sPk to represent the rowid primary key index. Make this
160028 ** not be unreasonable to make this value much larger. */
160049 continue; /* Partial index inappropriate for this query */
160131 /* If this is a non-covering index scan, add in the cost of
160499 ** schemas. But if this is a write operation, start writes on all
160547 Bitmask mPrereq, /* Tables that must be scanned before this one */
160548 Bitmask mUnusable /* Tables that must be scanned after this one */
160607 ** xBestIndex again, this time with IN(...) terms disabled. */
160784 ** this does not happen. Otherwise, for WHERE clauses such as the
160910 WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */
161073 ** check that it is the only column used by this loop. Otherwise,
161088 ** than WO_IN is captured by the previous "if". So this one
161113 /* An unconstrained column that might be NULL means that this
161236 ** Normally, in this case it is not possible for the caller to determine
161240 ** this function may be called on the returned WhereInfo object. It returns
161302 ** Use the LIMIT for M if it is smaller. Or if this sort is for
161318 ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
161347 char *pSpace; /* Temporary memory used by this routine */
161359 /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this
161360 ** case the purpose of this call is to estimate the number of rows returned
161361 ** by the overall query. Once this estimate has been obtained, the caller
161362 ** will invoke this function a second time, passing the estimate as the
161405 ** in this case the query may return a maximum of one row, the results
161407 ** indicate this. Or, if nLoop is greater than zero, set isOrdered to
161430 /* Do not use an automatic index if the this loop is expected
161438 /* At this point, pWLoop is a candidate to be the next loop.
161507 ** this candidate as not viable. */
161517 /* If we reach this points it means that the new candidate path
161724 ** Return non-zero on success, if this query can be handled by this
161725 ** no-frills query planner. Return zero if this query needs the
162087 ** should invoke sqlite3WhereEnd() with the return value of this function
162090 ** If an error occurs, this routine returns NULL.
162095 ** example, if the SQL is this:
162129 ** code will run much faster. Most of the work of this routine is checking
162160 ** if there is one. If there is no ORDER BY clause or if this routine
162165 ** to use for OR clause processing. The WHERE clause should use this
162184 WhereInfo *pWInfo; /* Will become the return value of this function */
162334 ** Do not do this if the expression contains non-deterministic functions
162498 ** to use a one-pass algorithm, determine if this is appropriate.
162513 ** use a one-pass approach, and this is not set accurately for scans
163002 /* If this scan uses an index, make VDBE code substitutions to read data
163004 ** this optimization prevents the table from ever being read, which can
163080 ** reference. Verify that this is harmless - that the
163130 ** The author disclaims copyright to this source code. In place of
163164 ** The flattening optimization is disabled when processing this transformed
163166 ** (in this case max()) to process rows sorted in order of (c, d), which
163225 ** This detail is encapsulated within this file, the code generated by
163692 ** let the test coverage routine know not to expect this function to be
163783 ** of this file), pWin is updated here.
163787 Window *pList, /* List of named windows for this SELECT */
163871 ** this function appends to the output expression-list and updates
163880 /* If this function is being called from within a scalar sub-select
163987 ExprList *pEList, /* Rewrite expressions in this list */
164078 ** any SQL window functions, this function is a no-op. Otherwise, it
164081 ** at the top of this file.
164127 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
164187 ** keep everything legal in this case.
164455 ** in if either (a) there are no other windows already linked to this
164646 ** with the object passed as the only argument to this function.
164667 ** A single instance of this structure is allocated on the stack by
164680 ** that it processes in a temporary table. If it is not zero, this
164718 ** be required. In this case both WindowCodeArg.csr and reg are set to
164725 int addrGosub; /* OP_Gosub to this address to return one row */
164767 ** enough to hold the array of arguments for each function. In this case
164780 int csr, /* Read arguments from this cursor */
165030 ** OP_Gosub instruction is all that this routine generates. Extra VM code
165261 ** the usual smaller. The VDBE opcodes OP_Ge and so on do not handle this
165276 ** not taken, control jumps over the comparison operator coded below this
165307 ** then leave reg1 as it is. In pseudo-code, this is implemented as:
165316 ** NULL is always NULL anyway, this case is handled as required too. */
165327 ** control skips over this test if the BIGNULL flag is set and either
165347 ** Helper function for sqlite3WindowCodeStep(). Each call to this function
165406 /* If this is a (RANGE BETWEEN a FOLLOWING AND b FOLLOWING) or
165553 ** If an OOM error occurs, this function sets the Parse.db.mallocFailed
165570 ** passed as the second argument when this function is invoked. It generates
165598 ** // First time this branch is taken, the eph table contains two
165747 ** when (expr1 < expr2). This is detected at runtime, not by this function.
165748 ** To handle this case, the pseudo-code programs depicted above are modified
166006 /* If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of
166028 ** at regNew. If the window has a PARTITION clause, this block generates
166238 ** The author disclaims copyright to this source code. In place of
166248 ** The canonical source code to this file ("parse.y") is a Lemon grammar
166252 ** this comment as part of the translated C-code. Edits should be made
166657 ** YYFALLBACK If defined, this indicates that one or more tokens
166811 ** The following are the tables generated in this section:
167645 ** + The state number for the parser at this level of the stack.
167647 ** + The value of the token stored at this level of the stack.
167650 ** + The semantic value stored at this level of the stack. This is
167661 ** number for the token at this stack level */
168747 ** systems, every element of this matrix should end up being set.
169789 ** if the lookahead token has already been consumed. As this procedure is
170577 ** that look like this: #1 #2 ... These terms refer to registers
171491 unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
171617 ** Applications can set this macro (for example inside %include) if
171682 ** The author disclaims copyright to this source code. In place of
171782 ** lower-case ASCII equivalent. On ASCII machines, this is just
171785 ** which are the only characters for which this feature is used.
171820 ** The implementation of this routine was generated by a program,
171823 ** named keywordhash.h and then included into this source file by
171830 ** The code in this file has been automatically generated by
171834 ** The code in this file implements a function that determines whether
171837 ** But by using this automatically generated code, the size of the code
172592 /* If the next character is a digit, this is a floating point
172675 ** but z[i] is a character not allowed within keywords, so this must
173024 ** The author disclaims copyright to this source code. In place of
173145 /* If triggers are not supported by this compile then the statement machine
173317 ** The author disclaims copyright to this source code. In place of
173325 ** Main file for the SQLite library. The routines in this file
173338 ** The author disclaims copyright to this source code. In place of
173371 ** The author disclaims copyright to this source code. In place of
173408 ** The author disclaims copyright to this source code. In place of
173538 ** this variable being set to non-zero will cause OSTRACE macros to emit
173552 ** I/O active are written using this function. These messages
173582 ** this routine will be called automatically by key routines such as
173588 ** The first thread to call this routine runs the initialization to
173589 ** completion. If subsequent threads call this routine before the first
173593 ** The first thread might call this routine recursively. Recursive
173594 ** calls to this routine should not block, of course. Otherwise the
173597 ** Let X be the first thread to enter this routine. Let Y be some other
173598 ** thread. Then while the initial invocation of this routine by X is
173601 ** * Calls to this routine from Y must block until the outer-most
173604 ** * Recursive calls to this routine from thread X return immediately
173626 /* If SQLite is already completely initialized, then this call
173629 ** of this routine.
173650 ** malloc subsystem - this implies that the allocation of a static
173674 /* If rc is not SQLITE_OK at this point, then either the malloc
173743 ** been compiled correctly. It is important to run this code, but
173778 ** routine is not threadsafe. But it is safe to invoke this routine
173780 ** when this routine is invoked, then this routine is a harmless no-op.
173813 ** this function resulted in the heap subsystem actually being shutdown.
174078 /* EVIDENCE-OF: R-53367-43190 If either argument to this option is
174164 /* Free any existing lookaside buffer for this handle before
174566 ** if this is not the last copy of the function, do not invoke it. Multiple
174652 ** call will do so. We need to do this before the check for active
174746 /* If we reach this point, it means that the database connection has
175136 ** If this routine returns non-zero, the lock is retried. If it
175284 /* If SQLITE_UTF16 is specified as the encoding type, transform this
175504 ** SQL function that use this routine so that the functions will exist
175526 ** this routine is a no-op. If the function does not exist, then create
175530 ** should call this routine to make sure the global function exists.
175589 sqlite3 *db, /* Trace this connection */
175649 sqlite3 *db, /* Attach the hook to this database */
175671 ** inserted or deleted using this database connection.
175674 sqlite3 *db, /* Attach the hook to this database */
175696 ** back by this database connection.
175699 sqlite3 *db, /* Attach the hook to this database */
175722 ** inserted or deleted using this database connection.
175725 sqlite3 *db, /* Attach the hook to this database */
175745 sqlite3 *db, /* Attach the hook to this database */
175796 ** The callback registered by this function replaces any existing callback
175799 ** configured by this function.
175820 ** into the write-ahead-log by this database connection.
175823 sqlite3 *db, /* Attach the hook to this db handle */
175896 /* If there are no active statements, clear the interrupt flag at this
175924 ** If a transaction is open on the database being checkpointed, this
175931 ** this function while the checkpoint is running.
175973 ** and this functions return value.
176075 ** above. If this is the case, then the db->mallocFailed flag needs to
176076 ** be cleared before returning. Do this directly, instead of via
176088 ** passed to this function, we assume a malloc() failed during sqlite3_open().
176114 ** argument. For now, this simply calls the internal sqlite3ErrStr()
176138 /* If SQLITE_UTF16 is specified as the encoding type, transform this
176152 /* Check if this call is removing or replacing an existing collation
176316 ** The first argument to this function is the name of the VFS to use (or
176319 ** itself. When this function is called the *pFlags variable should contain
176324 ** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to
176335 ** this buffer by calling sqlite3_free().
176405 ** Within this loop, variable eState may be set to 0, 1 or 2, depending
176425 /* This branch is taken when "%00" appears within the URI. In this
176447 /* An empty option name. Ignore this option altogether. */
177158 ** malloc() failure, but SQLite now does this automatically.
177231 ** data for this thread has been deallocated.
177233 ** SQLite no longer uses thread-specific data so this routine is now a
177311 ** and autoinc. At this point there are two possibilities:
177338 ** this has the effect of zeroing all output parameters.
177464 ** this verb acts like PRNG_RESET.
177566 ** as it existing before this routine was called.
177642 ** The run-time test procedure might look something like this:
177755 ** By default this is 0x7ffffffe (over 2 billion), but that value is
177756 ** too big to test in a reasonable amount of time, so this control is
178023 ** error to call this routine with any parameter other than a pointer
178041 ** parameter if it exists. If the parameter does not exist, this routine
178093 ** It is an error to pass this routine a filename string that was not
178371 ** The author disclaims copyright to this source code. In place of
178386 /* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */
178402 ** Head of a linked list of all sqlite3 objects created by this process
178448 ** db is not currently a part of the list, this function is a no-op.
178503 ** before this routine returns.
178511 ** Each call to this routine overrides any prior callbacks registered
178706 ** The author disclaims copyright to this source code. In place of
178719 ** The code in this file is only compiled if:
178772 ** A doclist is stored like this:
178786 ** varint POS_END; (marks end of positions for this document.
178801 ** The 123 value is the first docid. For column zero in this document
178859 ** that this might extend through 2x or 4x the pagesize.
178947 ** leaf nodes are written in to the %_segments table in order, this
178998 ** The author disclaims copyright to this source code. In place of
179044 ** The author disclaims copyright to this source code.
179063 /* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.
179114 ** this callback. The caller will do so.
179123 ** Destroy an existing tokenizer. The fts3 module calls this method
179140 ** Destroy an existing tokenizer cursor. The fts3 module calls this
179154 ** of this buffer in bytes. The input text that generated the token is
179174 int *piPosition /* OUT: Number of tokens returned before this one */
179178 ** Methods below this point are only available if iVersion>=1.
179188 const sqlite3_tokenizer_module *pModule; /* The module for this tokenizer */
179193 sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */
179210 ** The author disclaims copyright to this source code. In place of
179231 ** The internals of this structure are intended to be opaque -- client
179232 ** code should not attempt to access or modify the fields of this structure
179233 ** directly. Change this structure only by using the routines below.
179235 ** accessing this structure are really macros, so we can't really make
179236 ** this structure opaque.
179241 int count; /* Number of entries in this table */
179245 int count; /* Number of entries with this hash */
179246 Fts3HashElem *chain; /* Pointer to first entry with this hash */
179253 ** Again, this structure is intended to be opaque, but it can't really
179258 void *data; /* Data associated with this element */
179259 void *pKey; int nKey; /* Key associated with this element */
179297 ** like this:
179347 ** However if this limit is reached midway through a transaction, a new
179381 ** value stored in the "%_segdir.level" column. Given this value L, the index
179387 ** theory though this may happen, but only after at least
179506 ** of this structure and xDestroy and xDisconnect free that instance.
179522 u32 nLeafAdd; /* Number of leaf blocks added this trans */
179564 Fts3Hash hPending; /* Pending terms table for this index */
179685 /* Variables above this point are populated when the expression is
179686 ** parsed (by code in fts3_expr.c). Below this point the variables are
179688 Fts3DeferredToken *pDeferred; /* Deferred token object for this token */
179689 Fts3MultiSegReader *pSegcsr; /* Segment-reader for this token */
179693 /* Cache of doclist for this phrase. */
179698 /* Used by sqlite3Fts3EvalPhrasePoslist() if this is a descendent of an
179703 /* Variables below this point are populated by fts3_expr.c when parsing
179707 int iColumn; /* Index of column this phrase must match */
179716 ** of this phrase query in FTS3 doclist format. As usual, the initial
179717 ** "Length" field found in doclists stored on disk is omitted from this
179735 Fts3Expr *pParent; /* pParent->pLeft==this or pParent->pRight==this */
179742 u8 bEof; /* True this expression is at EOF already */
179744 u8 bDeferred; /* True if this expression is entirely deferred */
179747 int iPhrase; /* Index of this phrase in matchinfo() results */
179838 int iColFilter; /* If >=0, filter for this column */
179955 int nRef; /* Number of pointers to this object */
180094 ** input does not begin with a quote character, then this routine
180141 ** When this function is called, *pp points to the first byte following a
180212 ** If *pRc is initially non-zero then this routine is a no-op.
180270 ** If *pRc is non-zero when this function is called, it is a no-op.
180325 ** If the p->bHasDocsize boolean is true (indicating that this is an
180390 ** If *pRc is non-zero when this function is called, it is a no-op.
180483 ** is the callers responsibility to call sqlite3_free() to release this
180523 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and
180525 ** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If
180580 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and
180582 ** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If
180609 ** Decode this value and store it in *pnOut, returning the number of bytes
180672 struct Fts3Index **apIndex /* OUT: Array of indexes for this table */
180718 ** The third argument passed to this function is the value passed to the
180731 ** is the responsibility of the caller to free this allocation
180835 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
180838 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
180889 /* Check if this is a tokenizer specification */
181144 /* If this is an xCreate call, create the underlying tables in the
181219 ** Set the pIdxInfo->estimatedRows variable to nRow. Unless this
181221 ** support estimatedRows. In that case this function is a no-op.
181232 ** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this
181234 ** support index-info flags. In that case this function is a no-op.
181273 int bDocid; /* True if this constraint is on docid */
181278 ** the planner does elect to use the results of this call as part
181281 ** this, return a very high cost here. */
181515 ** a b-tree for a term or term prefix. The node data is passed to this
181519 ** If piFirst is not NULL, then this function sets *piFirst to the blockid
181549 ** Even if the data structure on disk is corrupted, this (reading two
181552 ** not make this guarantee explicitly, but in practice there are always
181649 ** range. Because this function only inspects interior segment nodes (and
181664 int iHeight; /* Height of this node in tree */
181706 ** varints. Each call to this function appends a single varint to a list.
181711 sqlite3_int64 iVal /* Write this value to the list */
181719 ** When this function is called, *ppPoslist is assumed to point to the
181724 ** a single document record of a doclist. So, in other words, this
181730 ** before this function returns.
181763 ** When this function is called, *ppPoslist is assumed to point to the
181776 ** before this function returns. The POS_COLUMN or POS_END terminator
181808 ** This function is used to help parse position-lists. When this function is
181819 ** Before calling this routine *pi must be initialized to the value of
181901 /* At this point, both p1 and p2 point to the start of column-lists
181951 ** Then the position list for this row for token 'b' would consist of:
181955 ** When this function returns, both *pp1 and *pp2 are left pointing to the
182124 ** An instance of this function is used to merge together the (potentially
182136 ** pEnd points 1 byte past the end of the buffer. When this function is
182138 ** has been reached. In this case *pp is set to 0 and the function returns.
182144 ** If it is true, the value read is subtracted from *pVal before this
182171 ** If *pbFirst is zero when this function is called, the value written to
182174 ** If *pbFirst is non-zero when this function is called, then the value
182178 ** Before returning, this function always sets *pbFirst to 1 and *piPrev
182186 sqlite3_int64 iVal /* Write this value to the list */
182207 ** bDescDoclist is 0 when this macro is invoked, then it returns (i1-i2).
182210 ** Using this makes it easier to write code that can merge doclists that are
182224 ** containing the output doclist and SQLITE_OK is returned. In this case
182228 ** are undefined in this case.
182330 ** The right-hand input doclist is overwritten by this function.
182451 ** If an OOM error occurs, return SQLITE_NOMEM. In this case it is
182516 /* If this is the first term selected, copy the doclist to the output
182522 ** doclists are stored in order=ASC order, this padding would not be
182524 ** than or equal to the size of [doclistA] in that case). But this is
182622 /* If iLevel is less than 0 and this is not a scan, include a seg-reader
182623 ** for the pending-terms. If this is a scan, then this call must be being
182624 ** made by an fts4aux module, not an FTS table. In this case calling
182651 /* If zTerm is not NULL, and this segment is not stored entirely on its
182652 ** root node, the range of leaves scanned can be reduced. Do this. */
182732 ** It is the responsibility of the caller to free this object by eventually
182812 Fts3MultiSegReader *pSegcsr; /* Seg-reader cursor for this term */
182878 ** matches the search criteria. For a MATCH search, this will be
182879 ** the next row that matches. For a full-table scan, this will be
182881 ** this routine simply sets the EOF flag.
182940 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
183018 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
183057 ** This is the xEof method of the virtual table. SQLite calls this
183070 ** This is the xRowid method. The SQLite core calls this routine to
183128 /* A user column. Or, if this is a full-table scan, possibly the
183170 ** merge is somewhere between 8 and 24 blocks. To avoid this overhead
183176 ** of blocks from the segments table. But this is not considered overhead
183207 ** table (if p->bHasStat==2), attempt to determine this (set p->bHasStat
183297 /* At this point p points to that preceding byte without the 0x80 bit
183302 ** is the first in the doclist. In this case do not skip forward 2 bytes.
183359 /* There must be at least one argument passed to this function (otherwise
183360 ** the non-overloaded version would have been called instead of this one).
183518 /* At this point it must be known if the %_stat table exists or not.
183611 ** by this module.
183685 ** Initialize the fts3 extension. If this extension is built as part
183686 ** of the sqlite library, then this function is called directly by
183687 ** SQLite. If fts3 is built as a dynamically loadable extension, this
183751 ** the four scalar functions. If this is successful, register the
183806 Fts3Expr *pExpr, /* Allocate readers for this expression */
183941 ** instances of the phrase (after considering deferred tokens). If this
184053 ** expression to initialize the mechanism for returning rows. Once this
184059 ** memory within this call.
184112 ** through doclists. It is used by this module to iterate through phrase
184117 ** descending (parameter bDescIdx==1) order of docid. Regardless, this
184229 /* We have already reached the end of this doclist. EOF. */
184244 ** list for document pDL->iDocid. However, if this position-list was
184247 ** with this case by advancing pIter past the zero-padding added by
184455 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
184466 ** If an error occurs within this function, *pRc is set to an SQLite error
184518 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
184567 ** write this value to *pnPage and return SQLITE_OK. Otherwise, return
184573 ** this database, then the average docsize is 1. Otherwise, it is 1 plus
184625 ** deferred. The array aTC[] has already been populated when this is
184639 Fts3Expr *pRoot, /* Consider tokens with this root node */
184655 ** table actually contains the same data as the index. To prevent this from
184662 /* Count the tokens in this AND/NEAR cluster. If none of the doclists
184664 ** only 1 token, exit early. No tokens to defer in this case. */
184678 /* Iterate through all tokens in this AND/NEAR cluster, in ascending order
184684 ** first iteration of this loop), or
184715 /* The number of overflow pages to load for this (and therefore all
184730 /* Either this is the cheapest token in the entire query, or it is
184836 ** the example above). When this function is called, *paPoslist points to
184843 ** close to a position in the *paPoslist position list are removed. If this
184905 ** It says above that this function advances the expression to the next
184910 ** the db. In this case the position-list is not populated at all.
184917 ** where "*" may match any single token. The position list in this case
185056 ** cluster, then this function returns 1 immediately.
185065 ** constraints. In this case it returns 1. If the NEAR expression does not
185090 ** no exceptions to this - it's the way the parser in fts3_expr.c works.
185146 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
185147 ** If an error occurs during execution of this function, *pRc is set to
185148 ** the appropriate SQLite error code. In this case the returned value is
185171 ** For example if this expression:
185242 ** iterating through the results of a full-text query. At this point the
185246 ** * Up until this point, "NEAR" operators in the expression have been
185251 ** If *pRc is not SQLITE_OK when this function is called, it immediately
185256 ** 1. *pRc is SQLITE_OK when this function returns, and
185271 ** token. Then, see if this row is really a match, considering deferred
185329 ** loading or merging of phrase doclists for this iteration.
185331 ** If *pRc is other than SQLITE_OK when this function is called, it is
185332 ** a no-op. If an error occurs within this function, *pRc is set to an
185373 ** by pExpr, calling this function for each row. This function increments
185412 ** If it is not already allocated and populated, this function allocates and
185486 ** order. For this reason, even though it seems more defensive, the
185562 ** The expression pExpr passed as the second argument to this function
185592 /* If this phrase is applies specifically to some column other than
185611 /* Check if this phrase descends from an OR expression node. If not,
185624 /* This is the descendent of an OR node. In this case we cannot use
185626 ** into memory in this case. */
185712 ** the eval module. Specifically, this means to free:
185764 ** The author disclaims copyright to this source code. In place of
185835 /* The user should invoke this in one of two forms:
186067 /* State 0. In this state the integer just read was a docid. */
186074 /* State 1. In this state we are expecting either a 1, indicating
186080 ** increment the column 0 "nDoc" count for this term.
186126 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
186168 /* In case this cursor is being reused, close and zero it. */
186201 ** this module will not return a row with a negative languageid), and
186323 ** The author disclaims copyright to this source code. In place of
186341 ** By default, this module parses the legacy syntax that has been
186357 ** If compiled with SQLITE_TEST defined, then this module exports the
186358 ** symbol "int sqlite3_fts3_enable_parentheses". Setting this variable
186479 ** call fts3ExprParse(). So this forward declaration is required.
186486 ** structure of type FTSQUERY_PHRASE containing a phrase consisting of this
186613 ** sqlite3_free(). Setting this up requires a two pass approach.
186764 /* If this is a "NEAR" keyword, check for an explicit nearness. */
186772 /* At this point this is probably a keyword. But for that to be true,
186797 /* See if we are dealing with a quoted phrase. If this is the case, then
186831 /* If control flows to this point, this must be a regular token, or
186837 ** with a quoted phrase, only with a single token. Not sure if this was
186839 ** first implemented. Whichever it was, this module duplicates the
186981 ** isRequirePhrase is set, this is a syntax error.
187110 int eType = pRoot->eType; /* Type of node in this tree */
187278 ** in this case.
187424 ** Everything after this point is just test code.
187619 ** The author disclaims copyright to this source code. In place of
187633 ** The code in this file is only compiled if:
187686 ** Call this routine to delete a hash table or to reset a hash table
187746 ** The C syntax in this function definition may be unfamilar to some
187832 ** hash table that matches the given key. The hash for this key has
187839 int h /* The hash for this key. */
187915 ** that matches pKey,nKey. Return the data for this element if it is
187934 ** The key is not copied in this instance. If a malloc fails, then
187937 ** If the "data" parameter to this function is NULL, then the
188005 ** The author disclaims copyright to this source code. In place of
188018 ** The code in this file is only compiled if:
188087 ** used to incrementally tokenize this string is returned in
188186 ** In this routine z[] is in reverse order. So we are really looking
188272 const char *zFrom, /* If the ending matches this... (Reversed) */
188273 const char *zTo, /* ... change the ending to this (not reversed) */
188335 ** in [a-zA-Z] then no stemming is attempted and this routine just
188670 ** The author disclaims copyright to this source code. In place of
188684 ** The code in this file is only compiled if:
189076 ** The purpose of this is to test that the fts3_tokenizer() function
189135 ** fts3TokenizerFunc() in this file for details) and, if ENABLE_TABLE is
189140 ** The third argument to this function, zName, is used as the name
189193 ** The author disclaims copyright to this source code. In place of
189206 ** The code in this file is only compiled if:
189262 ** track such information in the database, then we'd only want this
189299 ** used to incrementally tokenize this string is returned in
189430 ** The author disclaims copyright to this source code. In place of
189454 ** The virtual table module tokenizes this <string>, using the FTS3
189531 ** in this case. Or, if an error occurs, an SQLite error code is returned.
189532 ** The final value of *pazDequote is undefined in this case.
189760 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
189891 ** The author disclaims copyright to this source code. In place of
189901 ** this file contains code to insert, update and delete rows from FTS3
189942 ** If this module is built with SQLITE_TEST defined, these constants may
190008 ** An instance of this structure is used to iterate through the terms on
190010 ** this structure are only manipulated by code in this file, opaque handles
190064 ** An instance of this structure is used to create a segment b-tree in the
190065 ** database. The internal details of this type are only accessed by the
190107 SegmentNode *pLeftmost; /* Pointer to left-most node of this depth */
190402 ** writing data to the fts3 table. If this lock is not acquired first, then
190403 ** the caller may end up attempting to take this lock as part of committing
190407 ** It is best to avoid this because if FTS3 returns any error when
190409 ** And this is not what users expect when they get SQLITE_LOCKED_SHAREDCACHE.
190473 ** There is only ever one instance of this SQL statement compiled for
190572 ** Zero is always returned in this case. Otherwise, if no OOM error occurs,
190655 ** happen if there was no previous entry for this token.
190699 /* If the user has inserted a NULL value, this function may be called with
190700 ** zText==0. In this case, add zero token entries to the hash table and
190749 ** Calling this function indicates that subsequent calls to
190755 int bDelete, /* True if this op is a delete */
190863 ** table. The SQL for this statement is:
190886 ** In FTS3, this is an error. It is an error to specify non-NULL values
191076 ** to this function. The handle may be closed by calling the
191081 ** method (xFilter etc.) that may directly or indirectly call this function
191250 /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf
191400 ** position. The exception is if this node is being loaded from disk
191645 ** within this entire function, not just this "else{...}" block.
191710 ** A different comparison function for SegReader structures. In this
191714 ** 1) EOF (end of doclist in this case) is greater than not EOF.
191831 ** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,
191922 ** this is possible.
191942 /* An unusual case: this is the first term to be added to the node
191945 ** p->nNodeSize bytes, but since this scenario only comes about when
191947 ** this is not expected to be a serious problem.
191988 ** If this is the first node in the tree, the term is added to it.
192041 ** database. Then call this function recursively to write the parent of
192055 int iHeight, /* Height of this node in tree */
192117 ** and return it via the input/output variable *ppWriter in this case.
192171 /* Figure out how many bytes are required by this new entry */
192218 /* If the buffer currently allocated is too small for this entry, realloc
192496 ** When this function is called, buffer *ppList (size *pnList bytes) contains
192725 ** have been made. Calling this function puts the MultiSegReader in such
192815 /* If this is a prefix-search, and if the term that apSegment[0] points
192817 ** required callbacks have been made. In this case exit early.
192819 ** Similarly, if this is a search for an exact match, and the first term
193020 ** segments in this index on levels greater than iAbsLevel. If there is
193032 ** old version of FTS. In this case it is not possible to determine
193056 /* Loop through all %_segdir entries for segments in this index with
193101 ** If this function is called with iLevel<0, but there is only one
193119 i64 iMaxLevel = 0; /* Max level number for this index/langid */
193139 ** greatest segment level currently present in the database for this
193595 ** An object of this type contains the state required to create or append
193631 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
193721 /* Figure out if this is a leaf or an internal node. */
193740 ** (pWriter->aNodeWriter[0].iBlock) when this function is called.
193802 ** into the parent of this node. */
193825 ** header must be written before this function is called.
193834 ** If the size of the value in blob pPrev is zero, then this is the first
193836 ** previous term. Before this function returns, it is updated to contain a
193841 ** is extended by this function if requrired.
193855 int bFirst = (pPrev->n==0); /* True if this is the first term written */
193921 /* If the current block is not empty, and if adding this term/doclist
193923 ** bytes, write this block out to the database. */
193975 ** If *pRc is not SQLITE_OK when this function is called, then no attempt
193976 ** is made to write any data to disk. Instead, this function serves only
194009 /* The entire output segment fits on a single node. Normally, this means
194011 ** table. However, this is not permitted in this case. The problem is that
194097 ** error code. The final value of *pbRes is undefined in this case.
194140 IncrmergeWriter *pWriter /* Populate this object */
194202 /* It is possible to append to this segment. Set up the IncrmergeWriter
194278 ** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus
194283 ** *piIdx is undefined in this case.
194335 IncrmergeWriter *pWriter /* Populate this object */
194498 const char *zTerm, /* Omit all terms smaller than this */
194556 const char *zTerm, /* Remove terms smaller than this */
194641 Fts3MultiSegReader *pCsr, /* Chomp all segments opened by this cursor */
194668 /* The incremental merge did not copy all the data from this
194741 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
194844 ** to the level identified by the block above (if any). If so, this
194857 ** no levels with more than nMin segments. Use this to limit the
194873 ** Exit early in this case. */
194883 ** indexes of absolute level iAbsLevel. If this cursor is opened using
194885 ** segments available in level iAbsLevel. In this case, no work is
195062 ** arguments to this function.
195092 ** return value is undefined in this case.
195170 ** code. The final value of *pbOk is undefined in this case.
195359 ** this list using sqlite3Fts3DeferToken().
195506 /* Deleting this row means the whole table is empty. In this case
195553 /* At this point it must be known if the %_stat table exists or not.
195592 /* If this is an INSERT operation, or an UPDATE that modifies the rowid
195593 ** value, then this operation requires constraint handling.
195595 ** If the on-conflict mode is REPLACE, this means that the existing row
195597 ** if the on-conflict mode is other than REPLACE, then this method must
195612 /* The new rowid is not NULL (in this case the rowid will be
195623 ** be losslessly converted to an integer. In this case, the eventual
195624 ** call to fts3InsertData() (either just below or further on in this
195641 /* If this is a DELETE or UPDATE operation, remove the old record. */
195647 /* If this is an INSERT or UPDATE operation, insert the new record. */
195708 ** The author disclaims copyright to this source code. In place of
195768 int iCol; /* Extract snippet from this column */
195806 ** An instance of this structure is used to manage a pair of buffers, each
195939 ** When this function is called, *pp points to the start of an element of
196080 ** candidate always starts at offset 0 (even if this candidate has a
196125 int *piScore, /* OUT: "Score" for this snippet */
196130 int iScore = 0; /* Score of this snippet */
196132 u64 mCover = 0; /* Mask of phrases covered by this snippet */
196348 ** are to the left of the first highlighted term. For example, to this:
196476 ** Extreme care is required when writing code to depend on this
196478 ** If a tokenizer is used directly by any code outside of FTS, this
196501 ** required. They are required if (a) this is not the first fragment,
196502 ** or (b) this fragment does not begin at position 0 of its column.
196521 /* Set isHighlight to true if this term should be highlighted. */
196540 ** row). When this function is called, *ppCollist should point to the
196790 int iPosOffset; /* Tokens count up to end of this phrase */
196840 ** array before returning. SQLITE_OK is returned in this case.
196867 int nLcs = 0; /* LCS value for this column */
196892 /* This iterator is already at EOF for this column. */
197074 ** cache does not match the format string for this request, discard
197081 /* If Fts3Cursor.pMIBuffer is NULL, then this is the first time the
197082 ** matchinfo function has been called for this query. In this case
197094 /* Determine the number of integers in the buffer returned by this call. */
197147 int iCol, /* Extract snippet from this column */
197163 int nSnippet = 0; /* Number of fragments in this snippet */
197196 ** If the iCol argument to this function was negative, this means all
197250 i64 iOff; /* Offset of this term from read positions */
197349 ** If an OOM occurs while retrieving the data (this can happen if SQLite
197384 /* All offsets for this column have been gathered. */
197462 ** The author disclaims copyright to this source code. In place of
197488 ** from the sqlite3 source file utf.c. If this file is compiled as part
197573 ** statement has specified that the tokenizer for this table shall consider
197577 ** For each codepoint in the zIn/nIn string, this function checks if the
197591 int bAlnum, /* Replace Isalnum() return value with this */
197726 ** used to incrementally tokenize this string is returned in
197791 ** Return SQLITE_DONE early if this takes us all the way to the end of
197862 ** The author disclaims copyright to this source code. In place of
197885 ** The results are undefined if the value passed to this function
197891 ** codepoints for which this function should return 0).
197898 ** using this format.
198103 ** The results are undefined if the value passed to this function
198120 ** The contents of this array are generated by parsing the CaseFolding.txt
198248 ** The author disclaims copyright to this source code. In place of
198272 ** Growing our own isspace() routine this way is twice as fast as
198307 /* An instance of this object represents a JSON string
198308 ** under construction. Really, this is a generic string accumulator
198385 ** Maximum nesting depth of JSON for this implementation.
198546 JsonString *p, /* Append to this JSON string */
198729 sqlite3_context *pCtx, /* Return value for this function */
198775 sqlite3_context *pCtx, /* Return value for this function */
198947 JsonParse *pParse, /* Append the node to this object */
198974 JsonParse *pParse, /* Append the node to this object */
199168 ** pParse is uninitialized when this routine is called.
199171 JsonParse *pParse, /* Initialize and fill this JsonParse object */
199250 ** of the argv array. Use the sqlite3_get_auxdata() cache for this
199343 u32 iRoot, /* Begin the search at this node */
199497 int *pApnd, /* Set this flag to 1 */
199498 const char **pzErr /* Make this point to any syntax error */
199669 ** corresponding to the SQL value input. Mostly this means putting
200049 ** this routine is a no-op. If JSON or PATH is malformed, throw an error.
200100 ** Create PATH and initialize it to VALUE. If PATH already exists, this
200372 u32 iEnd; /* EOF when i equals or exceeds this value */
200401 ** the last two columns in the table. Should this ever changes, be
200554 u32 i /* Path to this element */
200722 ** this entire plan */
200727 ** initialized to to discourage the query planner from selecting this
200950 ** The author disclaims copyright to this source code. In place of
201078 /* The xBestIndex method of this virtual table requires an estimate of
201080 ** various strategies. If possible, this estimate is loaded from the
201110 u32 nBusy; /* Current number of users of this structure */
201111 i64 nRowEst; /* Estimated number of rows in this table */
201152 ** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will
201185 RtreeDValue rScore; /* The score for this node. Smallest goes first. */
201308 int nRef; /* Number of references to this node */
201311 RtreeNode *pNext; /* Next node in this hash collision chain */
201348 ** An instance of this structure (in the form of a BLOB) is returned by
201354 u32 iSize; /* Size of this object */
201790 RtreeNode *pNode, /* Write new cell into this node */
201864 ** node pNode. If pNode is a leaf node, this is a rowid. If it is
202098 ** There are five versions of this macro. The last one is generic. The
202144 RtreeSearchPoint *pSearch, /* Container of this cell */
202213 ** If this constraint cannot be satisfied by any child within the node,
202265 ** If this constraint is not satisfied, set *peWithin to NOT_WITHIN.
202301 ** integer value equal to iRowid. Return the index of this cell.
202342 ** iLevel values coming first. In this way, if rScore is the same for all
202745 ** first argument to this function is the right-hand operand to the MATCH
202936 i64 nRow; /* Estimated rows returned by this scan */
203205 RtreeNode *pNode, /* Adjust ancestry of this node. */
203271 ** this function sets the aIdx array to contain:
203591 ** In this case avoid the all to nodeWrite().
203670 ** the entry resides (argument pLeaf). Once the leaf is located, this
203686 ** want to do this as it leads to a memory leak when trying to delete
203838 /* Allocate the buffers used by this operation. The allocation is
203839 ** relinquished before this function returns.
203897 /* Find a node to store this cell in. pNode->iNode currently contains
203966 /* Find a node to store this cell in. pNode->iNode currently contains
204045 ** in this scenario).
204115 ** Assuming no OOM error occurs, this function sets the error message
204321 ** The sqlite3_blob object should be released at this point.
204356 ** it uses this hook to close any open blob handle. This is done because a
204378 ** of the number of rows in the virtual table. If possible, this is based
204413 ** by this module.
204580 ** The second argument to this function contains the text of an SQL statement
204607 ** If this function is being called as part of an xConnect(), then the rtree
204608 ** table already exists. In this case the node-size is determined by inspecting
204859 ** node always has nodeno=1, so the example above is the primary use for this
204889 int nDim; /* Number of dimensions for this rtree tbl */
204911 ** The second and subsequent arguments to this function are a format string
204943 ** The second and subsequent arguments to this function are a printf()
204970 ** returned in this case.
204979 ** this case.
205021 ** In both cases, this function checks that there exists an entry with
205073 ** containing pCell. In this case it is also verified that the two
205180 ** The second argument to this function must be either "_rowid" or
205228 ** to ensure that the queries run as part of this integrity-check operate
205290 ** Invoking this SQL function runs an integrity-check on the named rtree
205354 ** The author disclaims copyright to this source code. In place of
205381 /* Use the SQLite core versions if this routine is part of the
205396 ** Growing our own isspace() routine this way is twice as fast as
205878 ** In other words, this routine returns a CCW polygon regardless of the
205881 ** Use this routine to sanitize historical inputs that that sometimes
206124 ** the line segment for the purposes of this analysis.
206292 GeoOverlap *p, /* Add segments to this Overlap object */
206293 GeoPoly *pPoly, /* Take all segments from this polygon */
207210 ** or sqlite3_rtree_query_callback(). In other words, this routine is the
207235 ** scalar function that is implemented by this routine.
207237 ** All this function does is construct an RtreeMatchArg object that
207239 ** parameters to this function, then return that RtreeMatchArg object
207285 sqlite3 *db, /* Register SQL function on this connection */
207309 sqlite3 *db, /* Register SQL function on this connection */
207353 ** The author disclaims copyright to this source code. In place of
207676 ** pointer after this function returns.
207911 ** The author disclaims copyright to this source code. In place of
207998 ** used to incrementally tokenize this string is returned in
208176 ** The author disclaims copyright to this source code. In place of
208204 ** During this stage RBU does not update the database by writing
208212 ** location using a call to rename(2). Before doing this the RBU
208218 ** this point they see the new version of the database - including
208237 ** committed before the RBU update database this will likely either just
208243 ** not really clear how to get out of this state. The system could just
208267 ** The author disclaims copyright to this source code. In place of
208299 ** exactly once. SQLite uses this trick to improve the performance of
208303 ** Additionally, this extension allows the work involved in writing the
208315 ** applied using this extension is hence refered to as an "RBU update".
208440 ** for UPDATEs may also be set to 'd'. In this case, instead of updating the
208447 ** For example, this row:
208458 ** format used by the fossil source-code management system. In this case
208465 ** to the rbu_rowid value. For example, this:
208545 ** the path to the RBU database. Each call to this function must be matched
208585 ** The second argument to this function identifies a database in which
208592 ** The vacuum can be resumed by calling this function to open a new RBU
208595 ** If the second argument passed to this function is NULL, then the
208597 ** is the name of the target database file. In this case, on UNIX, if the
208626 ** If the second parameter to this function is passed zero, then the limit
208628 ** not modified (this is useful for querying the current limit).
208649 ** The first argument passed to this function must be a valid, open, RBU
208669 ** this function may return NULL. The error code and message may be collected
208672 ** Database handles returned by this function remain valid until the next
208697 ** sqlite3rbu_close() or this function.
208711 ** or sqlite3rbu_open() call, or if one occurs within this function, an
208717 ** Otherwise, if no error occurs, this function returns SQLITE_OK if the
208744 ** If this API is called during stage 2 of the update, output variable
208750 ** If this API is called during stage 1 of the update, output variable
208763 ** If the rbu_count table is present and populated correctly and this
208775 ** defined in this file. Return values should be interpreted as follows:
208813 ** path. Normally, it does this by invoking POSIX function rename(2) directly.
208821 ** argument (pArg) passed to this function. The second is the full path
208825 ** In this case the RBU operation will be abandoned and the error returned
208828 ** Passing a NULL pointer in place of the xRename argument to this function
208845 ** Part of the RBU implementation uses a custom VFS object. Usually, this
208848 ** The exception is for applications that also use zipvfs. In this case,
208905 /* Maximum number of prepared UPDATE statements held by this module */
208956 ** Trbul number of sqlite3rbu_step() calls made so far as part of this
208964 ** be continued if this happens).
209052 ** An iterator of this type is used to iterate through all objects in
209067 ** this array set set to 1. This is because in that case, the module has
209151 ** If the RBU database contains an rbu_count table, this value is set to
209177 ** PK does not exist. In this case no operations are required on index
209228 ** An rbu VFS is implemented using an instance of this structure.
209248 ** If this is a temporary file (pRbu!=0 && flags&DELETE_ON_CLOSE), variable
209258 int openFlags; /* Flags this file was opened with */
209265 char *zDel; /* Delete this when closing file */
209267 const char *zWal; /* Wal filename for this main db file */
209268 rbu_file *pWalFd; /* Wal file descriptor for this main db */
209362 ** routine will determine this size for you.
209372 ** then this routine returns -1.
209382 char *zOut /* Write the output into this preallocated buffer */
209481 ** arguments must be passed to this function. The first is the blob to
209482 ** patch and the second the patch to apply. If no error occurs, this
209536 ** of the caller to (eventually) free this buffer using sqlite3_free().
209558 ** to eventually free this buffer using sqlite3_free().
209576 ** returned. In this case, *pzErrmsg may also be set to point to an error
209577 ** message. It is the responsibility of the caller to free this error message
209580 ** If argument zSql is NULL, this function assumes that an OOM has occurred.
209581 ** In this case SQLITE_NOMEM is returned and *ppStmt set to NULL.
209820 ** than SQLITE_OK), then this function returns NULL without modifying the
209821 ** stored error code. In this case it still calls sqlite3_free() on any
209846 ** RBU handle. If an error has already occurred when this function is
209872 ** error has already occurred when this function is called, return NULL
209914 ** It is the responsibility of the caller to eventually free this memory
210143 /* Figure out the type of table this step will deal with. */
210308 ** this function contain literal SQL values.
210373 ** If the expression cannot be created, NULL is returned. In this case,
210684 ** of the RBU handle to something reflecting this.
210706 ** when this function is called, NULL is returned immediately, without
210760 ** when this function is called, NULL is returned immediately, without
210786 ** this function returns:
210834 ** a table (not index) with an external primary key, this function is a
210837 ** Assuming the iterator does point to a table with an external PK, this
210861 ** zIdx to point to a nul-terminated string containing this name. */
210904 ** If an error has already occurred when this function is called, it
210906 ** occurs during the execution of this function, it sets the error code
210911 ** a table (not an index) when this function is called. This function
211161 /* Create the imposter table used to write to this index. */
211247 const char *zTbl = pIter->zTbl; /* Table this step applies to */
211274 ** Because it only performs INSERT operations, this is not required for
211391 ** If the zMask string does not specify any columns to update, then this
211392 ** is not an error. Output variable *ppStmt is set to NULL in this case.
211579 ** open on the target database. Use this handle instead of opening a new
211731 ** this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use.
211807 ** being resumed. In this case, if the checksum of the wal-index-header
212009 ** then reopens the database file (this time in vanilla, non-oal, WAL mode).
212030 /* Move the *-oal file to *-wal. At this point connection p->db is
212079 ** determines the type of operation requested by this row and returns
212161 /* If this is a delete, decrement nPhaseOneStep by nIndex. If the DELETE
212176 /* If this is an INSERT into a table b-tree and the table has an
212177 ** explicit INTEGER PRIMARY KEY, check that this is not an attempt
212293 ** Or, if this is an RBU vacuum, set the schema cookie of the main db
212307 /* Coverage: it may be that this sqlite3_step() cannot fail. There
212373 ** The second argument passed to this function is the name of a PRAGMA
212406 ** the state database is empty. If this RBU handle was opened for an
212467 /* If this is an RBU vacuum operation and the state table was empty
212468 ** when this handle was opened, create the target database schema. */
212556 ** after this step, then rbu_step() again, then a power failure occurs,
212558 ** this by checkpointing frames until the next page in the aFrame[]
212814 ** flag it set, this means that the db was not opened because it seemed
212815 ** to be a wal-mode db. But, this may have happened due to an earlier
212817 ** If this is the case, it will have been checkpointed and deleted
212861 /* At this point (pTargetFd->iCookie) contains the value of the
212894 ** created at this point. */
212920 ** exclusive lock on the db file. If this fails, so be it. */
213042 /* If this is an RBU vacuum handle and the vacuum has either finished
213248 ** rbu_vfs.pMain to facilitate this.
213467 /* If this is being called to read the first page of the target
213584 /* If this is an RBU vacuum operation and this is the target database,
213609 /* Do not allow EXCLUSIVE locks. Preventing SQLite from taking this
213650 ** one is found, this vfs will operate in pass-through mode. The lower
213656 ** one is found, this is an error. */
213759 /* If not in RBU_STAGE_OAL, allow this call to pass through. Or, if this
213875 ** the name of the *-wal file this db connection will use. SQLite
213876 ** happens to pass a pointer to this buffer when using xAccess()
213952 /* If this call is to check if a *-wal file associated with an RBU target
214165 ** Configure the aggregate temp file size limit for this RBU handle.
214188 ** The author disclaims copyright to this source code. In place of
214259 " payload INTEGER," /* 5 Bytes of payload on this page */
214260 " unused INTEGER," /* 6 Bytes of unused space on this page */
214269 /* Forward reference to data structured used in this module */
214278 u32 iChildPg; /* Child node (or 0 if this is a leaf) */
214290 char *zPath; /* Path to this page */
214307 int iDb; /* Schema used for this query */
214329 sqlite3 *db; /* Database connection that owns this vtab */
214447 ** If this will satisfy the client, set the orderByConsumed flag so that
214513 ** this happens. dbsqlfuzz 9ed3e4e3816219d3509d711636c38542bf3f40b1. */
214720 Btree *pBt, /* Load page from this b-tree */
214722 StatPage *pPg /* Load page into this object */
214830 ** an entire btree, this is the exit point from this function */
214926 int rc = SQLITE_OK; /* Result of this operation */
214927 const char *zName = 0; /* Only provide analysis of this table */
215051 ** Invoke this routine to register the "dbstat" virtual table module
215091 ** The author disclaims copyright to this source code. In place of
215131 int mxPgno; /* Last page to visit on this scan */
215219 /* If we reach this point, it means that either there is no schema=
215366 ** request this page from the page is an SQLITE_CORRUPT error. */
215479 ** Invoke this routine to register the "dbpage" virtual table module
215576 ** Instances of this structure are used to build strings or binary records.
215585 ** An object of this type is used internally as an abstraction for
215609 int bPatchset; /* True if this is a patchset */
215639 int bStat1; /* True if this is sqlite_stat1 */
215808 ** this structure stored in a SessionTable.aChange[] hash table.
215812 u8 bIndirect; /* True if this change is "indirect" */
215876 ** returning. Or, if aBuf is NULL, the only thing this function does is
215977 ** order to use this macro, the entire data structure must be represented
215987 ** In practice, the data structures this macro is used for are the primary
216107 ** calculated by this function are compatible with those calculated by
216111 ** a patchset DELETE. In this case the non-PK fields are omitted entirely.
216117 int nBucket /* Assume this many buckets in hash table */
216236 ** When this function is called, both *paOne and *paTwo point to a value
216240 ** If, when this function is called, *paTwo points to a valid value (i.e.
216384 ** this (that the method has already been called). */
216436 ** It is possible that a non-fatal OOM error occurs in this function. In
216438 ** Growing the hash table in this case is a performance optimization only,
216611 ** free any allocation made. An error code will be returned in this case.
216630 ** write to table pTab, part of session pSession. If this is the first
216631 ** write to this table, initalize the SessionTable.nCol, azCol[] and
216637 ** indicate that updates on this table should be ignored. SessionTable.abPK
216638 ** is set to NULL in this case.
216671 ** sqlite_stat1 table. The purpose of this is to substitute a zero-length
216830 /* Check the number of columns in this xPreUpdate call matches the
216862 /* Calculate the hash-key for this change. If the primary key of the row
216869 /* Search the hash table for an existing record for this row. */
216877 ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK
216878 ** values (if this is an INSERT). */
216916 ** It is not possible for an OOM to occur in this block. */
216938 /* If the existing change is considered "indirect", but this current
217002 ** The 'pre-update' hook registered by this module with SQLite databases.
217021 /* If this session is attached to a different database ("main", "temp"
217023 ** to the next session object attached to this database. */
217167 const char *zDb1, /* Pick rows in this db only */
217168 const char *zDb2, /* But not in this one */
217370 ** attached to database handle $db. Do this under the cover of the db
217472 /* First search for an existing entry. If one is found, this call is
217524 ** of sqlite3_realloc64(). Allocations greater than this size in bytes
217525 ** always fail. It is used here to ensure that this routine can always
217526 ** allocate up to this limit - instead of up to the largest power of
217810 /* If at least one field has been modified, this is not a no-op. */
217813 /* Add a field to the old.* record. This is omitted if this modules is
218033 SessionBuffer *pBuf, /* Append header to this buffer */
218071 /* Zero the output variables in case an error occurs. If this session
218073 ** this call will be a no-op. */
218450 ** When this function is called, *ppRec points to the start of a record
218481 sqlite3_value *pVal, /* Set the value of this object */
218486 /* In theory this code could just pass SQLITE_TRANSIENT as the final
218501 ** When this function is called, *paChange points to the start of the record
218503 ** one byte after the end of the same record before this function returns.
218519 ** The apOut[] array may have been partially populated in this case.
218525 sqlite3_value **apOut, /* Write values to this array */
218642 ** final value of *pnByte is undefined in this case.
218729 ** this function and sessionChangesetNext() are that
218732 ** that modifies no columns), this function sets (*pbEmpty) to 1.
218818 /* If this is an UPDATE or DELETE, read the old.* record. */
218825 /* If this is an INSERT or UPDATE, read the new.* record. */
218832 /* If this is an UPDATE that is part of a patchset, then all PK and
218850 /* If this is an UPDATE that is part of a changeset, then check that
218855 ** point generating them. Under most circumstances this is benign, but
218873 ** If both paRec and pnRec are NULL, then this function works like the public
218881 ** Either way, this function returns SQLITE_ROW if the iterator is
219040 ** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case
219044 ** In all other cases this function returns SQLITE_MISUSE.
219467 ** structure like this:
219471 ** The DELETE statement looks like this:
219540 ** The SELECT statement looks like this:
219626 ** See comments in the body of this function for details.
219655 ** to an array nCol elements in size. In this case only those values for
219666 sqlite3_stmt *pStmt /* Bind values to this statement */
219702 ** If this function returns SQLITE_ROW, the caller must eventually reset()
219800 ** handler as the "conflicting" record. In this case the type of conflict
219817 ** this function returns SQLITE_OK.
219902 ** to true before returning. In this case the caller will invoke this function
219903 ** again, this time with pbRetry set to NULL.
219909 ** before retrying. In this case the caller attempts to remove the conflicting
219910 ** row before invoking this function again, this time with pbReplace set
219913 ** If any conflict handler returns SQLITE_CHANGESET_ABORT, this function
219944 ** * this is a patchset, or
219946 ** * all columns of the table are PK columns (in this case there is
219995 ** a row with a matching primary key. If so, this is a DATA conflict.
220012 /* Check if there is a conflicting row. For sqlite_stat1, this needs
220045 ** The difference between this function and sessionApplyOne() is that this
220051 sqlite3 *db, /* Apply change to "main" db of this handle */
220064 ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and
220067 ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation,
220078 ** SQLITE_CHANGESET_REPLACE. In this case remove the conflicting row
220164 sqlite3 *db, /* Apply change to "main" db of this handle */
220232 ** xFilter callback returns zero, skip this table. If it returns
220362 sqlite3 *db, /* Apply change to "main" db of this handle */
220395 sqlite3 *db, /* Apply change to "main" db of this handle */
220420 sqlite3 *db, /* Apply change to "main" db of this handle */
220447 sqlite3 *db, /* Apply change to "main" db of this handle */
220776 ** buffer containing the output changeset before this function returns. In
220777 ** this case (*pnOut) is set to the size of the output buffer in bytes. It
221028 ** in the rebase buffer is set to "replaced" (type 0xFF). If this
221097 ** before this function returns. In this case (*pnOut) is set to the size of
221136 /* Append a table header to the output for this new table */
221252 ** Call this one or more times to configure a rebaser.
221357 ** The author disclaims copyright to this source code. In place of
221366 ** Interfaces to extend FTS5. Using the interfaces defined in this file,
221466 ** (i.e. if it is a contentless table), then this API always returns 0.
221525 ** If there is already an auxiliary data pointer when this function is
221527 ** was specified along with the original pointer, it is invoked at this
221533 ** If an error (e.g. an OOM condition) occurs within this function,
221545 ** (set to NULL) before this function returns. In this case the xDelete,
221561 ** to use, this API may be faster under some circumstances. To iterate
221574 ** modify this structure directly - it should only be used as shown above
221581 ** (i.e. if it is a contentless table), then this API always iterates
221606 ** then this API always iterates through an empty set (all calls to
221609 ** The information accessed using this API and its companion
221611 ** (or xInst/xInstCount). The chief advantage of this API is that it is
221673 ** The first argument passed to this function is a copy of the (void*)
221684 ** be returned. In this case, fts5 assumes that the final value of *ppOut
221689 ** allocated using xCreate(). Fts5 guarantees that this function will
221695 ** argument passed to this function is a pointer to an Fts5Tokenizer object
221732 ** synonyms. In this case see the discussion below for details.
221755 ** There are several ways to approach this in FTS5:
221757 ** <ol><li> By mapping all synonyms to a single token. In this case, using
221758 ** the above example, this means that the tokenizer returns the
221767 ** separately. In this case, when tokenizing query text, the
221787 ** Using this method, when tokenizing document text, the tokenizer
221832 ** For full prefix support, method (3) may be preferred. In this case,
221835 ** extra entries are added to the FTS index, this method uses more space
221838 ** Method (2) offers a midpoint between (1) and (3). Using this method,
221933 ** The author disclaims copyright to this source code. In place of
221993 /* Truncate very long tokens to this many bytes. Hard limit is
222386 ** added to or removed from the index, this function is called one or more
222446 ** this connection since it was created.
222529 i64 iRowid, /* Rowid for this entry */
222683 ** The fts5_expr.c API above this point is used by the other hand-written
222684 ** C code in this module. The interfaces below this point are called by
222809 ** The author disclaims copyright to this source code. In place of
222820 ** this template to construct a parser. The "lemon" program inserts text
222822 ** interstitial "-" characters) contained in this template is changed into
222824 ** of this template is copied straight through into the generate parser
222888 ** fts5YYFALLBACK If defined, this indicates that one or more tokens
223027 ** The following are the tables generated in this section:
223114 ** + The state number for the parser at this level of the stack.
223116 ** + The value of the token stored at this level of the stack.
223119 ** + The semantic value stored at this level of the stack. This is
223130 ** number for the token at this stack level */
223483 ** systems, every element of this matrix should end up being set.
223771 ** if the lookahead token has already been consumed. As this procedure is
224097 unsigned int fts5yyruleno = fts5yyact - fts5YY_MIN_REDUCE; /* Reduce by this rule */
224223 ** Applications can set this macro (for example inside %include) if
224286 ** The author disclaims copyright to this source code. In place of
224303 ** column being considered do not overlap, this object simply iterates
224412 ** If *pRc is set to any value other than SQLITE_OK when this function is
224669 int nInst = 0; /* Number of instance matches this row */
224846 Fts5Bm25Data **ppData /* OUT: bm25-data object for this query */
224872 /* Calculate the average document length for this FTS5 table */
224892 ** The problem with this is that if (N < 2*nHit), the IDF is
225001 ** The author disclaims copyright to this source code. In place of
225057 ** the error code in p. If an error has already occurred when this function
225076 ** though this byte is not included in the pBuf->n count.
225092 ** Like sqlite3Fts5BufferAppendString(), this function ensures that the byte
225093 ** following the buffer data is set to 0x00, even though this byte is not
225150 ** the error code in p. If an error has already occurred when this function
225227 ** The previous position written to this list is *piPrev. *piPrev is set
225356 /* Calculate a hash value for this term. This is the same hash checksum
225410 ** The author disclaims copyright to this source code. In place of
225521 /* At this point, if the literal was an integer, the parse is
225584 ** input does not begin with a quote character, then this routine
225819 ** If *pRc is other than SQLITE_OK when this function is called, it is
225820 ** a no-op (NULL is returned). Otherwise, if an OOM occurs within this
226117 ** the callback returned SQLITE_DONE, this is not an error and this function
226138 ** If it actually is this, return a pointer to the ')'. Otherwise, return
226161 ** this is:
226376 ** The author disclaims copyright to this source code. In place of
226438 /* Next method for this node. */
226444 /* Child nodes. For a NOT node, this array always contains 2 entries. For
226466 Fts5IndexIter *pIter; /* Iterator for this term */
226475 Fts5ExprNode *pNode; /* FTS5_STRING node this phrase is part of */
226478 Fts5ExprTerm aTerm[1]; /* Terms that make up this phrase */
226832 Fts5Buffer *pBuf, /* Use this buffer for space if required */
226903 ** pointing to the same rowid when this function is called. This function
226906 ** is set to true if this is really a match, or false otherwise.
227041 ** If in/out parameter (*pRc) is set to other than SQLITE_OK when this
227043 ** occurs within this function (*pRc) is set accordingly before returning.
227142 ** than the initial value of *piLast. If this means the iterator points
227317 ** If pExpr is an ASC iterator, this function returns a value with the
227322 ** Otherwise, if this is a DESC iterator, the opposite is returned:
227392 ** this function is called. This function checks if all term iterators
227394 ** If an EOF is reached before this happens, *pbEof is set to true before
227413 /* Check that this node should not be FTS5_TERM */
227421 ** iterator skips through rowids in the default ascending order, this means
227540 /* As this "NEAR" object is actually a single phrase that consists
227751 ** If pNode currently points to a match, this function returns SQLITE_OK
228047 /* If an error has already occurred, this is a no-op */
228324 ** The second argument passed to this function may be NULL, or it may be
228330 ** The old colset object (if any) is not freed in this case.
228430 ** SQLITE_OK when this function is called, NULL is returned.
228653 sqlite3_int64 nByte; /* Bytes of space to allocate for this node */
229239 ** At present this function is only used for detail=col and detail=none
229273 ** TODO: Make this more efficient!
229448 ** The author disclaims copyright to this source code. In place of
229687 i64 iRowid, /* Rowid for this entry */
229782 /* If this is a new rowid, append the 4-byte size field for the previous
229783 ** entry, and the new rowid for this entry. */
230009 ** The author disclaims copyright to this source code. In place of
230019 ** routines in this file file implement all read and write access to the
230020 ** %_data table. Other parts of the system access this functionality via
230054 #define FTS5_MIN_DLIDX_SIZE 4 /* Add dlidx if this many empty pages */
230065 ** The %_data table managed by this module,
230135 ** this field. Plus 1 if this entry carries the "delete" flag.
230159 ** footer is 0 bytes in size, then this field is the same as the
230170 ** term/doclist data fits on a single leaf page. If this is not the case,
230253 ** Each time a blob is read from the %_data table, it is padded with this
230341 int nSegment; /* Total segments in this structure */
230342 int nLevel; /* Number of levels in this index */
230350 int pgno; /* Page number for this page */
230357 int pgno; /* Page number for this page */
230400 ** rowid field of the current entry. Usually this is the size field of the
230493 ** segments that this object is merging data from. Both the aSeg[] and
230500 ** comparison in this context is the index of the iterator that currently
230509 ** There is no way to tell if this is populated or not.
230514 Fts5Index *pIndex; /* Index that owns this iterator */
230545 Fts5Data *pData; /* Data for current page of this level */
230646 ** rollback since it was last used. In this case a new blob handle
230659 /* If the blob handle is not open at this point, open it and seek
230676 u8 *aOut = 0; /* Read blob data into this buffer */
230694 /* TODO1: Fix this */
231051 /* TODO: Do we need this if the leaf-index is appended? Probably... */
231095 ** Fts5Index handle. If an error has already occurred when this function
231178 ** error has already occurred, this function is a no-op.
231285 ** to reflect this.
231295 int szPromote = 0; /* Promote anything this size or smaller */
231402 ** When this function is called pIter->iLeafPgno is the page number the
231696 ** of the "nPrefix" field (if there was one - it is passed 0 if this is
231754 ** this function returns.
231757 ** an error has already occurred when this function is called, it is a no-op.
231767 ** fts5TrimSegments() for details. In this case leave the iterator empty.
231797 ** The iterator is in an unusual state when this function is called: the
231804 ** aRowidOffset[] and iRowidOffset variables. At this point the iterator
231876 ** In this case leave pIter->pLeaf==0, this iterator is at EOF. */
232031 ** already occurred when this function is called, it is a no-op.
232140 ** this block is particularly performance critical, so equivalent
232188 /* If this condition is true then the largest rowid for the current
232215 /* If pLast is NULL at this point, then the last rowid for this doclist
232216 ** lies on the page currently indicated by the iterator. In this case
232221 ** rowid. In this case configure the iterator so that it points to the
232222 ** first rowid on this page.
232261 /* Check if the current doclist ends on this page. If it does, return
232284 ** is larger than the specified term, even if this term is not on the
232316 /* Figure out how many new bytes are in this term */
232430 ** an error has already occurred when this function is called, it is a no-op.
232513 ** an error has already occurred when this function is called, it is a no-op.
232628 ** This function is a no-op unless SQLITE_DEBUG is defined when this module
232629 ** is compiled. In that case, this function is essentially an assert()
232773 i64 iMatch /* Advance iterator at least this far */
232860 ** on the iterator instead. That function does the same as this one, except
232917 ** EOF when this function is called.
232923 i64 iFrom /* Advance at least as far as this */
233025 Fts5Buffer *pBuf; /* Append to this buffer */
233026 Fts5Colset *pColset; /* Restrict matches to this column */
233032 Fts5Buffer *pBuf; /* Append to this buffer */
233033 Fts5Colset *pColset; /* Restrict matches to this column */
233039 ** TODO: Make this more efficient!
233126 Fts5SegIter *pSeg, /* Poslist of this iterator */
233303 ** to this buffer. */
233399 ** to this buffer. */
233521 ** to the first entry in its segment. In this case initialize the
233607 ** to. If the iterator points to EOF when this function is called the
233649 ** If an error has already occurred, this function is a no-op. 0 is
233650 ** returned in this case.
233802 ** Fts5SegWriter.aDlidx[] array. If it is large enough, this function
233835 ** has already occurred when this function is called, it is a no-op.
233955 /* No term was written to this page. */
233987 ** already occurred, this function is a no-op.
234026 ** the segment b-tree. In this case it is necessary to add a term to
234029 ** this term. In other words, a prefix of (pTerm/nTerm) that is one
234034 ** is if this is the first term written in an incremental-merge step.
234035 ** In this case the previous term is not available, so just write a
234082 /* If this is to be the first rowid written to the page, set the
234223 /* All keys from this input segment have been transfered to the output.
234241 ** this case a prior iteration of this loop may have corrupted the
234296 int *pnRem /* Write up to this many output leaves */
234499 ** already occurred, this function is a no-op.
234554 ** in a 32-bit integer. Return the size of the largest prefix of this
234576 ** already occurred, this function is a no-op.
234615 const u8 *pDoclist; /* Pointer to doclist for this term */
234618 /* Write the term for this entry to disk. */
234632 /* The entire doclist will not fit on this leaf. The following
234672 /* The entire poslist will not fit on this leaf. So it needs
234750 /* Figure out if this structure requires optimization. A structure does
234974 ** In this case the buffers consist of a delta-encoded list of rowids only.
235137 /* See the earlier comment in this function for an explanation of why
235388 ** The %_data table is completely empty when this function is called. This
235514 ** added to or removed from the index, this function is called one or more
235577 /* Figure out which index to search and set iIdx accordingly. If this
235582 ** If the QUERY_TEST_NOIDX flag was specified, then this must be a
235677 ** definition of "at or after" depends on whether this iterator iterates
235746 ** Return the total number of blocks this module has read from the %_data
235790 ** Below this point is the implementation of the integrity-check
235826 int iLeaf /* Load doclist-index for this leaf */
235955 ** the same. If not, call this corruption. */
235963 /* If this is a prefix query, check that the results returned if the
235968 ** a time, and the multi-iter loop from which this function is called
235971 ** Also only do this if buffer zTerm contains nTerm bytes of valid
236106 i64 iRow; /* Rowid for this leaf */
236107 Fts5Data *pLeaf; /* Data for this leaf */
236115 ** ignore this b-tree entry. Otherwise, load it into memory. */
236261 /* The cksum argument passed to this function is a checksum calculated
236284 /* If this is a new term, query for it. Update cksum3 with the results. */
236318 ** Below this point is the implementation of the fts5_decode() scalar
236506 ** If *pRc is other than SQLITE_OK when this function is called, it is a
236507 ** no-op. If an OOM or other error occurs within this function, *pRc is
236509 ** pBuf is undefined in this case.
236629 /* Figure out where the doclist for this term ends */
236832 ** The author disclaims copyright to this source code. In place of
236902 ** A single object of this type is allocated when the FTS5 module is
236922 Fts5Global *pGlobal; /* Global context for this function */
236947 Fts5Cursor *pSortCsr; /* Sort data from this cursor */
236980 ** If this is a 'special' query (refer to function fts5SpecialMatch()),
236981 ** then this variable contains the result of the query.
237001 /* Zero from this point onwards on cursor reset */
237004 i64 iFirstRowid; /* Return no rowids earlier than this */
237005 i64 iLastRowid; /* Return no rowids later than this */
237068 Fts5Auxiliary *pAux; /* Extension to which this belongs */
237124 ** having called xSavepoint() on this vtab. */
237282 ** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this
237284 ** support index-info flags. In that case this function is a no-op.
237419 /* As there exists an unusable MATCH constraint this is an
237831 ** And since the statement required here reads from this very virtual
237834 ** If SQLite a built-in statement cache, this wouldn't be a problem. */
238034 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
238079 /* Decode the arguments passed through to this function. */
238161 /* If pSortCsr is non-NULL, then this call is being made as part of
238164 ** return results to the user for this query. The current cursor
238223 ** This is the xEof method of the virtual table. SQLite calls this
238247 ** This is the xRowid method. The SQLite core calls this routine to
238341 ** The commands implemented by this function are documented in the "Special
238343 ** more commands are added to this function.
238455 /* A transaction must be open when this is called. */
238527 /* If this is a REPLACE, first remove the current entry (if any) */
239527 fts5_tokenizer *pTokenizer /* Populate this object */
239629 ** by this module.
239717 ** this module is being built as part of the SQLite core (SQLITE_CORE is
239720 ** Or, if this module is being built as a loadable extension,
239759 ** The author disclaims copyright to this source code. In place of
240145 ** remove the %_content row at this time though.
240214 ** is specified when the FTS5 table is created), this function is a no-op.
240430 ** this case the user is required to provide a rowid explicitly.
240641 ** determine this.
240772 ** sqlite3Fts5StorageStmt(). The eStmt parameter passed to this function
240865 ** rows. However this function is only called from the xRowCount() API,
240928 ** The author disclaims copyright to this source code. In place of
241105 ** from the sqlite3 source file utf.c. If this file is compiled as part
241383 /* Each iteration of this loop gobbles up a contiguous run of separators,
241470 /* Any tokens larger than this (in bytes) are passed through without
242295 ** In practice, this is:
242344 ** The author disclaims copyright to this source code. In place of
242454 ** The results are undefined if the value passed to this function
242471 ** The contents of this array are generated by parsing the CaseFolding.txt
243123 ** The author disclaims copyright to this source code. In place of
243140 ** Except, this version does handle the single byte case that the core
243315 /* we can skip this cause it was (effectively) done above in calc'ing s */
243468 ** The author disclaims copyright to this source code. In place of
243515 Fts5Global *pGlobal; /* FTS5 global object for this database */
243525 int bEof; /* True if this cursor is at EOF */
243772 ** the "term" column (column 0). So if the user has requested this
244066 sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */
244136 ** This is the xEof method of the virtual table. SQLite calls this
244212 ** This is the xRowid method. The SQLite core calls this routine to
244266 ** The author disclaims copyright to this source code. In place of
244311 sqlite3 *db; /* Database connection for this stmt vtab */
244321 sqlite3 *db; /* Database connection for this cursor */
244329 ** Think of this routine as the constructor for stmt_vtab objects.
244331 ** All this routine needs to do is:
244447 ** Return the rowid for the current row. In this implementation, the
244527 ** SQLite will invoke this method one or more times while planning a query
244602 /* Return the source-id for this library */
244983 // You should clear key derive result of output before you call this function
245025 // You should set all key infos including salt before you call this function
245150 // You should clear key derive infos before you call this function
245261 // You should clear key derive infos and password infos before you call this function
245276 // You should clear key derive infos and password infos before you call this function
245318 // You should clear output before you call this function
245339 // You should clear key context before you call this function