Lines Matching defs:be

4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
15 ** of the embedded sqlite3.h header file.) Additional code files may be needed
49 ** large file support, or if the OS is windows, these should be no-ops.
52 ** system #includes. Hence, this block of code must be the very first
55 ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
133 ** It used to be the case that setting this value to zero would
194 ** The maximum number of attached databases. This must be between 0
212 ** and the fact that the page size must be a power of 2.
218 ** limit will not be able to rollback the aborted transaction. This could
257 ** This value can be lowered (or raised) at run-time using that the
275 ** A value of 1 means that a trigger program will not be able to itself
277 ** may be executed.
318 ** A simple compiler pragma or casting sequence could not be found
321 ** It could be argued that the intptr_t type could be used in this
346 ** The SQLITE_THREADSAFE macro must be defined as either 0 or 1.
359 ** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
362 ** be overridden at runtime using the sqlite3_config() API.
369 ** Exactly one of the following macros must be defined in order to
440 ** testcase() must be evaluated both true and false in order to
444 ** can be used to make sure boundary values are tested. For
445 ** bitmask tests, testcase() can be used to make sure each bit
485 ** are intended to always be true or false, respectively. Such
486 ** expressions could be omitted from the code completely. But they
495 ** be true and false so that the unreachable code then specify will
496 ** not be counted as untested code.
540 ** notice, and should not be referenced by programs that use SQLite.
585 ** compatibility only. Application writers should be aware that
618 ** be larger than the release from which it is derived. Either Y will
619 ** be held constant and Z will be incremented or else Y will be incremented
620 ** and Z will be reset to zero.
680 ** SQLite can be compiled with or without mutexes. When
689 ** the mutexes. But for maximum safety, mutexes should be enabled.
690 ** ^The default behavior is for mutexes to be enabled.
692 ** This interface can be used by an application to make sure that the
699 ** can be fully or partially disabled using a call to [sqlite3_config()]
780 ** The C parameter to [sqlite3_close(C)] must be either a NULL
859 const char *sql, /* SQL to be evaluated */
873 ** New error codes may be added in future versions of SQLite.
925 ** One may expect the number of extended result codes will be expand
929 ** The SQLITE_OK result code will never be extended. It will always
930 ** be exactly zero.
1030 ** information need not be flushed. If the lower four bits of the flag
1066 ** may be invoked even if the xOpen reported that it failed. The
1070 ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
1073 ** flag may be ORed in to indicate that only the data of the file
1074 ** and not its inode needs to be synced.
1095 ** write return values. Potential uses for xFileControl() might be
1106 ** minimum write that can be performed without disturbing
1157 /* Additional methods may be added in future releases */
1172 ** is used during testing and only needs to be supported when SQLITE_TEST
1183 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
1199 ** The value of the iVersion field is initially 1 but may be larger in
1200 ** future versions of SQLite. Additional fields may be appended to this
1224 ** be unique across all VFS modules.
1229 ** the string will be valid and unchanged until xClose() is
1235 ** xFilename parameter is NULL it will also be the case that the
1243 ** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set.
1262 ** also be no-ops, and any attempt to read the journal would return
1264 ** file will be doing page-aligned sector reads and writes in a random
1274 ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
1276 ** will be set for TEMP databases, journals and for subjournals.
1283 ** be created, and that it is an error if it already exists.
1284 ** It is <i>not</i> used to indicate the file should be opened
1294 ** element will be valid after xOpen returns regardless of the success
1297 ** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
1300 ** to test whether a file is at least readable. The file can be a
1306 ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
1342 /* New fields may be appended in figure versions. The iVersion
1349 ** These integer constants can be used as the third parameter to
1386 ** is not. The sqlite3_shutdown() interface must only be called from a
1387 ** single thread. All open [database connections] must be closed and all
1388 ** other SQLite resources must be deallocated prior to invoking
1403 ** calls sqlite3_initialize() so the SQLite library will be automatically
1404 ** initialized when [sqlite3_open()] is called if it has not be initialized
1455 ** may only be invoked prior to library initialization using
1459 ** Note, however, that ^sqlite3_config() can be called as part of the
1464 ** what property of SQLite is to be configured. Subsequent arguments
1482 ** sqlite3_db_config() interface should only be used immediately after
1490 ** New verbs are likely to be added in future releases of SQLite.
1528 ** xRealloc must be a no-op - it must not perform any allocation or
1533 ** still be in compliance with this specification.
1537 ** is always at least as big as the requested size but may be larger.
1539 ** The xRoundup method returns what would be the allocated size of
1555 ** the xInit method, so the xInit method need not be threadsafe. The
1557 ** not need to be threadsafe either. For all other methods, SQLite
1562 ** methods must be threadsafe or else make their own arrangements for
1585 ** can be passed as the first argument to the [sqlite3_config()] interface.
1587 ** New configuration options may be added in future releases of SQLite.
1588 ** Existing configuration options might be discontinued. Applications
1598 ** all mutexing and puts SQLite into a mode where it can only be used
1612 ** are enabled so that SQLite will be safe to use in a multi-threaded
1639 ** alternative low-level memory allocation routines to be used in place of
1648 ** This option can be used to overload the default memory allocation
1671 ** aligned memory buffer from which the scrach allocations will be
1674 ** argument must be a multiple of 16. The sz parameter should be a few bytes
1676 ** The first argument must be a pointer to an 8-byte aligned buffer
1679 ** N should be set to the expected maximum number of threads. ^SQLite will
1683 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
1688 ** This configuration should not be used if an application-define page
1692 ** The sz argument should be the size of the largest database page
1704 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
1705 ** will be undefined.</dd>
1719 ** The first pointer (the memory pointer) must be aligned to an 8-byte
1720 ** boundary or subsequent behavior of SQLite will be undefined.</dd>
1725 ** alternative low-level mutex routines to be used in place
1739 ** This option can be used to overload the default mutex allocation
1754 ** verb to [sqlite3_db_config()] can be used to change the lookaside
1792 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
1794 ** New configuration options may be added in future releases of SQLite.
1795 ** Existing configuration options might be discontinued. Applications
1808 ** may be NULL in which case SQLite will allocate the
1811 ** slots. The size of the buffer in the first argument must be greater than
1813 ** must be aligned to an 8-byte boundary. ^If the second argument to
1863 ** be successful even if it is subsequently rolled back.
1916 ** the sqlite3_changes() interface can be called to find the number of
1973 ** to be interrupted and might continue to completion.
1978 ** will be rolled back automatically.
2003 ** appears to be a complete SQL statement. ^A statement is judged to be
2020 ** then the return value from sqlite3_complete16() will be non-zero
2023 ** The input to [sqlite3_complete()] must be a zero-terminated
2026 ** The input to [sqlite3_complete16()] must be a zero-terminated
2035 ** ^This routine sets a callback function that might be invoked whenever
2041 ** is not NULL, then the callback might be invoked with two arguments.
2052 ** The presence of a busy handler does not guarantee that it will be invoked
2076 ** cache will be left in an inconsistent state and so the error
2084 ** ^(There can only be a single busy handler defined for each
2111 ** ^(There can only be a single busy handler for a particular
2127 ** numbers are obtained separately. Let N be the number of rows
2128 ** and M be the number of columns.
2139 ** A result table should be deallocated using [sqlite3_free_table()].
2189 const char *zSql, /* SQL to be evaluated */
2205 ** The strings returned by these two routines should be
2215 ** historical accident that cannot be fixed without breaking
2219 ** the number of characters written would be a more useful return
2226 ** the zero terminator. So the longest string that can be completely
2227 ** written will be n-1 characters.
2237 ** character it escapes that character and allows it to be inserted into
2310 ** that it might be reused. ^The sqlite3_free() routine is
2313 ** should neither be read nor written. Even reading previously freed
2320 ** prior memory allocation to be at least N bytes, where N is the
2321 ** second parameter. The memory allocation to be resized is the first
2341 ** implementation of these routines to be omitted. That capability
2342 ** is no longer provided. Only built-in memory allocators can be used.
2353 ** must be either NULL or else pointers obtained from a prior
2423 ** specific action but allow the SQL statement to continue to be
2424 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2439 ** the particular action to be authorized. ^The third through sixth parameters
2441 ** details about the action to be authorized.
2448 ** return can be used to deny an untrusted user access to individual
2460 ** not want the user to be able to make arbitrary changes to the
2461 ** database. An authorizer could then be put in place while the
2470 ** ^(Only a single authorizer can be in place on a database connection
2481 ** statement might be re-prepared during [sqlite3_step()] due to a
2516 ** the authorizer callback may be passed.
2518 ** These action code values signify what kind of operation is to be
2520 ** callback function will be parameters or NULL depending on which of these
2567 ** These routines register callback functions that can be used for
2597 ** interrupted. This feature can be used to implement a
2617 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2620 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
2624 ** ^The default encoding for the database will be UTF-8 if
2629 ** associated with the [database connection] handle should be released by
2668 ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2683 ** on-disk database will be created. ^This private database will be
2692 ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
2694 ** characters must be converted to UTF-8 prior to passing them into
2728 ** However, the error string might be overwritten or deallocated by
2731 ** When the serialized [threading mode] is in use, it might be the
2734 ** When that happens, the second error will be reported since these
2743 ** error code and message may or may not be set.
2779 ** ^(This interface allows the size of various constructs to be limited
2781 ** [database connection] whose limit is to be set or queried. The
2783 ** class of constructs to be size limited. The third parameter is the
2797 ** by untrusted external sources. An example application might be a
2800 ** off the Internet. The internal databases can be given the
2802 ** be given much smaller limits designed to prevent a denial of service
2805 ** created by an untrusted script can be contained using the
2808 ** New run-time limit categories may be added in future releases.
2817 ** that can be lowered at run-time using [sqlite3_limit()].
2855 ** be bound.</dd>)^
2877 ** To execute an SQL query, it must first be compiled into a byte-code
2884 ** The second argument, "zSql", is the statement to be compiled, encoded
2895 ** performance advantage to be gained by passing an nByte parameter that
2904 ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
2910 ** ppStmt may not be NULL.
2946 ** change the query plan for a statement, then the statement may be
2985 ** ^This interface can be used to retrieve a saved copy of the original
2996 ** that can be stored in a database table. SQLite uses dynamic typing
2998 ** can be integers, floating point values, strings, BLOBs, or NULL.
3000 ** An sqlite3_value object may be either "protected" or "unprotected".
3009 ** sqlite3_value object. If SQLite is compiled to be single-threaded
3014 ** sqlite3_value objects and they can be used interchangeably. However,
3023 ** Unprotected sqlite3_value objects may only be used with
3050 ** literals may be replaced by a [parameter] that matches one of following
3064 ** can be set using the sqlite3_bind_*() routines defined here.
3070 ** ^The second argument is the index of the SQL parameter to be set.
3074 ** ^The index for named parameters can be looked up using the
3077 ** ^The NNN value must be between 1 and the [sqlite3_limit()]
3083 ** number of bytes in the parameter. To be clear: the value is the
3092 ** information is in static, unmanaged space and does not need to be freed.
3136 ** ^This routine can be used to find the number of [SQL parameters]
3145 ** there may be gaps in the list.)^
3187 ** name must be given in UTF-8 even if the original statement
3247 ** ^The name of the database or table or column can be returned as
3306 ** and the following statement to be compiled:
3329 ** must be called one or more times to evaluate the statement.
3336 ** interface will continue to be supported.
3338 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
3341 ** [extended result codes] might be returned as well.
3351 ** successfully. sqlite3_step() should not be called again on this virtual
3357 ** caller. The values may be accessed using the [column access functions].
3361 ** violation) has occurred. sqlite3_step() should not be called again on
3362 ** the VM. More information may be found by calling [sqlite3_errmsg()].
3365 ** can be obtained by calling [sqlite3_reset()] on the
3373 ** be the case that the same database connection is being used by two or
3441 ** should be returned. ^The leftmost column of the result set has the index 0.
3442 ** ^The number of columns in the result can be determined using
3447 ** These routines may only be called when the most recent call to
3489 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
3532 ** sqlite3_column_text16() may be invalidated.
3539 ** need to be added to the string.</li>
3541 ** sqlite3_column_text16() is called. The content must be converted
3544 ** sqlite3_column_text() is called. The content must be converted
3548 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
3603 ** ^This routine can be called at any point during the execution of the
3607 ** ^Incomplete updates may be rolled back and transactions canceled,
3609 ** [error code] returned will be [SQLITE_ABORT].
3617 ** object back to its initial state, ready to be re-executed.
3653 ** function is to be added. ^If an application uses more than one database
3654 ** connection then application-defined SQL functions must be added
3657 ** The second parameter is the name of the SQL function to be created or
3673 ** its parameters. Any SQL function implementation should be able to work
3674 ** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
3681 ** encoding is used, then the fourth argument should be [SQLITE_ANY].
3689 ** callback only; NULL pointers should be passed as the xStep and xFinal
3691 ** and xFinal and NULL should be passed for xFunc. ^To delete an existing
3707 ** ^Built-in functions may be overloaded by new application-defined functions.
3759 ** to be supported. However, new applications should avoid
3810 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
3814 ** These routines must be called from the same thread as
3846 ** In those cases, sqlite3_aggregate_context() might be called for the
3861 ** The first parameter must be a copy of the
3866 ** This routine must be called from the same thread in which
3880 ** This routine must be called from the same thread in which
3899 ** The following two functions may be used by scalar SQL functions to
3902 ** some circumstances the associated metadata may be preserved. This may
3903 ** be used, for example, to add a regular-expression matching scalar
3906 ** pattern. The compiled regular expression can be reused on multiple
3908 ** does not need to be recompiled on each invocation.
3929 ** the destructor will be called before the metadata is dropped.
3935 ** These routines must be called from the same thread in which
3948 ** and will never change. It does not need to be destroyed. ^The
3973 ** an application-defined function to be the BLOB whose content is pointed
3978 ** the application-defined function to be a BLOB containing all zero
3982 ** an application-defined function to be a floating point value specified
4014 ** of the application-defined function to be the 32-bit signed integer
4017 ** of the application-defined function to be the 64-bit signed integer
4021 ** of the application-defined function to be NULL.
4025 ** set the return value of the application-defined function to be
4052 ** the application-defined function to be a copy the
4056 ** be deallocated after sqlite3_result_value() returns without harm.
4057 ** ^A [protected sqlite3_value] object may always be used where an
4059 ** kind of [sqlite3_value] object can be used with this interface.
4093 ** ^The third argument may be one of the constants [SQLITE_UTF8],
4095 ** routine expects to be passed pointers to strings encoded using UTF-8,
4097 ** third argument might also be [SQLITE_UTF16] to indicate that the routine
4098 ** expects pointers to be UTF-16 strings in the native byte order, or the
4099 ** argument can be [SQLITE_UTF16_ALIGNED] if the
4103 ** A pointer to the user supplied routine must be passed as the fifth
4155 ** can be used, a single callback function may be registered with the
4156 ** [database connection] to be invoked whenever an undefined collation
4189 ** Specify the key for an encrypted database. This routine should be
4196 sqlite3 *db, /* Database to be rekeyed */
4209 sqlite3 *db, /* Database to be rekeyed */
4220 ** millisecond time resolution, then the time will be rounded up to
4235 ** will be placed in that directory.)^ ^If this variable
4243 ** It is intended that this variable be set once
4254 ** Hence, if this variable is modified directly, either it should be
4256 ** or else the use of the [temp_store_directory pragma] should be avoided.
4273 ** transaction might be rolled back automatically. The only way to
4306 ** connection and in particular must not be a NULL pointer.
4314 ** function to be invoked whenever a transaction is [COMMIT | committed].
4318 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
4332 ** to modify the database connection must be deferred until after the
4344 ** hook returning non-zero, just as it would be with any other rollback.
4364 ** to be invoked whenever a row is updated, inserted or deleted.
4374 ** to be invoked.
4392 ** to modify the database connection must be deferred until after the
4448 ** which might be more or less than the amount requested.
4456 ** on the amount of heap memory that may be allocated by SQLite.
4466 ** [sqlite3_release_memory()] will only be called when memory is exhausted.
4470 ** But if the soft heap limit cannot be honored, execution will
4500 ** may be NULL.
4503 ** and subsequent parameters to this function. ^Any of these arguments may be
4540 ** cannot be found, an [error code] is returned and an error message left
4541 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
4567 ** ^zProc may be 0, in which case the name of the entry point
4577 ** ^Extension loading must be enabled using
4579 ** otherwise an error will be returned.
4608 ** ^This API can be invoked at program startup in order to register
4609 ** one or more statically linked extensions that will be available
4641 ** to be experimental. The interface might change in incompatible ways.
4721 ** expr on the right-hand side can be evaluated (and thus the constraint
4737 ** is true, then the constraint is assumed to be fully handled by the
4791 ** ^Module names must be registered before
4801 ** when a new virtual table is be being created or reinitialized.
4832 ** be tailored to the specific needs of the module implementation.
4840 ** is delivered up to the client application, the string will be automatically
4841 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
4891 ** must exist in order to be overloaded.)^
4896 ** of the new function always causes an exception to be thrown. So
4898 ** purpose is to be a placeholder function that can be overloaded
4906 ** to be experimental. The interface might change in incompatible ways.
4920 ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
4924 ** can be used to read or write small subsections of the BLOB.
4934 ** in other words, the same BLOB that would be selected by:
4954 ** to be a null pointer.)^
4973 ** the opened blob. ^The size of a blob may not be changed by this
4978 ** and the built-in [zeroblob] SQL function can be used, if desired,
4983 ** be released by a call to [sqlite3_blob_close()].
5003 ** ^If any writes were made to the BLOB, they might be held in cache
5014 ** ^Calling this routine with a null pointer (such as would be returned
5045 ** can be determined using the [sqlite3_blob_bytes()] interface.
5079 ** can be determined using the [sqlite3_blob_bytes()] interface.
5107 ** New VFSes can be registered and existing VFSes can be unregistered.
5118 ** ^The same VFS can be registered multiple times without injury.
5169 ** that means that a mutex could not be allocated. ^SQLite
5212 ** dynamic mutex that it allocates. The dynamic mutexes must not be in
5222 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
5224 ** mutex must be exited an equal number of times before another thread
5266 ** Additionally, an instance of this structure can be used as an
5304 ** The xMutexInit() method must be threadsafe. ^It must be harmless to
5307 ** xMutexInit() must be no-ops.
5354 ** clearly the mutex cannot be held if it does not exist. But the
5373 ** next. Applications that override the built-in mutex logic must be
5406 ** ^A NULL pointer can be used in place of "main" to refer to the
5415 ** code is not remembered and will not be recalled by [sqlite3_errcode()]
5491 ** This routine is threadsafe but is not atomic. This routine can be
5508 ** that can be returned by [sqlite3_status()].
5536 ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
5559 ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
5578 ** New status parameters may be added from time to time.
5596 ** database connection object to be interrogated. ^The second argument
5614 ** These constants are the available integer "verbs" that can be passed as
5617 ** New verbs may be added in future releases of SQLite. Existing verbs
5618 ** might be discontinued. Applications should check the return code from
5639 ** be used to monitor the performance characteristics of the prepared
5647 ** object to be interrogated. The second argument
5649 ** to be interrogated.)^
5706 ** from, or ready to be written to, the database file. By implementing a
5725 ** if the application invokes this API. It can be used to clean up
5729 ** the xInit method, so the xInit method need not be threadsafe. ^The
5731 ** not need to be threadsafe either. All other methods must be threadsafe
5741 ** be allocated by the cache. ^szPage will not be a power of two. ^szPage
5742 ** will the page size of the database file that is to be cached plus an
5749 ** be used to cache database pages of a file stored on disk, or
5757 ** ^(The xCachesize() method may be called at any time by SQLite to set the
5769 ** 8-byte boundary. ^The page to be fetched is determined by the key. ^The
5771 ** is considered to be "pinned".
5792 ** attempting to unpin pages, the xFetch() method will be invoked again with
5797 ** then the page should be evicted from the cache. In this case SQLite
5799 ** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
5800 ** zero, then the page is considered to be unpinned. ^The cache implementation
5809 ** previously contains an entry associated with newKey, it should be
5811 ** to be pinned.
5817 ** they can be safely discarded.
5820 ** All resources associated with the specified cache should be freed. ^After
5866 ** continuously for the entire backup operation. ^Thus, the backup may be
5879 ** There should be exactly one call to sqlite3_backup_finish() for each
5894 ** must be different or else sqlite3_backup_init(D,N,S,M) will file with
5901 ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
5905 ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
5915 ** are still more pages to be copied, then the function resturns [SQLITE_OK].
5934 ** sqlite3_backup_step() can be retried later. ^If the source
5938 ** case the call to sqlite3_backup_step() can be retried later on. ^(If
5953 ** sqlite3_backup_step(), the source database may be modified mid-way
5956 ** used by the backup operation, then the backup will be automatically
5972 ** and may not be used following a call to sqlite3_backup_finish().
5988 ** the [sqlite3_backup] object: the number of pages still to be backed
5996 ** pages that need to be updated or the size of the source database file
6001 ** ^The source [database connection] may be used by the application for other
6004 ** connections, then the source database connection may be used concurrently
6047 ** individual tables within the shared-cache cannot be obtained. See
6049 ** ^This API may be used to register a callback that SQLite will invoke
6065 ** the first argument to register for a callback that will be invoked
6081 ** ^(There may be at most one unlock-notify callback registered by a
6087 ** unlock-notify callback may also be canceled by closing the blocked
6092 ** crash or deadlock may be the result.
6106 ** When a blocking connections transaction is concluded, there may be
6118 ** database waits for the callback to be issued before taking any further
6121 ** connection Y's transaction to be concluded, and similarly connection
6128 ** unlock-notify callback is registered. The system is said to be in
6133 ** the system is also considered to be deadlocked if connection B has
6148 ** or "DROP INDEX" query, an infinite loop might be the result.
6189 ** a few hundred characters, it will be truncated to the length of the
6239 ** The internals of this structure are intended to be opaque -- client
6253 ** Hash.htsize and Hash.ht may be zero. In that case lookup is done
6272 ** Again, this structure is intended to be opaque, but it can't really
6273 ** be opaque because it is used by macros.
6572 ** types can be conveniently redefined at compile-type. Like this:
6624 ** that can be stored in a u32 without loss of data. The value
6734 ** All variables must either be on the stack or dynamically allocated from
6768 ** However, these macros may also be used to suppress warnings related to
6769 ** parameters that may or may not be used depending on compilation options.
6847 ** needs to be revisited.
6853 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
6891 /* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the
6935 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
6951 ** should be one of the following values. The integer values are assigned
6953 ** SQLite database header may be found using the following formula:
7157 void *token; /* id that may be used to recursive triggers */
7195 ** gets freed when the Vdbe is finalized so it still should be obtained
7511 ** value means no limit. This value may be overridden using the
7697 ** and should not be accessed by other modules.
7725 ** Only clean and unpinned pages can be reclaimed.
7847 ** will defined to either 1 or 0. One of the four will be 1. The other
7848 ** three will be 0.
7907 # include <os2safe.h> /* has to be included before os2.h for linking to work */
7943 ** prematurely, old temporary files can be easily identified. This can be done
7946 ** 2006-10-31: The default prefix used to be "sqlite_". But then
7952 ** For this reason, the default name prefix is changed to be "sqlite"
7963 ** The following values may be passed as the second argument to
7971 ** SHARED locks may be obtained by other processes.
7974 ** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a
7976 ** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to
7998 ** There can only be one writer. A RESERVED_LOCK is obtained by locking
8124 ** mutexes implemention cannot be overridden
8129 ** implementation can be overridden at
8174 ** Each database file to be accessed by the system is an instance
8178 ** databases may be attached.
8216 ** These macros can be used to test, set, or clear bits in the
8232 ** changes and so the view will need to be reset.
8239 ** The number of different kinds of things that can be limited
8245 ** Lookaside malloc is a set of fixed-size buffers that can be used
8259 ** be stored in lookaside because in shared cache mode the schema information
8293 ** trigger has its own context, so that lastRowid can be updated inside
8294 ** triggers as usual. The previous value will be restored once the trigger
8452 ** These must be the low-order bits of the flags field.
8497 #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
8609 ** collating sequence may not be read or written.
8629 ** A sort order can be either ASC or DESC.
8643 ** used as the P4 operand, they will be more readable.
8663 ** Additional bit values that can be ORed with an affinity without
8678 ** implementation. sqlite3_vtab* handles can not be shared between
8685 ** transaction, these accesses need to be made via the same database
8733 ** that the datatype of the PRIMARY KEY must be INTEGER for this field to
8734 ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of
8794 ** done as a macro so that it will be optimized out when virtual
8845 ** to be rolled back. ABORT processing means the operation in process
8920 #define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */
8930 ** The columns of the table that are to be indexed are described
8941 ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].
8942 ** The second column to be indexed (c1) has an index of 0 in
8946 ** must be unique and what to do if they are not. When Index.onError=OE_None,
9006 ** fields do not need to be freed when deallocating the AggInfo structure.
9060 ** as opcodes here. For example, the parser defines TK_GE to be an integer
9072 ** binary operator. Either or both may be NULL.
9087 ** it can be accessed after all aggregates are computed.
9106 ** help reduce memory requirements, sometimes an Expr object will be
9108 ** two or more Expr objects will be stored in a single memory allocation,
9200 ** These macros can be used to test, set, or clear bits in the
9225 ** name. An expr/name combination can be used in several ways, such
9228 ** also be used as the argument to a function, in which case the a.zName
9301 ** can also be used to describe a particular table such as the table that
9303 ** such a table must be a simple name: ID. But in SQLite, the table can
9304 ** now be identified by a database name, a dot, then the table name: ID.ID.
9348 ** This object is intended to be opaque outside of the where.c module.
9350 ** is. None of the fields in this object should be used outside of
9371 ** is intended to be private the the where.c module and should not be
9451 ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or
9456 ** NameContexts can be nested. When resolving names, the inner-most
9493 ** These addresses must be stored so that we can go back and fill in
9495 ** the number of columns in P2 can be computed at the same time
9525 #define SF_Distinct 0x0001 /* Output should be DISTINCT */
9534 ** The results of a select can be distributed in several ways. The
9590 ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
9657 u8 tempReg; /* iReg is a temp register that needs to be freed */
9722 ** An instance of the following structure can be declared on a stack and used
9723 ** to save the Parse.zAuthContext value so that it can be restored later.
9736 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
9746 * database). This allows Trigger structures to be retrieved by name.
9760 Expr *pWhen; /* The WHEN clause of the expression (may be NULL) */
9774 ** In that cases, the constants below can be ORed together.
9798 * this stores values to be inserted. Otherwise NULL.
9800 * statement, then this stores the column-names to be
9845 ** do not necessarily know how big the string will be in the end.
9848 sqlite3 *db; /* Optional database for lookaside. Can be NULL */
9896 /* The above might be initialized to non-zero. The following need to always
9897 ** initially be zero, however. */
10030 ** that deal with sqlite3StackAlloc() failures to be unreachable.
10323 ** be defined locally, but now we use the varint routines in the util.c
10537 ** Available fault injectors. Should be numbered beginning with 0.
10692 ** is (x - 0x20). Therefore toupper() can be implemented as:
10699 ** Bit 0x40 is set if the character non-alphanumeric and can be used in an
10774 /* All the rest should always be initialized to zero */
10795 ** The value of the "pending" byte must be 0x40000000 (1 byte past the
10804 ** than 1 GiB. The sqlite3_test_control() interface can be used to
10972 ** This implemention requires years to be expressed as a 4-digit number
10974 ** be represented, even though julian day numbers allow a much wider
11130 ** The HH, MM, and SS must each be exactly 2 digits. The
11131 ** fractional seconds FFFF can be one or more digits.
11278 ** (":SS.FFF") is option. The year and date can be omitted as long
11279 ** as there is a time string. The time string can be omitted as long
11579 ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be
12021 ** functions. This should be the only routine in this file with
12100 ** of this would be completely automatic if SQLite were coded using
12165 /* 0x7f1f is a mask of SQLITE_OPEN_ flags that are valid to be passed
12250 ** error in sqlite3_os_init() by the upper layers can be tested.
12455 ** are merely placeholders. Real drivers must be substituted using
12533 ** cases of nByte<=0 will be intercepted and dealt with by higher level
13143 ** be changed.
13183 ** u.hdr.prevSize can be part of the data for that chunk and should
13184 ** not be read or written.
13340 ** will already be held (obtained by code in malloc.c) if
13430 ** this mem3.iMaster replacement to work, the master chunk must be
13792 ** is not required to be threadsafe (it is not).
13832 ** be changed.
13850 ** Let n be the size of the largest allocation divided by the minimum
13852 ** be the maximum amount of memory ever outstanding at one time. Let
13853 ** N be the total amount of memory available for allocation. Robson
13874 ** The size of this object must be a power of two. That fact is
13908 u8 *zPool; /* Memory available to be allocated */
13955 ** on. It should be found on mem5.aiFreelist[iLogsize].
13997 ** will already be held (obtained by code in malloc.c) if
14049 ** threads can be in this routine at the same time.
14057 /* nByte must be a positive */
14229 ** the allocation is too large to be handled by this allocation system,
14232 ** All allocations must be a power of two and must be expressed by a
14262 ** This routine is not threadsafe. The caller must be holding a mutex
14277 /* The size of a Mem5Link object must be a power of two. Verify that
14497 ** until it can be obtained.
14507 ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
14644 ** that means that a mutex could not be allocated.
14685 ** be entered multiple times by the same thread. In such cases the,
14686 ** mutex must be exited an equal number of times before another thread
14779 ** that means that a mutex could not be allocated.
14930 ** be entered multiple times by the same thread. In such cases the,
14931 ** mutex must be exited an equal number of times before another thread
15052 ** there might be race conditions that can cause these routines to
15061 ** should be compiled without -DSQLITE_DEBUG and with -DNDEBUG to
15083 ** that means that a mutex could not be allocated. SQLite
15190 ** be entered multiple times by the same thread. In such cases the,
15191 ** mutex must be exited an equal number of times before another thread
15201 ** is atomic - that it cannot be deceived into thinking self
15241 ** is atomic - that it cannot be deceived into thinking self
15443 ** (which should be the last to shutdown.) */
15459 ** that means that a mutex could not be allocated. SQLite
15543 ** be entered multiple times by the same thread. In such cases the,
15544 ** mutex must be exited an equal number of times before another thread
15701 ** be held while the callback is running. Recursive calls into
15702 ** the memory subsystem are allowed, but no new callbacks will be
15921 ** Allocate memory that is to be used and released right away.
15923 ** for situations where the memory might be held long-term. This
15936 ** would be much more complicated.) */
15986 ** would be much more complicated.) */
16061 ** Free memory that might be associated with a particular database
16301 ** This function must be called before exiting any API function (i.e.
16332 ** completeness. They are very out-of-date but might be useful as
16362 ** * The "=" flag (similar to "-") causes the output to be
16363 ** be centered in the appropriately sized field.
16517 ** SQLITE_PRINT_BUF_SIZE to be less than 350.
16534 ** 2. A pointer to the list of characters to be output
16536 ** 3. An integer number of characters to be output.
16537 ** (Note: This number might be zero.)
16539 ** arg This is the pointer to anything which will be passed as the
16586 etByte flag_dp; /* True if decimal point should be shown */
16587 etByte flag_rtz; /* True if trailing zeros should be removed */
17195 ** the string and before returnning. This routine is intended to be used
17273 ** allocate memory because it might be called while the memory allocator
17368 ** must be held while executing this routine.
17373 ** well be good enough. But maybe not. Or maybe lrand48() has some
17534 ** VDBE. This information used to all be at the top of the single
17543 ** SQL is translated into a sequence of instructions to be
17601 ** be NULL.
17683 ** No other flags may be set in this case.
17704 ** the following flags must be set to determine the memory management
17732 ** that can be associated with a constant argument to a function. This
17824 u8 expired; /* True if the VM needs to be recompiled */
18039 ** be encoded as a multi-byte character. Any multi-byte character that
18042 ** * This routine never allows a UTF16 surrogate value to be encoded.
18245 ** The allocation (static, dynamic etc.) and encoding of the Mem may be
18314 ** correct UTF-8 encoding to be longer than a malformed encoding).
18336 ** be freed by the calling function.
18384 ** in pZ. nChar must be non-negative.
18512 ** This option [-ffast-math] should never be turned on by any
18539 ** Compute a string length that is limited to what can be stored in
18542 ** The value returned will never be negative. Nor will it ever be greater
18544 ** than 1GiB) the value returned might be less than the true string length.
18562 ** %z A string that should be freed after use
18567 ** zFormat and any string tokens that follow it are assumed to be
18571 ** should be called with err_code set to SQLITE_OK and zFormat set
18595 ** %z A string that should be freed after use
18600 ** This function should be used to report any error that occurs whilst
18604 ** Function sqlite3Error() should be used during statement execution
18630 ** The input string must be zero-terminated. A new zero-terminator
18699 ** false does not mean that the number can be successfully converted into
18700 ** an integer - it might be too big.
18845 /* 1.0e+22 is the largest power of 10 than can be
18896 ** or is an integer that is too large to be expressed with 64 bits,
18932 /* 19-digit numbers must be no larger than 9223372036854775807 if positive
18971 /* Guaranteed to be too big if greater than 19 digits */
18985 ** input number to be zero-terminated.
19041 ** The length of data write will be between 1 and 9 bytes. The number
19317 ** rare larger cases can be handled by the slower 64-bit varint
19387 ** Return the number of bytes that will be needed to store the given
19437 ** binary value has been obtained from malloc and must be freed by
19473 ** 1 it means that the db pointer is valid and 0 if it should not be
19477 ** sqlite3SafetyCheckOk() requires that the db pointer be valid for
19479 ** open properly and is not fit for general use but which can be
19531 ** "pNew" is a pointer to the hash table that is to be initialized.
19582 HashElem *pNew /* The element to be inserted */
19650 const Hash *pH, /* The pH to be searched */
19680 HashElem* elem, /* The element to be removed from the pH */
19982 ** be exercised on Linux (which does not need to malloc() in the driver)
20020 ** This file should be #included by the os_*.c files only. It is not a
20089 ** processor and returns that value. This can be used for high-res
20290 /* Unread portions of the input buffer must be zero-filled */
20302 const void *pBuf, /* The bytes to be written */
20556 /* If we are holding a PENDING lock that ought to be released, then
20626 ** must be either NO_LOCK or SHARED_LOCK.
20656 /* This should never happen. We should always be able to
20703 ** the specified file. This is almost always 512 bytes, but may be
20708 ** a database and its journal file) that the sector size will be the
20755 ** The returned char pointer has to be freed.
20771 /* conversion for current codepage which can be used for paths */
20781 ** The returned char pointer has to be freed.
20783 ** This function is non-static to be able to use this in shell.c and
20796 /* conversion for current codepage which can be used for paths */
20833 ** Create a temporary file name in zBuf. zBuf must be big enough to
20888 ** pathname into zFull[]. zFull[] will be at least pVfs->mxPathname
21110 * symbol with an extra underscore, that might be needed depending
21196 ** might be greater than or equal to the argument, but not less
21215 ** return 0. Return 1 if the time and date cannot be found.
21219 SHORT minute; /* needs to be able to cope with negative timezone offset */
21317 ** KEEP THE STRUCTURE OF THIS FILE INTACT. New code should be placed
21318 ** in the correct division and should be clearly labeled.
21381 ** large file support, these should be no-ops.
21383 ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
21394 ** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
21427 ** If we are to be thread-safe, include the pthreads header and define
21462 ** cannot be closed immediately. In these cases, instances of the following
21545 ** This file should be #included by the os_*.c files only. It is not a
21614 ** processor and returns that value. This can be used for high-res
21767 ** lacks the fcntl() system call. So redefine fcntl() to be something
21789 ** vxworksFileId objects used by this file, all of which may be
21964 ** On VxWorks, a unique file id must be based on the canonical filename.
21966 ** A pointer to an instance of the following structure can be used as a
22164 ** be closed and that list is walked (and cleared) when the last lock
22171 ** A cannot be modified or overridden by a different thread B.
22194 ** not allow locks to be overridden by other threads and that restriction
22195 ** means that sqlite3* database handles cannot be moved from one thread
22198 ** Version 3.3.1 (2006-01-15): unixFile can be moved from one thread to
22201 ** or if no locks are held. But the unixFile.pLock field needs to be
22268 ** file descriptor to be closed to the pending list.
22288 ** Lists of all unixLockInfo and unixOpenCnt objects. These used to be hash
22306 ** will be set appropriately. On other systems, we have to check at
22330 int fd; /* File to be locked */
22391 ** The mutex entered using the unixEnterMutex() function must be held
22418 ** The mutex entered using the unixEnterMutex() function must be held
22456 ** return values might be uninitialized if an error occurs.
22458 ** The mutex entered using the unixEnterMutex() function must be held
22497 ** an ASCII 'S' character which also happens to be the first byte
22679 ** The "op" parameter should be one of F_RDLCK, F_WRLCK, or F_UNLCK.
22699 ** of bytes to be read or written, we give hints to NFS to help it
22762 ** slightly in order to be compatible with windows systems simultaneously
22779 ** on the 'pending byte'. This ensures that no new SHARED locks can be
22791 ** The reason a single byte cannot be used instead of the 'shared byte
22868 ** be released.
23033 ** must be either NO_LOCK or SHARED_LOCK.
23163 ** even on VxWorks. A mutex will be acquired on VxWorks by the
23214 ** descriptor to pOpen->pUnused list. It will be automatically closed
23239 ** also be used if the application employs some external mechanism to
23282 ** sitting around that need to be cleared manually.
23406 ** must be either NO_LOCK or SHARED_LOCK.
23478 ** only a single process can be reading the database at a time.
23590 /* didn't get, must be busy */
23612 ** must be either NO_LOCK or SHARED_LOCK.
23630 /* shared can just be set because we always have an exclusive */
23787 ** must be either NO_LOCK or SHARED_LOCK.
23807 /* shared can just be set because we always have an exclusive */
23890 const char *path, /* Name of the file to be locked or unlocked */
23892 unsigned long long offset, /* First byte to be locked */
24037 ** be released.
24138 ** must be either NO_LOCK or SHARED_LOCK.
24210 ** descriptor to pOpen->aPending. It will be automatically closed when
24249 ** be necessary to define _XOPEN_SOURCE to be 500. This varies from
24304 ** file), the bytes in the locking range should never be read or written. */
24318 /* Unread parts of the buffer must be zero-filled */
24377 ** file), the bytes in the locking range should never be read or written. */
24435 ** Others do no. To be safe, we will stick with the (slower) fsync().
24518 ** It shouldn't be possible for fullfsync to fail on the local
24522 ** It'd be better to detect fullfsync support once and avoid
24694 ** it hence it is OK for the transaction change counter to be
24714 ** the specified file. This is almost always 512 bytes, but may be
24719 ** a database and its journal file) that the sector size will be the
24746 ** field of the sqlite3_vfs VFS objects are initialized to be pointers to
24764 ** from be cast into a function pointer.
24936 ** that does not need to be locked. */
24986 ** that does not need to be locked. */
25084 ** descriptors on this file, then no malloc would be required by
25086 ** handle h - as it is guaranteed that no posix locks will be released
25101 /* AFP locking uses the file path so it needs to be included in
25122 /* Dotfile locking uses the file path so it needs to be included in
25139 /* Named semaphore locking uses the file path so it needs to be
25211 ** Create a temporary file name in zBuf. zBuf must be allocated
25212 ** by the calling process and must be big enough to hold at least
25287 ** but the associated file descriptor could not be closed because some
25355 ** true, the file was configured to be automatically deleted when the
25362 const char *zPath, /* Pathname of file to be opened */
25363 sqlite3_file *pFile, /* The file descriptor to be filled in */
25383 ** is called the directory file descriptor will be fsync()ed and close()d.
25397 ** (a) Exactly one of the READWRITE and READONLY flags must be set, and
25398 ** (b) if CREATE is set, then READWRITE must also be set, and
25399 ** (c) if EXCLUSIVE is set, then CREATE must also be set.
25400 ** (d) if DELETEONCLOSE is set, then CREATE must also be set.
25445 ** open(). These must be calculated even if open() is not called, as
25446 ** they may be stored as part of the file handle and used by the
25498 ** to be open on a database file. If it were open on a database file,
25499 ** it would not be safe to close as this would release any locks held
25567 const char *zPath, /* Name of file to be deleted */
25705 ** GCC with -pedantic-errors says that C90 does not allow a void* to be
25710 ** Variable x below is defined to be a pointer to a function taking
25746 ** prefer that the randomness be increased by making use of the
25784 ** might be greater than or equal to the argument, but not less
25820 ** return 0. Return 1 if the time and date cannot be found.
25929 ** host ID in it, the proxy path in the conch file will be used, otherwise
25931 ** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the
25936 ** The lock path will be "<tmpdir>/sqliteplocks/_Users_me_foo.db:auto:")
25939 ** be removed, however it may be switched to a different proxy path via
25986 ** to be created the first time they are used.
26020 ** force proxy locking to be used for every database file opened, and 0
26021 ** will force automatic proxy locking to be disabled for all database
26100 /* writes the host id path to path, path should be an pre-allocated buffer
26315 ** lockPath means that the lockPath in the conch file will be used if the
26316 ** host IDs match, or a new lock path will be generated automatically
26735 ** will be performed on the local proxy lock file. The following fields
26736 ** are preserved in the locking context so that they can be restored and
26922 ** must be either NO_LOCK or SHARED_LOCK.
26996 ** should be the only routines in this file that are visible from other
27002 ** should not be used.
27051 ** array cannot be const.
27133 ** be exercised on Linux (which does not need to malloc() in the driver)
27177 ** This file should be #included by the os_*.c files only. It is not a
27246 ** processor and returns that value. This can be used for high-res
27415 const sqlite3_io_methods *pMethod;/* Must be first */
27640 /* This will never be called, but defined to make the code compile */
27703 ** must be zero-initialized */
27722 /* If shared memory could not be created, then close the mutex and fail */
28011 /* Unread parts of the buffer must be zero-filled */
28023 const void *pBuf, /* The bytes to be written */
28271 /* Try 3 times to get the pending lock. The pending lock might be
28330 /* If we are holding a PENDING lock that ought to be released, then
28379 ** must be either NO_LOCK or SHARED_LOCK.
28400 /* This should never happen. We should always be able to
28437 ** the specified file. This is almost always 512 bytes, but may be
28442 ** a database and its journal file) that the sector size will be the
28487 ** is obtained from malloc and must be freed by the calling
28506 ** Create a temporary file name in zBuf. zBuf must be big enough to
28774 ** Note that windows does not allow a file to be deleted if some other
28778 ** file open, we will be unable to delete it. To work around this
28872 ** pathname into zOut[]. zOut[] will be at least pVfs->mxPathname
29124 ** return 0. Return 1 if the time and date cannot be found.
29184 ** it should be truncated. The return value of xGetLastError
29199 ** However if an error message is supplied, it will be incorporated
29271 ** may be set or cleared one at a time.
29279 ** but can be as large as 2 billion for a really big database.
29286 ** it will be aligned within the Bitvec struct. */
29290 ** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE.
29340 ** this would be 125. */
29344 /* For a BITVEC_SZ of 512, this would be 34,359,739. */
29400 ** This routine might cause sub-bitmaps to be allocated. Failing
29476 ** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage
29537 ** Let V[] be an array of unsigned characters sufficient to hold
29538 ** up to N bits. Let I be an integer between 0 and N. 0<=I<N.
29539 ** Then the following macros can be used to set, clear, or test
29583 /* Allocate the Bitvec to be tested and a linear array of
29816 ** The caller discovers how much space needs to be allocated by
29967 ** Drop a page from the cache. There must be exactly one reference to the
30125 ** Since there cannot be more than 2^31 distinct pages in a database,
30126 ** there cannot be more than 31 buckets required by the merge sorter.
30149 /* To get here, there need to be 2^(N_SORT_BUCKET) elements in
30262 ** flag (bPurgeable) are set when the cache is created. nMax may be
30264 ** The global mutex must be held when accessing nMax.
30271 /* Hash table of all pages. The following variables may only be accessed
30397 ** configured soft-heap-limit to be breached, it will be possible to
30451 ** The pointer is allowed to be NULL, which is prudent. But it turns out
30493 ** The global mutex must be held when this function is called.
30537 ** The global mutex must be held when this function is called.
30565 ** The global mutex must be held when this function is called.
30598 ** The global mutex must be held when this function is called.
30645 ** not need to be freed.
30708 ** Whether or not a new page may be allocated by this function depends on
30719 ** depending on the value of parameter createFlag (which may be 0, 1 or 2).
30852 ** the head of the list (last page to be recycled). However, if the
30854 ** to the tail of the list (first page to be recycled).
30966 ** by the current thread may be sqlite3_free()ed.
31030 ** can be intermixed with tests to see if a given rowid has been
31035 ** process has started, no new elements may be inserted.
31059 ** value added by the INSERT will not be visible to the second TEST.
31067 ** has to be allocated on an INSERT.) The cost of a TEST with a new
31101 ** chunks are kept on a linked list so that they can be deallocated
31132 ** It must be the case that N is sufficient to make a Rowset. If not
31136 ** allocation of entries available to be filled.
31215 ** assumed to each already be in sorted order.
31218 struct RowSetEntry *pA, /* First sorted list to be merged */
31219 struct RowSetEntry *pB /* Second sorted list to be merged */
31348 ** as deep as it needs to be in order to contain the entire list.
31392 ** routine may not be called again.
31492 ** Writing is not permitted. There can be
31500 ** processes may still be reading the on-disk
31505 ** threads can be reading or writing while one
31513 ** will be committed.
31520 ** PAGER_RESERVED. (Note that sqlite3PagerWrite() can only be
31522 ** be in PAGER_SHARED before it transitions to PAGER_RESERVED.)
31585 ** Pager.errCode may be set to SQLITE_IOERR, SQLITE_CORRUPT, or
31591 ** APIs, they may still be used successfully.
31599 ** of pages in the database file. This may be different from Pager.dbSize
31605 ** only guaranteed to be correct if the boolean Pager.dbSizeValid is true.
31632 ** the dbModified flag is clear then less work has to be done.
31638 ** The point of this flag is that it must be set after the
31642 ** to wait for a journal sync before they can be written out to
31651 ** may be written into the journal file while the pager is still in
31654 ** fails, then SQLITE_BUSY may be returned to the user and the user
31666 ** TODO: It might be easier to set this variable in writeJournalHdr()
31777 ** to roll the journal back, the database could be corrupted. The additional
31789 ** be correct. But by initializing the checksum to random value which
31811 ** the value of MEMDB will be a constant and the compiler will optimize
31845 ** A page needs to be written into the sub-journal if there exists one
31907 ** This is so that expressions can be written as:
31929 ** can be used with this pager. The optimization can be used if:
31932 ** a database page may be written atomically, and
31940 ** If the optimization cannot be used, 0 is returned. If it can be used,
32011 ** When this is called the journal file for pager pPager must be open.
32018 ** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is
32101 ** The journal file must be open when this function is called.
32116 ** not need to be synced following this operation.
32156 ** The journal file must be open when this routine is called. A journal
32177 assert( isOpen(pPager->jfd) ); /* Journal file must be open. */
32207 ** where this risk can be ignored:
32248 ** that will be implicitly filled in by the OS).
32251 ** be significantly slower than contiguously writing data to the file,
32253 ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what
32258 ** bytes in size, more than one call to sqlite3OsWrite() may be required
32271 ** The journal file must be open when this is called. A journal header file
32283 ** If the journal header file appears to be corrupted, SQLITE_DONE is
32285 ** cannot be read from the journal file an error code is returned.
32298 assert( isOpen(pPager->jfd) ); /* Journal file must be open. */
32301 ** journal file is too small for there to be a header stored at this
32349 ** are within range. To be 'in range', both values need to be a power
32390 ** pPager at the current location. The master journal name must be the last
32455 ** will not be able to find the master-journal name to determine
32478 ** fail, since no attempt to allocate dynamic memory will be made.
32544 ** on the pager file (by this or any other process), it will be
32562 ** this happens. TODO: Really, this doesn't need to be cleared
32573 /* If Pager.errCode is set, the contents of the pager cache cannot be
32575 ** cache can be discarded and the error code safely cleared.
32591 ** This function should be called when an IOERR, CORRUPT or FULL error
32593 ** structure, the second the error-code about to be returned by a pager
32603 ** cannot be trusted. This state can be cleared by completely discarding
32606 ** to be replayed to restore the contents of the database file (as if
32632 ** to obtain a shared lock on the pager (which may be this one) will
32637 ** the pager to enter the error state. Which will be cleared by the
32651 ** either a COMMIT or a ROLLBACK operation. This routine may be called
32663 ** transaction. Nor will it be considered to be a hot-journal by this
32678 ** file. An invalid journal file cannot be rolled back.
32737 /* This branch may be executed with Pager.journalMode==MEMORY if
32739 ** file should be closed and deleted. If this connection writes to
32796 ** scenario is that one end or the other of the record will be changed.
32797 ** It is much less likely that the two ends of the journal record will be
32798 ** correct and the middle be corrupt. Thus, this "checksum" scheme,
32835 ** is successfully read from the (sub-)journal file but appears to be
32845 ** If this is a savepoint rollback, then memory may have to be dynamically
32884 ** it could cause invalid data to be written into the journal. We need to
32908 /* If the pager is in RESERVED state, then there must be a copy of this
32914 ** not be in the pager cache. Later: if a malloc() or IO error occurs
32915 ** during a Movepage() call, then the page may not be in the cache
32930 ** restore the database to its original form. Two conditions must be
32931 ** met before writing to the database files. (1) the database must be
32965 ** will be read from the database file, which may or may not be
32986 /* No page should ever be explicitly rolled back that is in use, except
32988 ** database active. However such a page may be rolled back as a result
32998 ** journal file, then its content must be as they were when the
33000 ** as clean, since there will be no need to write it out to the.
33009 ** again within this transaction, it will be marked as dirty but
33010 ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially
33011 ** be written out into the database file before its journal file
33046 ** file for a transaction involving two databases might be:
33050 ** A master journal file may only be deleted once all of its child
33061 ** If a child journal can be found that matches both of the criteria
33063 ** no such child journal can be found, file zMaster is deleted from
33072 ** the entire contents of the master journal file. This could be
33179 ** Or, it might might be the case that the file on disk is smaller than
33212 ** of the open database file. The sector size will be used used
33271 ** failure occurred while the journal was being written, it could be the
33274 ** the value of nRec computed from the file size would be too large. For
33277 ** If the nRec value is 0xffffffff it means that nRec should be computed
33280 ** in this case. But for things like temporary table (which will be
33293 ** that might be a hot journal. Or, it could be that the journal is
33321 ** present on disk, then the journal is not hot and does not need to be
33352 ** This indicates nothing more needs to be rolled back.
33380 ** chunk of the journal contains zero pages to be rolled back. But
33383 ** pages that need to be rolled back and that the number of pages
33384 ** should be computed based on the journal file size.
33420 ** so that no further harm will be done. Perhaps the next
33421 ** process to come along will be able to rollback the database.
33432 /* Following a rollback, the database file should be back in its original
33539 ** journal. The actual file might be larger than this in
33547 ** There might be records in the main journal that have a page number
33549 ** will be skipped automatically. Pages are added to pDone as they
33594 ** will be skipped. Out-of-range pages are also skipped.
33640 ** assurance that the journal will not be corrupted to the
33806 ** during rollback and will be overwritten whenever a rollback
33889 ** if the file system has to be queried for the size of the file and
33930 ** that the file can be read.
33961 /* The OS lock values must be the same as the Pager lock values */
33966 /* If the file is currently unlocked then the size must be unknown. It
33974 ** may be invoked during, according to the comment above
34004 ** be necessary to write the current content out to the sub-journal
34008 ** dirty page were to be discarded from the cache via the pagerStress()
34011 ** this happened, the correct behaviour would be to restore the current
34014 ** sub-journal rolled back the content could not be restored and the
34034 ** truncation will be done when the current transaction is committed.
34055 ** a hot journal may be left in the filesystem but no error is returned
34068 ** call which may be made from within pagerUnlockAndRollback(). If it
34070 ** be played back into the database. If a power failure occurs while
34114 ** disk and can be restored in the event of a hot-journal rollback.
34121 ** be taken.
34142 ** The Pager.needSync flag is never be set for temporary files, or any
34160 ** mode, then the journal file may at this point actually be larger
34162 ** file happens to be a journal-header (written as part of the
34204 ** for garbage data to be appended to the file, the nRec field
34206 ** and never needs to be updated.
34245 ** be NULL, representing an empty list. In this case this function is
34250 ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,
34271 ** be obtained, SQLITE_BUSY is returned.
34280 /* At this point there may be either a RESERVED or EXCLUSIVE lock on the
34300 ** is not possible for rc to be other than SQLITE_OK if this branch
34416 ** page clean, the IO error code is returned. If the page cannot be
34459 ** the database image, it may need to be written to the sub-journal.
34473 ** If (X>Y), then when pagerStress is called page X will not be written
34474 ** out to the database file, but will be dropped from the cache. Then,
34476 ** data from the database file. This will be the copy of page X as it
34482 ** be restored to its current value when the "ROLLBACK TO sp" is
34509 ** in *ppPager. The pager should eventually be freed by passing it
34514 ** and used as the file to be cached. Temporary files are be deleted
34517 ** This can be used to implement an in-memory database.
34524 ** operation of the pager. It should be passed some bitwise combination
34564 ** may be a wrapper capable of caching the first portion of the journal
34601 ** the database being opened will be more than pVfs->mxPathname
34602 ** bytes in length. This means the database cannot be opened,
34603 ** as it will not be possible to open the journal file or even
34672 ** + The largest page size that can be written atomically.
34793 ** needs to be played back. According to this function, a hot-journal
34842 ** be dealt with by the playback routine. Ticket #3883.
34867 ** If there is, then we consider this journal to be hot. If not,
34868 ** it can be ignored.
34882 ** its has a zero header, that might be due to an I/O error, or
34883 ** it might be due to the race condition described above and in
34885 ** This might be a false positive. But if it is, then the
34903 ** pPg->pData. A shared lock or greater must be held on the database
34961 ** discarded if they are found to be invalid.
35017 ** database file, then it either needs to be played back or deleted.
35049 ** exclusive-access mode the file descriptor will be kept open and
35118 ** There is a vanishingly small chance that a change will not be
35120 ** it can be neglected.
35209 ** will not be journaled. This saves IO.
35265 ** be initialized. */
35292 ** page that does not need to be journaled. Nevertheless, be sure
35394 ** There must already be a RESERVED or EXCLUSIVE lock on the database
35403 ** If the journal file is already open (as it may be in exclusive mode),
35429 ** the call to PagerPagecount() can be removed.
35494 ** functions need be called.
35505 ** within this transaction will be opened as an in-memory file. This
35506 ** has no effect if the sub-journal is already opened (as it may be when
35522 ** busy-handler callback can be used when upgrading to the EXCLUSIVE
35583 /* If an error has been previously detected, we should not be
35604 /* If we get this far, it means that the page needs to be
35658 ** playback_one_page() will think that the page needs to be restored
35668 ** transaction will be rolled back by the layer above.
35715 ** Mark a data page as writeable. This routine must be called before
35717 ** of this function and be careful not to change any page data unless
35743 ** header to be written between the pages journaled by this function.
35791 ** starting at pg1, then it needs to be set for all of them. Because
35794 ** before any of them can be written out to the database file.
35831 ** that page might be marked as dirty. This happens, for example, when
35862 ** page data. In this case the file will be updated when the current
35865 ** The isDirectMode flag may only be non-zero if the library was compiled
35957 ** of a master journal file that should be written into the individual
35958 ** journal file. zMaster may be NULL, which is interpreted as no master
35991 /* If a prior error occurred, this routine should not be called. ROLLBACK
36002 ** backup in progress needs to be restarted.
36027 ** in 'direct' mode. In this case the journal file will never be
36057 ** being discarded by the truncation must be written to the journal
36142 ** be used as a hot-journal and the current transaction rolled back.
36145 ** truncating or partially zeroing it, so that it cannot be used
36155 /* This routine should not be called if a prior error has occurred.
36160 /* This function should not be called if the pager is not in at least
36172 ** a hot-journal during hot-journal rollback, 0 changes will be made
36228 ** playback operation did not succeed it would not be safe to finalize
36229 ** the journal file. It needs to be left in the file-system so that
36304 a[8] = 0; /* Used to be pPager->nOvfl */
36381 ** The savepoint to release or rollback need not be the most recently
36419 /* Figure out how many savepoints will still be active after this
36443 ** the database file, so the playback operation can be skipped.
36520 ** There must be no references to the page previously located at
36521 ** pgno (which we call pPgOld) though that page is allowed to be
36529 ** A transaction must be active when this routine is called. It used to be
36537 ** pPg refers to will not be written to again within this transaction.
36550 /* In order to be able to rollback, an in-memory database must journal
36569 ** be possible to restore its contents when the "ROLLBACK TO one"
36587 /* If the journal needs to be sync()ed before page pPg->pgno can
36588 ** be written to, store pPg->pgno in local variable needSyncPgno.
36591 ** the journal needs to be sync()ed before database page pPg->pgno
36592 ** can be written to. The caller has already promised not to write to it.
36603 ** page pgno before the 'move' operation, it needs to be retained
36627 /* If needSyncPgno is non-zero, then the journal file needs to be
36630 ** "is journaled" bitvec flag has been set. This needs to be remedied by
36637 ** this transaction, it may be written to the database file before
36692 ** Get/set the locking-mode for this pager. Parameter eMode must be one
36714 ** Get/set the journal-mode for this pager. Parameter eMode must be one of:
36730 ** * The journal mode may not be changed while a transaction is active.
36839 ** fixed amount of payload can be carried directly on the database
36850 ** "no such page". The page size can be any power of 2 between 512 and 32768.
36851 ** Each page can be either a btree page, a freelist page, an overflow
36891 ** space in a page that can be consumed by a single cell for standard
36947 ** be easily added without having to defragment the page.
36955 ** increasing order. Because a freeblock must be at least 4 bytes in size,
36974 ** appears first. A variable-length integer may not be more than 9 bytes long.
36976 ** allows a 64-bit integer to be encoded in 9 bytes.
37026 ** small cells will be rare, but they are possible.
37040 ** header must be exactly 16 bytes including the zero-terminator so
37041 ** the string itself should be 15 characters long. If you change
37042 ** the header, then your custom library will not be able to read
37044 ** will not be able to read databases created by your custom library.
37065 ** walk up the BTree from any leaf to the root. Care must be taken to
37129 ** For some database files, the same underlying database cache might be
37137 ** The pBt pointer itself may not be changed while there exists cursors
37160 ** If the shared-data extension is enabled, there may be multiple users
37171 ** A single database file can be in use as the same time by two
37181 ** may not be modified once it is initially set as long as nRef>0.
37182 ** The pSchema field may be set once under BtShared.mutex and
37209 u8 pageSizeFixed; /* True if the page size can no longer be changed */
37256 ** this will be declared corrupt. This value is calculated based on a
37260 ** If a tree that appears to be taller than this is encountered, it is
37273 ** but cursors cannot be shared. Each cursor is associated with a
37307 ** Cursor points to a valid entry. getPayload() etc. may be called.
37318 ** this state, restoreCursorPosition() can be called to attempt to
37349 ** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be
37368 ** is moved, the pointer in its parent must be updated to point to the
37485 ** which need to be locked after p. If we cannot get a lock on
37494 ** connected by pNext and pPrev should be in sorted order by
37511 ** should already be set correctly. */
37518 /* In most cases, we should be able to acquire the lock we
37520 ** procedure that follows. Just be sure not to block.
37583 ** Btree. These entry points are used by incremental I/O and can be
37598 ** a statement since we will be comparing table and column names
37621 /* Reason for ALWAYS: There must be at least on unlocked Btree in
37679 ** if the pointer can possibly be shared with
37687 ** The number of shared btrees will always be small (usually 0 or 1)
37924 /* Figure out the root-page that the lock should be held on. For table
37959 **** This function may be used as part of assert() statements only. ****
37961 ** Return true if it would be illegal for pBtree to write into the
37993 ** SQLITE_OK if the lock may be obtained (by calling
38006 ** transaction on this file. And, obviously, for this to be so there
38007 ** must be an open write transaction on the file itself.
38018 ** requested lock may not be obtained.
38033 ** only be a single writer).
38053 ** by Btree handle p. Parameter eLock must be either READ_LOCK or
38083 /* This function should only be called on a sharable b-tree after it
38130 ** may be incorrectly cleared.
38164 ** than the writer must be about to drop to zero. In this case
38168 ** be zero already. So this next line is harmless in that case.
38235 ** table is about to be deleted. In this case invalidate all incrblob
38244 i64 iRow, /* The rowid that might be changing */
38276 ** such a page is not even journalled (as it will not be modified,
38281 ** be, if it is not at all meaningful?).
38289 ** may be lost. In the event of a rollback, it may not be possible
38330 ** Clear (destroy) the BtShared.pHasContent bitvec. This should be
38427 BtCursor *pCur, /* Cursor open on the btree to be searched */
38455 ** saved position info stored by saveCursorPosition(), so there can be
38544 /* The master-journal page number must never be used as a pointer map page */
38655 ** Within this file, the parseCell() macro can be called instead of
38656 ** btreeParseCellPtr(). Using some compilers, this will be faster.
38750 /* The value returned by this function should always be the same as
39181 /* To many cells for a single page. The page must be corrupt */
39190 ** past the end of a page boundary and causes SQLITE_CORRUPT to be
39230 /* Free blocks must be in ascending order. And the last byte of
39241 ** of the page, then the page must be corrupted. This check also
39311 ** means we have started to be concerned about content and the disk
39364 ** may remain unchanged, or it may be set to an invalid value.
39395 ** Release a MemPage. This should be called once for each prior
39425 /* pPage might not be a btree page; it might be an overflow page
39429 ** btreeInitPage() be called on every btree page so we make
39451 ** database file will be deleted when sqlite3BtreeClose() is called.
39817 ** and the database cannot be corrupted if this program
39820 ** could be left in an inconsistent and unrecoverable state.
39873 ** The page size must be a power of 2 between 512 and 65536. If the page
39877 ** Page sizes are constrained to be a power of two so that the region
39886 ** and autovacuum mode can no longer be changed.
40038 /* The maximum embedded fraction must be exactly 25%. And the minimum
40039 ** embedded fraction must be 12.5% for both leaf-data and non-leaf-data.
40041 ** version 3.6.0, we require them to be fixed.
40181 ** to access the database. A preexisting transaction may not be
40185 ** A write-transaction must be started before attempting any
40206 ** One or the other of the two processes must give way or there can be
40258 ** on page 1, the transaction cannot be opened. */
40319 ** the sub-journal is not already open, then it will be opened here.
40375 ** be modified, as follows:
40441 ** the journal needs to be sync()ed before database page pDbPage->pgno
40442 ** can be written to. The caller has already promised not to write to that
40474 ** pages need to be changed.
40478 ** the pointer map needs to be updated for the subsequent overflow page.
40535 ** incrVacuumStep() will be called a finite amount of times
40566 ** if nFin is non-zero. In that case, the free-list will be
40640 ** A write-transaction must be opened before calling this function.
40668 ** the database file should be truncated to during the commit process.
40683 Pgno nPtrmap; /* Number of PtrMap pages to be freed */
40684 Pgno iFree; /* The next page to be freed */
40734 ** causes a rollback journal to be created (if it does not already exist)
40736 ** the database can be restored to its original state by playing back
40748 ** the name of a master journal file that should be written into the
40790 ** may still be reading from the database. */
40820 ** be invoked prior to calling this routine. The sqlite3BtreeCommitPhaseOne()
40878 ** originally opened for writing and the cursor has not be disabled
40897 ** to other database connections that happen to be sharing
40901 ** All cursors using the same cache must be tripped
40905 ** save the state of the cursor. The cursor must be
40925 ** Rollback the transaction in progress. All cursors will be
40945 ** the cache may be internally inconsistent (not contain valid trees) so
40947 ** all queries that may be using any of the cursors that failed to save.
40979 ** Start a statement subtransaction. The subtransaction can can be rolled
40987 ** can be rolled back without having to rollback the entire transaction.
40993 ** iStatement is 1. This anonymous savepoint can be released or rolled back
41026 ** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the
41054 ** If wrFlag==0, then the cursor can only be used for reading.
41055 ** If wrFlag==1, then the cursor can be used for reading or for
41057 ** are the conditions that must be met in order for writing to
41058 ** be allowed:
41065 ** the changes made by this write cursor would be visible to
41068 ** 3: The database must be writable (not on read-only media)
41070 ** 4: There must be an active transaction.
41154 ** Initialize memory that will be converted into a BtCursor object.
41156 ** The simple approach here would be to memset() the entire object
41158 ** do not need to be zeroed and they are large, so we can save a lot
41175 ** or negative rowids are very uncommon so this should not be a problem.
41187 ** return value indicates that the rowid cache is invalid and should be
41318 ** It might just as well be a procedure (returning void) but we continue
41351 MemPage **ppPage, /* OUT: MemPage handle (may be NULL) */
41365 ** out to be wrong, fall back to loading the data of page
41448 ** or be scattered out on multiple overflow pages.
41456 ** Once an overflow page-list cache has been allocated, it may be
41495 /* Check if data must be read/written to/from the btree page itself. */
41599 ** "amt" bytes will be transfered into pBuf[]. The transfer
41619 ** "amt" bytes will be transfered into pBuf[]. The transfer
41651 ** into *pAmt. If *pAmt==0, then the value returned will not be
41655 ** and data to fit on the local page and for there to be no overflow
41656 ** pages. When that is so, this routine can be used to access the
41658 ** onto overflow pages, then accessPayload() must be used to reassemble
41709 ** or be destroyed on the next call to any Btree routine,
41711 ** Hence, a mutex on the BtShared should be held prior to calling
41743 ** if an intkey page appears to be the parent of a non-intkey page, or
41829 ** If this function returns successfully, it may be assumed that the
41879 /* Assert that the root page is of the correct type. This must be the
42026 ** must be NULL. For index tables, pIdxKey is used and intKey
42051 BtCursor *pCur, /* The cursor to be moved */
42098 /* pPage->nCell must be greater than zero. If this is the root-page
42102 ** be the right kind (index or table) of b-tree page. Otherwise
42139 ** page is at most 8198 bytes, which may be stored as a 2-byte
42159 ** this case the whole cell needs to be parsed, a buffer allocated
42161 ** buffer before VdbeRecordCompare() can be called. */
42230 ** TRUE will be returned after a call to sqlite3BtreeNext() moves
42384 ** locate a page close to the page number "nearby". This can be used in an
42389 ** anywhere on the free-list, then it is guarenteed to be returned. This
42418 u8 searchList = 0; /* If the free-list must be searched for 'nearby' */
42422 ** the entire-list will be searched for that page.
42675 MemPage *pPage; /* Page being freed. May be NULL. */
42746 ** usableSize/4 - 8 entries will be reported as corrupt. In order
42826 /* 0 is not a legal page number and page 1 cannot be an
42828 ** file the database must be corrupt. */
42854 ** be constructed in this temporary area then copied into pPage->aData
42880 /* pPage is not necessarily writeable since pCell might be auxiliary
43013 ** "sz" must be the number of bytes in the cell.
43095 /* The cell should normally be sized correctly. However, when moving a
43097 ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size
43098 ** might be less than 8 (leaf-size + pointer) on the interior node. Hence
43154 ** Add a list of cells to a page. The page should be initially empty.
43158 MemPage *pPage, /* The page to be assemblied */
43219 ** unbalanced. But odds are that we will be inserting new entries
43228 ** cell that will be inserted into pParent. Such a cell consists of a 4
43230 ** words, at most 13 bytes. Hence the pSpace buffer must be at
43247 ** may be inserted. If both these operations are successful, proceed.
43269 ** be marked as dirty. Returning an error code will cause a
43281 ** a variable length key value (which must be the same value as the
43423 ** The number of siblings of the page might be increased or decreased by
43427 ** might not actually be stored in MemPage.aData[]. This can happen
43431 ** In the course of balancing the page and its siblings, cells may be
43439 ** be rolled back.
43447 ** of the page-size, the aOvflSpace[] buffer is guaranteed to be large
43496 ** this overflow cell is present, it must be the cell with
43568 ** buffer. It will be copied out again as soon as the aSpace[] buffer
43623 ** that the original pages since the original pages will be in the
43703 ** right-most sibling might be nearly empty. This block of code attempts
43707 ** be so out of balance as to be illegal. For example, the right-most
43708 ** sibling might be completely empty. This adjustment is not optional.
43795 ** not be a problem.
43875 ** bytes, then it may actually be smaller than this
43920 ** (it must be, as it was just reconstructed using assemblePage()). This
43921 ** is important if the parent page happens to be page 1 of the database
43932 ** be dealt with by this routine. Some of these have been set already, but
43946 ** cells stored on the sibling pages may need to be updated.
43949 ** overflow pages used by these cells may need to be updated
43954 ** to be updated.
44006 ** with any child or overflow pages need to be updated. */
44120 ** tree needs to be balanced, and if so calls the appropriate balancing
44200 ** calling balance_nonroot() (balance_deeper() may be called first,
44214 ** new pSpace buffer, so it may be safely freed here. */
44218 /* The pSpace buffer will be freed after the next call to
44243 ** define what table the record should be inserted into. The cursor
44257 ** cursor pCur is pointing at the existing copy of a row that is to be
44260 ** the cursor before the new key can be inserted.
44290 ** expecting an index b-tree, then the caller should be inserting blob
44292 ** intkey table, the caller should be inserting integer keys with a
44310 ** that the cursor is already where it needs to be and returns without
44380 ** row without seeking the cursor. This can be a big performance boost.
44451 ** making any modifications. Make the page containing the entry to be
44466 ** node. The cell from the leaf node needs to be moved to the internal
44495 ** tricky as the leaf node may be underfull, and the internal node may
44496 ** be either under or overfull. In this case run the balancing algorithm
44498 ** tree that we can be sure that any problem in the internal node has
44499 ** been corrected, so be it. Otherwise, after balancing the leaf node,
44549 ** out to be an overflow page, delete all overflow page-map caches
44561 /* The new root-page may not be allocated on a pointer-map page, or the
44571 ** be moved to the allocated page (unless the allocated page happens
44580 /* pgnoRoot is the page that will be used for the root-page of
44715 ** If pnChange is not NULL, then table iTable must be an intkey table. The
44753 ** page number that used to be the last root page in the file before
44835 ** be a root-page number, less one again if that is the
44871 ** This function may only be called if the b-tree connection already
44905 ** read-only and may not be written.
45398 ** A read-only or read-write transaction must be opened before calling
45407 Btree *p, /* The btree to be checked */
45632 ** Argument pCsr must be a cursor opened for writing on an
45636 ** Only the data content may only be modified, it is not possible to
45745 ** structure may be accessed via two groups of thread-safe entry points:
45756 ** be held when either of these functions are invoked.
45761 ** the values returned may be invalid. There is no way for a call to
45773 ** in connection handle pDb. If such a database cannot be found, return
45776 ** If the "temp" database is requested, it may need to be opened by this
45841 pDestDb, SQLITE_ERROR, "source and destination must be distinct"
46015 ** one now. If a transaction is opened here, then it will be closed
46069 ** size may be different to the source page size.
46094 ** * The destination may need to be truncated, and
46097 ** pending-byte page in the source database may need to be
46212 ** Return the number of pages still to be backed up as of the most recent
46232 ** to be updated with the new data before the backup operation is
46262 ** valid and which are not, so the entire process needs to be restarted.
46279 ** must be active for both files.
46281 ** The size of file pTo may be reduced by this operation. If anything
46291 /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set
46306 ** checks this assumption - (p->rc) should be set to either SQLITE_DONE
46358 ** SQLITE_NOMEM may be returned if a malloc() fails during conversion
46392 ** be discarded.
46438 ** malloc(). In this way, we know that the memory is safe to be
46515 ** A MEM_Null value will never be passed to this function. This function is
46517 ** sqlite3_value_text()), or for ensuring that values to be used as btree
46540 ** is UTF-16le or UTF-16be do a translation.
46542 ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.
46586 ** If the memory cell contains a string value that must be freed by
46671 ** If pMem represents a string value, its encoding might be changed.
46749 ** true and could be omitted. But we leave it in because other
46821 ** Delete any previous value and set the value to be a BLOB of length
46869 ** Delete any previous value and set the value of pMem to be an
46969 ** Change the value of a Mem to be a string or a BLOB.
46978 ** size limit) then no memory allocation occurs. If the string can be
47140 /* The collation sequence must be defined at this point, even if
47174 /* Both values must be blobs. Compare using memcmp(). */
47189 ** The pMem structure is assumed to be uninitialized. Any prior content
47245 ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or
47248 ** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED.
47249 ** If that is the case, then the result must be aligned on an even byte
47306 ** be converted directly into a value, then the value is allocated and
47309 ** cannot be converted to a value, then *ppVal is set to NULL.
47390 sqlite3_value *v, /* Value to be set */
47447 ** set the sqlite3VdbeAddopTrace to 1 and all opcodes will be printed
47531 ** unchanged (this is so that any opcodes already allocated can be
47638 ** Create a new symbolic label for an instruction that has yet to be
47640 ** label can be used as the P2 value of an operation. Later, when
47646 ** always negative and P2 values are suppose to be non-negative.
47647 ** Hence, a negative P2 value is a label that has yet to be resolved.
47668 ** Resolve label "x" to be the address of the next instruction to
47669 ** be inserted. The parameter "x" must have been obtained from
47682 ** Mark the VDBE as one that can only be run one time.
47693 ** invoke directly or indirectly. It should be used as follows:
47761 ** to be rolled back). This condition is true if the main program or any
47772 ** ABORT may be thrown, or false otherwise. Return true if it does
47773 ** match, or false otherwise. This function is intended to be used as
47802 ** through all opcodes and hasAbort may be set incorrectly. Return
47860 ** Return the address of the next instruction to be inserted.
47870 ** to arrange for the returned array to be eventually freed using the
47982 ** the address of the next instruction to be coded.
48119 ** sqlite3_malloc, to be freed when the Vdbe is finalized.
48122 ** caller should not free the allocation, it will be freed when the Vdbe is
48239 ** routine, then a pointer to a dummy VdbeOp will be returned. That opcode
48731 void *pBuf, /* Where return pointer will be stored */
48735 int *pnByte /* If allocation cannot be made, increment *pnByte */
48752 ** After the VDBE has be prepped, it can be executed by one or more
48758 ** This function may be called more than once on a single virtual machine.
48760 ** calls are made as part of the process of resetting a statement to be
48781 /* There should be at least one opcode.
48789 ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by
48896 /* The pCx->pCursor will be close automatically, if it exists, by
48986 ** Set the number of result columns that will be returned by this SQL
48989 ** be called on an SQL statement before sqlite3_step().
49010 ** Set the name of the idx'th column to be returned by the SQL statement.
49011 ** zName must be a pointer to a nul terminated string.
49013 ** This call must be made after a call to sqlite3VdbeSetNumCols().
49015 ** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC
49017 ** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed.
49042 ** A read or write transaction may or may not be active on database handle
49054 /* With this option, sqlite3VtabSync() is defined to be simply
49062 ** be done before determining whether a master journal file is
49071 /* This loop determines (a) if the commit hook should be invoked and
49211 ** master journal file will be orphaned. But we cannot delete it,
49243 ** may be lying around. Returning an error code won't help matters.
49296 ** can never be used again. This happens when a rollback
49320 ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or
49333 ** statement transaction that should be closed here. The only exception
49374 ** If SQLite is compiled to support shared-cache mode and to be threadsafe,
49376 ** that may be accessed by the VM passed as an argument. In doing so it
49384 ** will be accessed by the VM, and we could use Vdbe.btreeMask to figure
49402 ** handle associated with the VM passed as an argument is about to be
49434 ** means the close did not happen and needs to be repeated.
49441 ** transaction will be committed or rolled back as a result of the
49551 ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to
49626 ** After this routine is run, the VDBE should be ready to be executed
49643 /* If the VDBE has be run even partially, then transfer the error code
49961 ** nBuf is the amount of space left in buf[]. nBuf must always be
49963 ** a blob with a zero-filled tail, then buf[] might be just the right
50124 ** space at pSpace. This space can be used to hold the returned
50128 ** The returned structure should be closed by a call to
50151 ** it by. If pSpace is already 8-byte aligned, nOff should be zero.
50215 ** greater than key2. The {nKey1, pKey1} key must be a blob
50217 ** key must be a parsed key such as obtained from
50225 ** equal, then the keys are considered to be equal and
50231 ** of the header will therefore be the serial type of the rowid:
50233 ** The serial type of the final rowid will always be a single byte.
50254 /* mem1.flags = 0; // Will be initialized by sqlite3VdbeSerialGet() */
50259 ** But in fact, mem1.u.i will never actually be used initialized, and doing
50279 /* Extract the values to be compared.
50322 ** are considered to be equal. Otherwise, the longer key is the
50323 ** larger. As it happens, the pPKey2 will always be the longer
50343 ** pCur might be pointing to text obtained from a corrupt database file.
50344 ** So the content cannot be trusted. Do appropriate checks on the content.
50357 ** than 2GiB are support - anything large must be database corruption.
50381 /* The last field of the index should be an integer - the ROWID.
50439 /* nCellKey will always be between 0 and 0xffffffff because of the say
50457 ** This routine sets the value to be returned by subsequent calls to
50504 ** The returned value must be freed by the caller using sqlite3ValueFree().
50558 ** to be recompiled. A statement needs to be recompiled whenever the
50625 ** back to its starting state so that it can be reused. A success code from
50929 /* At this point local variable rc holds the value that should be
50932 ** be one of the values in the first assert() below. Variable p->rc
50933 ** contains the value that would be returned if sqlite3_finalize()
51185 ** using gcc, force nullMem to be 8-byte aligned using the magical
51315 ** 0 The column name as it should be displayed for output
51502 const void *zData, /* Pointer to the data to be bound */
51503 int nData, /* Number of bytes of data to be bound */
51635 ** Return the number of wildcards that can be potentially bound to.
52067 ** does not control the string, it might be deleted without the register
52085 ** Argument pMem points at a register that will be passed to a
52119 /* Find the memory cell that will be used to store the blob of memory
52130 ** be freed lazily via the sqlite3_release_memory() API. This
52212 char affinity, /* The affinity to be applied */
52411 ** processor and returns that value. This can be used for high-res
52487 ** implement a loop. This test used to be on every single instruction,
52501 ** occurs here will not be reported, causing the test to fail.
52534 ** sqlite3VdbeMakeReady() must be called before this routine in order to
52551 ** immediately. There will be no error message but the p->rc field is
52554 ** A memory allocation error causes p->rc to be set to SQLITE_NOMEM and this
52559 ** After this routine has finished, sqlite3VdbeFinalize() should be
52682 const char *zAffinity; /* The affinity to be applied */
52694 Mem *pData0; /* First field to be combined into the record */
52793 } be;
52795 Mem *pData; /* MEM cell holding data for the record to be inserted */
52797 i64 iKey; /* The integer ROWID or key for the record to be inserted */
52883 int *aRoot; /* Array of rootpage numbers for tables to be checked */
53084 ** external allocations out of mem[p2] and set mem[p2] to be
53129 ** indentation conventions, each case should be indented by 6 spaces. But
53131 ** the switch statement will break with convention and be flush-left. Another
53138 ** will be filled with #defines that give unique integer values to each
53164 ** The next instruction executed will be
53236 ** or sqlite3_finalize(). For a normal halt, this should be SQLITE_OK (0).
53237 ** For errors, it can be some other value. If P1!=0 then P2 will determine
53532 ** transaction. It needs to be rolled back. */
53590 ** It is illegal for P1 and P3 to be the same register. Sometimes,
53755 ** be returned. This is used by the built-in min(), max() and nullif()
53772 ** Register P3 must not be one of the function inputs.
53775 ** function was determined to be constant at compile time. If the first
53778 ** sqlite3_set_auxdata() API may be safely retained until the next
53933 ** To force any register to be an integer, just add 0.
53944 ** Force the value in register P1 to be an integer. If the value
53945 ** in P1 is not an integer and cannot be converted into an integer
53970 ** has REAL affinity. Such column values may still be stored as
53985 ** Force the value in register P1 to be text.
54007 ** Force the value in register P1 to be a BLOB.
54030 ** Force the value in register P1 to be numeric (either an
54049 ** Force the value in register P1 be an integer. If
54067 ** Force the value in register P1 to be a floating point number.
54092 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
54122 ** If neither operand is NULL the the result is the same as it would be if
54134 ** If neither operand is NULL the the result is the same as it would be if
54227 ** Set the permutation used by the OP_Compare operator to be the array
54520 /* This block sets the variable u.am.payloadSize to be the total number of
54523 ** u.am.zRec is set to be the complete text of the record if it is available.
54526 ** might be available in the u.am.pC->aRow cache. Or it might not be.
54552 ** payload size, so it is impossible for u.am.payloadSize64 to be
54569 /* Consider the row to be NULL */
54629 ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte
54630 ** types use so much data space that there can only be 4096 and 32 of
54642 ** u.am.nField might be significantly less than the true number of columns
54643 ** in the table, and in that case, 5*u.am.nField+3 might be smaller than u.am.offset.
54646 ** to be oversized. Offset is limited to 98307 above. But 98307 might
54649 ** will likely be much smaller since u.am.nField will likely be less than
54703 ** or if the end of the last field appears to be past the end of the
54704 ** record, or if the end of the last field appears to be before the end
54705 ** of the record (when all fields present), then we must be dealing
54773 ** string indicates the column affinity that should be used for the nth
54778 const char *zAffinity; /* The affinity to be applied */
54804 ** P4 may be a string that is P2 characters long. The nth character of the
54805 ** string indicates the column affinity that should be used for the nth
54823 Mem *pData0; /* First field to be combined into the record */
54874 /* Only pure zero-filled BLOBs can be input to this Opcode.
54894 ** be one of the input registers (because the following call to
54974 ** transaction, then there cannot be any savepoints.
54983 /* A new savepoint cannot be created if there are active write
55180 ** transaction might also be rolled back if an error is encountered.
55191 ** write transaction must be started before any changes can be made to the
55197 ** throw an ABORT exception), a statement transaction may also be opened.
55201 ** VDBE to be rolled back after an error without having to roll back the
55239 ** counter. If the statement transaction needs to be rolled back,
55240 ** the value of this counter needs to be restored too. */
55255 ** There must be a read-lock on the database (either a transaction
55256 ** must be started or there must be an open cursor) before
55286 ** A transaction must be started before executing this opcode.
55331 ** to be executed (to establish a read lock) before this opcode is
55359 ** v-table would have to be ready for the sqlite3_vtab structure itself
55360 ** to be invalidated whenever sqlite3_step() is called from within
55380 ** values need not be contiguous but all P1 values should be small integers.
55381 ** It is an error for P1 to be negative.
55386 ** There will be a read lock on the database whenever there is an
55395 ** The P4 value may be either an integer (P4_INT32) or a pointer to
55409 ** The P4 value may be either an integer (P4_INT32) or a pointer to
55417 ** in read/write mode. For a given table, there can be one or more read-only
55578 ** row output from the sorter so that the row can be decomposed into
55582 ** P3 is the number of fields in the records that will be stored by
55689 /* The input value in P3 might be of any type: integer, real, string,
55690 ** blob, or NULL. But it needs to be an integer before we can do
55697 /* If the P3 value could not be converted into an integer without
55701 /* If the P3 value cannot be converted into any kind of a number,
55706 /* If we reach this point, then the P3 value must be a floating
55711 /* The P3 value is too large in magnitude to be expressed as an
55794 /* u.az.res might be negative because the table is empty. Check to
55935 ** that make up an unpacked index key that can be used with cursor P1.
55936 ** The value of N can be inferred from the cursor. N includes the rowid
55938 ** or may not be the same as R.
56091 ** allowed to be less than this value. When this value reaches its maximum,
56097 #if 0 /* local variables moved into u.be */
56104 #endif /* local variables moved into u.be */
56106 u.be.v = 0;
56107 u.be.res = 0;
56109 u.be.pC = p->apCsr[pOp->p1];
56110 assert( u.be.pC!=0 );
56111 if( NEVER(u.be.pC->pCursor==0) ){
56127 assert( u.be.pC->isTable );
56128 u.be.cnt = 0;
56140 if( !u.be.pC->useRandomRowid ){
56141 u.be.v = sqlite3BtreeGetCachedRowid(u.be.pC->pCursor);
56142 if( u.be.v==0 ){
56143 rc = sqlite3BtreeLast(u.be.pC->pCursor, &u.be.res);
56147 if( u.be.res ){
56148 u.be.v = 1; /* IMP: R-61914-48074 */
56150 assert( sqlite3BtreeCursorIsValid(u.be.pC->pCursor) );
56151 rc = sqlite3BtreeKeySize(u.be.pC->pCursor, &u.be.v);
56153 if( u.be.v==MAX_ROWID ){
56154 u.be.pC->useRandomRowid = 1;
56156 u.be.v++; /* IMP: R-29538-34987 */
56166 for(u.be.pFrame=p->pFrame; u.be.pFrame->pParent; u.be.pFrame=u.be.pFrame->pParent);
56168 assert( pOp->p3<=u.be.pFrame->nMem );
56169 u.be.pMem = &u.be.pFrame->aMem[pOp->p3];
56173 u.be.pMem = &aMem[pOp->p3];
56176 REGISTER_TRACE(pOp->p3, u.be.pMem);
56177 sqlite3VdbeMemIntegerify(u.be.pMem);
56178 assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
56179 if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
56183 if( u.be.v<u.be.pMem->u.i+1 ){
56184 u.be.v = u.be.pMem->u.i + 1;
56186 u.be.pMem->u.i = u.be.v;
56190 sqlite3BtreeSetCachedRowid(u.be.pC->pCursor, u.be.v<MAX_ROWID ? u.be.v+1 : 0);
56192 if( u.be.pC->useRandomRowid ){
56198 assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is
56200 u.be.v = db->lastRowid;
56201 u.be.cnt = 0;
56203 if( u.be.cnt==0 && (u.be.v&0xffffff)==u.be.v ){
56204 u.be.v++;
56206 sqlite3_randomness(sizeof(u.be.v), &u.be.v);
56207 if( u.be.cnt<5 ) u.be.v &= 0xffffff;
56209 rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, 0, (u64)u.be.v, 0, &u.be.res);
56210 u.be.cnt++;
56211 }while( u.be.cnt<100 && rc==SQLITE_OK && u.be.res==0 );
56212 if( rc==SQLITE_OK && u.be.res==0 ){
56217 u.be.pC->rowidIsValid = 0;
56218 u.be.pC->deferredMoveto = 0;
56219 u.be.pC->cacheStatus = CACHE_STALE;
56221 pOut->u.i = u.be.v;
56231 ** be a MEM_Int.
56252 ** may be NULL. If it is not NULL, then the update-hook
56272 Mem *pData; /* MEM cell holding data for the record to be inserted */
56274 i64 iKey; /* The integer ROWID or key for the record to be inserted */
56341 ** The cursor will be left pointing at either the next or the previous
56343 ** the next Next instruction will be a no-op. Hence it is OK to delete
56349 ** P1 must not be pseudo-table. It has to be a real table with
56353 ** pointing to. The update hook will be invoked, if it exists.
56369 /* If the update-hook will be invoked, set u.bg.iKey to the rowid of the
56381 ** to the row to be deleted and the sqlite3VdbeCursorMoveto() operation
56423 ** If the P1 cursor must be pointing to a valid row (not a NULL row)
56433 ** If the P1 cursor must be pointing to a valid row (not a NULL row)
56503 ** P1 can be either an ordinary table or a virtual table. There used to
56504 ** be a separate OP_VRowid opcode for use with virtual tables, but this
56614 ** rewinding so that the global variable will be incremented and
56668 ** The P1 cursor must be for a real table, not a pseudo-table.
56679 ** The P1 cursor must be for a real table, not a pseudo-table.
56724 ** insert is likely to be an append.
56797 ** the end of the index key pointed to by cursor P1. This integer should be
56843 ** the result is false whereas it would be true with IdxGT.
56900 ** P3==1 then the table to be clear is in the auxiliary database file
56904 ** might be moved into the newly deleted root page in order to keep all
56959 ** P2==1 then the table to be clear is in the auxiliary database file
56962 ** If the P3 value is non-zero, then the table referred to must be an
57062 ** loaded. Otherwise, the new index definition can be loaded along
57072 ** u.bu.iDb mutex may be temporarily released to avoid deadlock. If
57075 ** will not be reloaded becuase the db->init.busy flag is set. This
57114 ** the analysis to be used when preparing all subsequent queries.
57168 ** At most reg(P3) errors will be reported.
57184 int *aRoot; /* Array of rootpage numbers for tables to be checked */
57279 ** must have P4==0, the final set P4=-1. P4 must be either -1 or
57286 ** never be tested for, and (c) when a value that is part of set X is
57366 ** SubProgram (if the trigger may be executed with more than one different
57385 ** is already allocated. Otherwise, it must be initialized. */
57473 ** Increment a "constraint counter" by P2 (P2 may be negative or positive).
57681 ** machines to be created and run. It may not be called from within
57745 ** used to generate an error message if the lock cannot be obtained.
57767 ** P4 may be a pointer to an sqlite3_vtab structure. If so, call the
57772 ** code will be set to SQLITE_LOCKED.
57869 ** P3. Register P3+1 stores the argc parameter to be passed to the
57874 ** A jump is made to P2 if the result set after filtering would be empty.
58083 ** row. This can be NULL to have the virtual table select the new
58201 ** The cases of the switch statement above this line should all be indented
58444 ** key columns must be indexed. The check below will pick up this
58488 /* Make sure a mutex is held on the table to be accessed */
58702 ** be used to service read() and write() requests. The actual file
58786 const void *zBuf, /* Take data to be written from here */
58967 ** The cursor can be either for reading or writing.
59036 const void *zBuf, /* Take data to be written from here */
59044 /* An in-memory journal file should only ever be appended to. Random
59114 ** part of SQLite causes Sync to be called by mistake.
59199 ** The return value from the callback should be one of the WRC_*
59338 ** TK_AS operator. The TK_AS operator causes the expression to be
59342 ** column reference is so that the column reference will be recognized as
59403 ** allowing it to be repopulated by the memcpy() on the following line.
59428 ** The zDb variable is the name of the database (the "X"). This value may be
59430 ** can be used. The zTable variable is the name of the table (the "Y"). This
59431 ** value can be NULL if zDb is also NULL. If zTable is NULL it
59433 ** can be used.
59435 ** If the name cannot be resolved unambiguously, leave an error message
59456 assert( pNC ); /* the name context cannot be NULL. */
59457 assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
59675 ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the
59964 ** same integer value that would be used in the SQL statement to indicate
60023 "%r %s BY term out of range - should be "
60135 ExprList *pOrderBy, /* The ORDER BY or GROUP BY clause to be processed */
60179 ** an appropriate error message might be left in pParse. (OOM errors
60253 /* Normally sqlite3SelectExpand() will be called first and will have
60255 ** an expression, sqlite3ResolveExprNames() will be called without a
60325 /* If a HAVING clause is present, then there must be a GROUP BY clause.
60337 ** Minor point: If this is the case, then the expression will be
60449 Expr *pExpr /* The expression to be analyzed. */
60572 ** Set the collating sequence for expression pExpr to be the collating
60635 ** type affinity that should be used for the comparison operator.
60662 ** be applied to both operands prior to doing the comparison.
60684 ** if the index with affinity idx_affinity may be used to implement
60700 ** Return the P5 value that should be used for a binary comparison
60710 ** Return a pointer to the collation sequence that should be used by
60718 ** Argument pRight (but not pLeft) may be a null pointer. In this case,
60879 ** appear to be quoted. If the quotes were of the form "..." (double-quotes)
60883 ** can be translated into a 32-bit integer, then the token is not
60889 sqlite3 *db, /* Handle for sqlite3DbMallocZero() (may be null) */
60891 const Token *pToken, /* Token argument. Might be NULL */
60936 sqlite3 *db, /* Handle for sqlite3DbMallocZero() (may be null) */
60938 const char *zToken /* Token argument. Might be NULL */
60984 ** One or both of the subtrees can be NULL. Return a pointer to the new
61043 ** sure "nnn" is not too be to avoid a denial of service attack when
61074 sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
61164 ** (2) the EP_xxx flags that indicate what the structure size should be.
61171 ** The size of the structure can be found by masking the return value
61172 ** of this routine with 0xfff. The flags can be found by masking the
61336 ** be deleted (by being passed to their respective ...Delete() routines)
61340 ** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded
61347 ** truncated version of the usual Expr structure that will be stored as
61384 ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes
61484 ExprList *pList, /* List to which to append. Might be NULL */
61485 Expr *pExpr /* Expression to be appended. Might be NULL */
61524 ** pList might be NULL following an OOM error. But pName should never be
61531 Token *pName, /* Name to be added */
61532 int dequote /* True to cause the name to be dequoted */
61549 ** pList might be NULL following an OOM error. But pSpan should never be
61556 ExprSpan *pSpan /* The span to be added */
61629 /* Consider functions to be constant if all their arguments are constant
61742 ** Return FALSE if there is no chance that the expression can be NULL.
61744 ** If the expression might be NULL or if the expression is too complex
61748 ** when we know that a value cannot be NULL. Hence, a false positive
61749 ** (returning TRUE when in fact the expression can never be NULL) might
61750 ** be a small performance hit but is otherwise harmless. On the other
61751 ** hand, a false negative (returning FALSE when the result could be NULL)
61776 ** can be omitted.
61780 const Expr *pExpr, /* Only generate OP_IsNull if this expr can be NULL */
61790 ** Return TRUE if the given expression is a constant which would be
61795 ** can be omitted. When in doubt return FALSE. A false negative
61819 assert( p->iTable>=0 ); /* p cannot be part of a CHECK constraint */
61884 ** It's job is to find or create a b-tree structure that may be used
61897 ** An existing b-tree may only be used if the SELECT is of the simple
61902 ** If the prNotFound parameter is 0, then the b-tree will be used to iterate
61904 ** epheremal table must be used unless the selected <column> is guaranteed
61905 ** to be unique - either because it is an INTEGER PRIMARY KEY or it
61908 ** If the prNotFound parameter is not 0, then the b-tree will be used
61910 ** be used unless <column> is an INTEGER PRIMARY KEY or an index can
61911 ** be found with <column> as its left-most column.
61941 int mustBeUnique = (prNotFound==0); /* True if RHS must be unique */
61945 /* Check to see if an existing table or index can be used to
61983 ** be used in place of a temp-table, it must be ordered according
61987 /* Check that the affinity that will be used to perform the
62053 ** to be of the form "<rowid> IN (?, ?, ?)", where <rowid> is a reference
62086 /* This code must be run in its entirety every time it is encountered
62219 /* If this has to be a scalar SELECT. Generate code to put the
62328 ** "x IN (...)" expression must be either 0 or NULL. If the set
62402 ** The z[] string will probably not be zero-terminated. But the
62403 ** z[n] character is guaranteed to be something that does not look
62423 ** The z[] string will probably not be zero-terminated. But the
62424 ** z[n] character is guaranteed to be something that does not look
62483 ** that the object will never already be in cache. Verify this guarantee.
62582 ** register might be in the cache in multiple places, so be sure to
62601 ** There must be an open cursor to pTab in iTable when this routine
62731 ** Note that in order for this to work, code must be generated in the
62778 ** be stored in target. The result might be stored in some other
63259 /* If the column has REAL affinity, it may currently be stored as an
63277 ** Form A is can be transformed into the equivalent form B as follows:
63361 "RAISE() may only be used within a trigger-program");
63389 ** If the register is a temporary register that can be deallocated,
63440 ** other place where expressions can be converted into TK_REGISTER is
63463 ** or OP_Variable that does not need to be placed in a
63467 ** expressions that need to be placed in a particular register.
63582 ExprList *pList, /* The expression list to be coded */
63936 ** identical, we return FALSE just to be safe. So if this routine
63939 ** can be sure the expressions are the same. In the places where
64090 ** Convert the pExpr to be a TK_AGG_COLUMN referring to that
64105 ** to be ignored */
64163 ** for variables that need to be added to the pParse->aAgg[] array.
64166 ** This routine should only be called after the expression has been
64322 ** and its length in 'len' (to be used next iteration of this loop).
64444 ** and its length in 'len' (to be used next iteration of this loop).
64455 ** to be met.
64457 ** Note that ON cannot be a database, table or column name, so
64522 ** Generate the text of a WHERE expression which can be used to select all
64538 ** Generate the text of a WHERE expression which can be used to select all
64568 ** the time the generated code is executed. This can be different from
64663 sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
64672 sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName);
64888 ** column must not be NULL.
64964 ** Routine sqlite3AlterFinishAddColumn() will be called to complete
64985 sqlite3ErrorMsg(pParse, "virtual tables may not be altered");
65073 ** Argument zWhere may be a pointer to a buffer containing a table name,
65074 ** or it may be a NULL pointer. If it is not NULL, then all entries in
65114 ** because the OpenWrite opcode below will be needing it. */
65151 Table *pTab, /* Table whose indices are to be analyzed */
65207 /* Open a cursor to the index to be analyzed. */
65280 ** value that should be stored in the sqlite_stat2 table. If so,
65317 ** below may be negative. Which causes an assert() to fail (or an
65372 ** be laoded into internal hash tables where is can be used.
65430 ** Form 1 causes all indices in all attached databases to be analyzed.
65576 ** code may be ignored.
65726 ** will fail because neither abc or def can be resolved.
65818 ** or may not be initialised.
66090 ** Initialize a DbFixer structure. This routine must be called prior
66097 DbFixer *pFix, /* The fixer to be initialized */
66098 Parse *pParse, /* Error messages will be written here */
66099 int iDb, /* This is the database that must be used */
66158 Select *pSelect /* The SELECT statement to be fixed to one database */
66179 Expr *pExpr /* The expression to be fixed to one database */
66197 ExprList *pList /* The expression to be fixed to one database */
66214 TriggerStep *pStep /* The trigger step be fixed to one database */
66252 ** All of the code in this file may be omitted by defining a single
66260 ** The access authorization function is be called during the compilation
66297 ** and attempts to write the column will be ignored.
66358 ** The pExpr should be a TK_COLUMN expression. The table referred to
66456 ** zArg3 argument to authorization callbacks will be zContext until
66512 ** be parsed. Initialize the pParse structure as needed.
66525 int iDb; /* The database containing the table to be locked */
66526 int iTab; /* The root page of the table to be locked */
66534 ** The table to be locked has root page iTab and is found in database iDb.
66535 ** A read or a write lock can be taken depending on isWritelock.
66544 int iTab, /* Root page number of the table to be locked */
66546 const char *zName /* Name of the table to be locked */
66606 ** Note that if an error occurred, it might be the case that
66720 assert( pParse->nested<10 ); /* Nesting should only be of limited depth */
66778 const char *zDbase /* Name of the database. Might be NULL */
66846 ** Unlinking from the Table must be done by the calling function.
66876 /* Justification of ALWAYS(); The index must be on the list of
67047 ** is obtained from sqliteMalloc() and must be freed by the calling
67086 ** -1 if the named db cannot be found.
67186 ** flag is true if the table should be stored in the auxiliary database
67193 ** routines will be called to add more information to this record.
67227 ** set to the index of the database that the table or view is to be
67233 /* If creating a temp table, the name may not be qualified */
67234 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
67277 ** and types will be used, so there is no need to test for namespace
67326 ** indices to be created and the table record must come before the
67327 ** indices. Hence, the record number for the table must be allocated
67360 ** The record created does not contain anything yet. It will be replaced
67451 ** be called next to set pCol->affinity correctly.
67556 ** Default value expressions must be constant. Raise an exception if this
67598 ** field of the table under construction to be the index of the
67607 ExprList *pList, /* List of field names to be indexed */
67735 ** invokes the collation factory if the named collation cannot be found
67769 ** the schema to change multiple times and for the cookie to be
67788 ** The estimate is conservative. It might be larger that what is
67838 ** from sqliteMalloc() and must be freed by the calling function.
68014 ** suitable state to query for the column names and types to be used
68020 ** be redundant.
68171 ** This will force all the Expr.token.z values to be dynamically
68258 ** to be permanent. So the computation is done on a copy of the SELECT
68330 ** because the first match might be for one of the deleted indices
68334 ** in order to be certain that we got the right one.
68401 /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM
68405 ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the
68412 ** and root page 5 happened to be the largest root-page number in the
68413 ** database, then root page 5 would be moved to page 4 by the
68447 ** pName is the name of the table to be dropped.
68513 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);
68576 ** dropped. Triggers are handled seperately because a trigger can be
68764 ** the index already exists and must be cleared before being refilled and
68819 ** we can be sure that no other temp registers have been allocated
68837 ** and pTblList is the name of the table that is to be indexed. Both will
68838 ** be NULL for a primary key or an index that is created to satisfy a
68840 ** as the table to be indexed. pParse->pNewTable is a table that is
68843 ** pList is a list of columns to be indexed. pList will be NULL if this
68853 Token *pName1, /* First part of index name. May be NULL */
68854 Token *pName2, /* Second part of index name. May be NULL */
68856 ExprList *pList, /* A list of columns to be indexed */
68864 Table *pTab = 0; /* Table to be indexed */
68865 Index *pIndex = 0; /* The index to be created */
68881 assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */
68891 ** Find the table that is to be indexed. Return early if not found.
68939 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
68944 sqlite3ErrorMsg(pParse, "views may not be indexed");
68950 sqlite3ErrorMsg(pParse, "virtual tables may not be indexed");
69078 /* Scan the names of the columns of the table to be indexed and
69084 ** the column will ever be used by the optimizer. Note that using the
69085 ** same column more than once cannot be an error because that would
69086 ** break backwards compatibility - it needs to be a warning.
69224 ** step can be skipped.
69317 ** to be used when we have not run the ANALYZE command.
69324 ** of the index. And so forth. It must always be the case that
69330 ** how aiRowEst[] should be initialized. The numbers generated here
69378 "or PRIMARY KEY constraint cannot be dropped", 0);
69434 ** might be the same as the pArray parameter or it might be a different
69439 void *pArray, /* Array of objects. Might be reallocated */
69468 ** need be.
69535 ** the iStart value would be 0. The result then would
69536 ** be: nil, nil, nil, A, B.
69539 ** db->mallocFailed flag will be set to true.
69543 SrcList *pSrc, /* The SrcList to be enlarged */
69591 ** need be. A new entry is created in the SrcList even if pTable is NULL.
69594 ** SrcList might be the same as the SrcList that was input or it might be
69620 ** Both pTable and pDatabase are assumed to be quoted. They are dequoted
69771 ** expects the join operator to be on the right operand. This routine
69913 ** It is important that all schema cookies be verified and all
69914 ** read transactions be started before anything else happens in
69915 ** the VDBE program. But this routine can be called after much other
69923 ** starts the transactions will be coded and the OP_Goto P2 value
69924 ** will be made to point to that subroutine. The generation of the
69928 ** schema on any databases. This can be used to position the OP_Goto
69929 ** early in the code, before we know if any database tables will be used.
69964 ** be set for operations that might fail (due to a constraint) part of
69967 ** can be checked before any changes are made to the database, it is never
69968 ** necessary to undo a write and the checkpoint should not be set.
69982 ** be necessary to undo the completed writes.
70091 ** Form 1 causes all indices in all attached databases to be rebuilt.
70098 CollSeq *pColl; /* Collating sequence to be reindexed, or NULL */
70105 Token *pObjName; /* Name of the table or index to be reindexed */
70147 sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed");
70152 ** Return a dynamicly allocated KeyInfo structure that can be used
70235 ** collation function in the best encoding but there may be other versions
70264 ** The return value is either the collation sequence to be used in database
70266 ** sequence can be found.
70331 ** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.
70361 ** return the pColl pointer to be deleted (because it wasn't added
70386 ** cannot be found.
70503 ** any number of arguments will be returned.
70510 ** number of arguments may be returned even if the eTextRep flag does not
70700 sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
70718 ** set of rows in the view that are to be added to the ephemeral table.
70723 Expr *pWhere, /* Optional WHERE clause to be added */
70765 Expr *pWhere, /* The WHERE clause. May be null */
70766 ExprList *pOrderBy, /* The ORDER BY clause. May be null */
70767 Expr *pLimit, /* The LIMIT clause. May be null */
70768 Expr *pOffset, /* The OFFSET clause. May be null */
70790 /* if pLimit is null, pOffset will always be null as well. */
70857 Expr *pWhere /* The WHERE clause. May be null */
70860 Table *pTab; /* The table from which records will be deleted */
70886 /* Locate the table which we want to delete. This table has to be
70888 ** will be calling are designed to work with multiple tables and expect
70981 ** API function sqlite3_count_changes) to be set incorrectly. */
71002 /* Collect rowids of every row to be deleted.
71092 ** single table to be deleted.
71094 ** The VDBE must be in a particular state when this routine is called.
71098 ** to be deleted, must be opened as cursor number $iCur.
71100 ** 2. Read/write cursors for all indices of pTab must be open as
71103 ** 3. The record number of the row to be deleted must be stored in
71111 Table *pTab, /* Table containing the row to be deleted */
71146 /* Populate the OLD.* pseudo-table register array. These values will be
71162 /* Seek the cursor to the row to be deleted again. It may be that
71205 ** The VDBE must be in a particular state when this routine is called.
71209 ** to be deleted, must be opened as cursor number "iCur".
71211 ** 2. Read/write cursors for all indices of pTab must be open as
71214 ** 3. The "iCur" cursor must be pointing to the row that is to be
71219 Table *pTab, /* Table containing the row to be deleted */
71236 ** regOut. The key with be for index pIdx which is an index on pTab.
71426 ** something that can be converted into a number, we have:
71428 ** cannot be converted to a numeric value.
71632 ** The COALESCE() and IFNULL() functions used to be implemented as shown
71634 ** do not have to be computed. This legacy implementation is retained as
71676 ** therefore be no less than -9223372036854775807.
71774 ** case. Thus 'a' LIKE 'A' would be true. */
71777 ** is case sensitive causing 'a' LIKE 'A' to be false */
71782 ** potentially be a "glob" expression. Return true (1) if they
71796 ** With the [...] and [^...] matching, a ']' character can be included
71798 ** range of characters can be specified using '-'. Example:
71802 ** This routine is usually quick, but can be N**2 in the worst case.
71971 "ESCAPE expression must be a single character", -1);
72164 ** must be exact. Collating sequences are not used.
72512 ** internal count when using count(*) and when the total count can be
72625 ** functions. This should be the only routine in this file with
72721 ** The array cannot be constant since changes are made to the
72878 ** modified (values must be compared at runtime).
72886 ** is thrown, even if the FK constraint would be satisfied after the new
72899 ** TODO: How should dropping a table be handled? How should renaming a
72900 ** table be handled?
72910 ** implemented using triggers, which of the old.* columns would be
72964 ** If the required index cannot be found, either because:
73036 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
73100 ** or deleted from the child table. If the parent row can be found, no
73101 ** special action is taken. Otherwise, if the parent row can *not* be
73159 ** will have INTEGER affinity applied to it, which may not be correct. */
73236 ** code for an SQL UPDATE operation, this function may be called twice -
73288 ** The collation sequence used for the comparison should be that of
73290 ** be applied to each child key value before the comparison takes place.
73393 ** The Trigger structure or any of its sub-components may be allocated from
73433 ** is the child table. If one cannot be found, return without
73434 ** generating any VDBE code. If one can be found, then jump over
73498 /* Exactly one of regOld and regNew should be non-zero. */
73521 ** schema items cannot be located, set an error in pParse and return
73571 ** be found, adding the child row has violated the FK constraint. */
73665 ** If any foreign key processing will be required, this function returns
73804 ** The final WHEN clause will be like this:
73870 ** should always be 0 there.
74020 Table *pTab, /* The table to be opened */
74050 ** is managed along with the rest of the Index structure. It will be
74059 ** The column affinity string will eventually be deleted by
74100 ** The column affinity string will eventually be deleted by
74255 ** This routine should be called when the top of the stack holds a
74256 ** new rowid that is about to be inserted. If that new rowid is
74430 ExprList *pList, /* List of values to be inserted */
74455 int appendFlag = 0; /* True if the insert is likely to be an append */
74480 /* Locate the table into which we will be inserting new information.
74542 ** Then special optimizations can be applied that make the transfer
74616 ** should be written into a temporary table (template 4). Set to
74617 ** FALSE if each* row of the SELECT can be written directly into
74620 ** A temp table must be used if the table being updated is also one
74677 ** of columns to be inserted into the table.
74741 /* Initialize the count of rows to be inserted
74809 ** PRIMARY KEY into which a NULL is being inserted, that NULL will be
74811 ** we do not know what the unique ID will be (because the insert has
74930 ** Whenever this column is read, the record number will be substituted
74932 ** taking up data space with information that will never be used. */
75131 ** cursors do not need to be open for indices where aRegIdx[i]==0.
75189 zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL",
75250 pParse, onError, "PRIMARY KEY must be unique", P4_STATIC);
75261 ** the index b-tree entries only. The table b-tree entry will be
75331 /* Check to see if the new index entry will be unique */
75399 ** rowid and the content to be inserted.
75401 ** The arguments to this routine should be the same as the first six
75411 int appendBias, /* True if this is likely to be an append */
75466 Table *pTab, /* Table to be opened */
75552 /* If no test above fails then the indices must be compatible */
75568 ** (3) There must be no triggers on tab1
75585 ** be attempted, then this routine returns FALSE.
75611 return 0; /* Must be of the form INSERT INTO ... SELECT ... */
75618 return 0; /* tab1 must not be a virtual table */
75648 assert( pSelect->pOffset==0 ); /* Must be so if pLimit==0 */
75650 return 0; /* SELECT may not be a compound query */
75653 return 0; /* SELECT may not be DISTINCT */
75662 return 0; /* The result set must be the special operator "*" */
75675 return 0; /* tab1 and tab2 may not be the same table */
75679 return 0; /* tab2 must not be a virtual table */
75683 return 0; /* tab2 may not be a view */
75686 return 0; /* Number of columns must be the same in tab1 and tab2 */
75693 return 0; /* Affinity must be the same on all columns */
75696 return 0; /* Collating sequence must be the same on all columns */
75699 return 0; /* tab2 must be NOT NULL if tab1 is */
75739 ** are indices to be copied and the destination is not empty,
75745 ** insure that all entries in the union of DEST and SRC will be
75762 pParse, onError, "PRIMARY KEY must be unique", P4_STATIC);
75828 ** other files are for internal use by SQLite and should not be
75845 const char *zSql, /* The SQL to be executed */
75993 ** shared libraries that want to be imported as extensions into
75994 ** an SQLite instance. Shared libraries that intend to be loaded
76010 ** versions of SQLite will not be able to load each others' shared
76673 ** zFile. The entry point is zProc. zProc may be 0 in which case a
76827 ** mutex must be held while accessing this list.
76976 ** should be passed into sqlite3BtreeSetSafetyLevel(). The is done
76977 ** to support legacy SQL code. The safety level used to be boolean
77062 sqlite3ErrorMsg(pParse, "temporary storage cannot be changed "
77077 ** as needing reloading. This must be done when using the SQLITE_TEMP_STORE
77138 /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
77143 /* This flag may only be set if both foreign-key and trigger support
77163 /* Foreign key support may not be enabled or disabled while not
77214 ** The identifier might also be a string. The value is a string, and
77328 ** database page size value. The value can only be set if
77396 ** the current default locking mode (which may be different to
77404 ** of the PRAGMA command. In this case the locking-mode must be
77454 ** the current default journal mode (which may be different to
77462 ** of the PRAGMA command. In this case the journal-mode must be
77604 ** page cache size. The local setting can be different from
77611 ** N should be a positive integer.
77631 ** value will be restored the next time the database is opened.
77649 ** the value sets a specific directory to be used for temporary files.
77703 ** the value sets a specific file to be used for database access locks.
77746 ** default value will be restored the next time the database is
77756 "Safety level may not be changed inside a transaction");
77967 ** used will be case sensitive or not depending on the RHS.
78145 ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be"
78152 ** encoding that will be used for the main database file if a new file
78161 ** In the second form this pragma sets the text encoding to be used in
78171 { "UTF-8", SQLITE_UTF8 }, /* Must be element [1] */
78172 { "UTF-16le", SQLITE_UTF16LE }, /* Must be element [2] */
78173 { "UTF-16be", SQLITE_UTF16BE }, /* Must be element [3] */
78194 ** will be overwritten when the schema is next loaded. If it does not
78195 ** already exists, it will be created to use the new encoding value.
78238 ** The user-version is not used internally by SQLite. It may be used by
78484 ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
78509 ** database. iDb==1 should never be used. iDb>=2 is used for
78599 ** will be closed before this function returns. */
78839 ** will be closed immediately after reading the meta-value. */
78877 ** function should never be used.
79092 ** if the statement cannot be recompiled because another connection has
79530 ** NULL t2 row will be inserted whenever t1.x!=5. If we do not
79531 ** defer the handling of t1.x=5, it will be processed immediately
79617 ** in the USING clause. Example: If the two tables to be joined are
79621 ** not contained in both tables to be joined.
79656 int regData /* Register holding data to be sorted */
79884 ** then there should be a single item on the stack. Write this
79893 ** does not matter. But there might be a LIMIT clause, in which
80120 ** expression pExpr. The string may be treated as static by the caller.
80125 ** is considered a column can be complex in the presence of subqueries. The
80154 ** extracted from in NameContext.pSrcList. This table may be real
80177 ** possible. However, it can still be true for statements like
80185 ** though it should really be "INTEGER".
80388 ** All column names will be unique.
80485 ** statement be resolved.
80601 ** contraversy about what the correct behavior should be.
80668 Select *p, /* The right-most of SELECTs to be coded */
80680 ** left is p->pPrior. The left query could also be a compound query
80681 ** in which case this routine will be called recursively.
80683 ** The results of the total query are to be written into a destination
80700 ** pPrior will be the t2 query. p->op will be TK_UNION in this case.
80707 Select *p, /* The right-most of SELECTs to be coded */
81035 ** The data to be output is contained in pIn->iMem. There are
81036 ** pIn->nMem columns to be output. pDest is where the output should
81037 ** be sent.
81107 ** then there should be a single item on the stack. Write this
81158 /* If none of the above, then the result destination must be
81244 ** is skipped if the next results would be the same as the previous.
81276 Select *p, /* The right-most of SELECTs to be coded */
81603 /* Reassembly the compound query so that it will be freed correctly
81637 int iTable, /* Table to be substituted */
81669 int iTable, /* Table to be substituted */
81681 int iTable, /* Table to be replaced */
81719 ** has no indices, the WHERE clause on the outer query cannot be
81729 ** exist on the table t1, a complete scan of the data might be
81789 ** ORDER by clause of the parent must be simple references to
81846 /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
81848 ** because they could be computed at compile-time. But when LIMIT and OFFSET
81908 ** that make up the compound SELECT are allowed to be aggregate or distinct
81946 ** 17 and 18 above) it must be a UNION ALL and the parent query must
81947 ** be of the form:
82046 ** iParent. The iParent cursor will never be used. Subsequent code
82183 ** it is, or 0 otherwise. At present, a query is considered to be
82248 ** was such a clause and the named index cannot be found, return
82290 ** If found, expand each "*" to be every column in every table
82291 ** and TABLE.* to be every column in TABLE.
82396 ** operators that need to be expanded. Loop through each expression
82409 /* This particular expression does not need to be expanded.
82420 /* This expression is a "*" or a "TABLE.*" and needs to be
82446 char *zToFree; /* Malloced string that needs to be freed */
82533 ** SELECT statement. The SELECT statement must be expanded before
82764 ** SRT_Set The result must be a single column. Store each
82775 ** is assumed to already be open.
82812 Expr *pWhere; /* The WHERE clause. May be NULL */
82813 ExprList *pOrderBy; /* The ORDER BY clause. May be NULL */
82814 ExprList *pGroupBy; /* The GROUP BY clause. May be NULL */
82815 Expr *pHaving; /* The HAVING clause. May be NULL */
82835 ** DISTINCT so it can be removed too. */
82875 /* Check to see if the subquery can be absorbed into the parent. */
82929 ** only a single column may be output.
82949 ** index might end up being unused if the data can be
82951 ** OP_OpenEphemeral instruction will be changed to an OP_Noop once
83087 ** will be converted into a Noop.
83114 ** it might be a single loop that uses an index to extract information
83122 ** we do not have to sort. The OP_OpenEphemeral table will be
83304 ** will therefore be cheaper to scan to determine the query result.
83309 ** In practice the KeyInfo structure will not be used. It is only
83345 ** A special flag must be passed to sqlite3WhereBegin() to slightly
83420 /* Identify column names if results of the SELECT are to be output.
83443 ** code base. Then are intended to be called from within the debugger
83544 ** These routines are in a separate files so that they will not be linked
83640 ** Instead, the entire table should be passed to sqlite3_free_table() when
83645 const char *zSql, /* The SQL to be executed */
83762 ** are already attached to pTab->pTrigger. But there might be additional
83824 assert( pName1!=0 ); /* pName1->z might be NULL, but not pName1 itself */
83829 /* If TEMP was specified, then the trigger name may not be qualified. */
83837 /* Figure out the db that the the trigger will be created in */
83873 ** drop so the trigger cannot be dropped. This results in an
84104 ExprList *pEList, /* The VALUE clause: a list of values to be inserted */
84135 Token *pTableName, /* Name of the table to be updated */
84190 ** This may be called directly from the parser and therefore identifies
84337 ** one trigger that must be fired when an operation of type 'op' is
84378 SrcList *pSrc; /* SrcList to be returned */
84411 /* Figure out the ON CONFLICT policy that will be used for this step
84629 /* It may be that this trigger has already been coded (or is in the
84631 ** a matching TriggerPrg.pTrigger field will be present somewhere
84638 /* If an existing TriggerPrg could not be located, create a new one. */
84710 ** never be accessed by the trigger program, so they are not allocated or
84743 ** always defined. The trigger must be in the same schema as the table
84744 ** or else it must be a TEMP trigger. */
84764 ** may be used by the caller, for example, to avoid having to load the entire
84768 ** table may be accessed using an [old|new].<col> reference. Bit 1 is set if
84771 ** with an index greater than 32 may be accessed, 0xffffffff is returned.
84776 ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
84779 ** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE
84837 SrcList *pSrc, /* The virtual table to be modified */
84907 ExprList *pChanges, /* Things to be changed */
84908 Expr *pWhere, /* The WHERE clause. May be null */
84912 Table *pTab; /* The table to be updated */
84920 int *aRegIdx = 0; /* One register assigned to each index to be updated */
84926 int openAll = 0; /* True if all indices need to be opened */
84946 int regRowSet = 0; /* Rowset of rows to be updated */
84990 ** The index cursors might not be used, but if they are used they
85006 ** for each column to be updated in the pChanges array. For each
85007 ** column to be updated, make sure we have authorization to change
85052 ** the value with a register number for indices that are to be used
85083 /* Virtual tables must be handled separately */
85134 /* Remember the rowid of every item to be updated.
85158 ** to be deleting some records.
85234 ** values for registers not modified by the UPDATE must be reloaded from
85237 ** be used eliminates some redundant opcodes.
85250 /* This branch loads the value of a column that will not be changed
85339 /* Repeat the above with the next record to be updated, until
85396 ** for each row to be changed:
85413 SrcList *pSrc, /* The virtual table to be modified */
85452 ** be stored.
85499 ** Most of the code in this file may be omitted by defining the
85596 /* Save the current value of the database flags so that it can be
85611 ** can be set to 'off' for this file, as it is not recovered if a crash
85616 ** An optimisation would be to use a non-journaled pager.
85741 ** temporary database never needs to be committed.
85899 ** Lock the virtual table so that it cannot be disconnected.
85947 ** database connections to be disconnected at the next opportunity.
85988 ** This function may only be called when the mutexes associated with all
85994 ** associated with the database handle itself must be held.
86002 ** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously
86050 ** string will be freed automatically when the table is
86195 ** allows a schema that contains virtual tables to be loaded before
86568 ** Set *pzErrmsg to point to a buffer that should be released using
86817 ** A WhereTerm might also be two or more subterms connected by OR:
86834 ** bits that will fit in a Bitmask. The VDBE cursor numbers might be
86836 ** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45. The WhereMaskSet
86840 ** would be mapped into integers 0 through 7.
86932 ** 57->5, 73->4. Or one of 719 other combinations might be used. It
86955 ** OR-ed combination of these values can be used when searching for
86980 ** is set to WO_IN|WO_EQ. The WhereLevel.wsFlags field can then be used as
86982 ** ISNULL constraints will then not be used on the right table of a left
87006 WhereClause *pWC, /* The WhereClause to be initialized */
87064 ** 0 is returned if the new WhereTerm could not be added due to a memory
87065 ** allocation error. The memory allocation failure will be recorded in
87075 ** WhereTerms. All pointers to WhereTerms should be invalidated after
87076 ** calling this routine. Such pointers may be reinitialized by referencing
87304 WhereClause *pWC, /* The WHERE clause to be searched */
87309 Index *pIdx /* Must be compatible with this index, if not NULL */
87332 ** it to be useful for optimising expression pX. Store this
87360 WhereClause *pWC /* the WHERE clause to be analyzed */
87371 ** can be optimized using inequality constraints. Return TRUE if it is
87374 ** In order for the operator to be optimizible, the RHS must be a string
87405 ** be the name of an indexed column with TEXT affinity. */
87456 ** function, then no OP_Variable will be added to the program.
87532 ** A single subterm might be a set of AND-connected sub-subterms.
87570 ** potentially be used with an index if an appropriate index exists.
87580 ** It might be the case that multiple tables are indexable. For example,
87596 int idxTerm /* Index of the OR-term to be analyzed */
87600 WhereTerm *pTerm = &pWC->a[idxTerm]; /* The term to be analyzed */
87682 ** Record the set of tables that satisfy case 2. The set might be
87702 ** might be possible to form an IN operator with either table1.column
87707 ** same table on both sizes of the ==) cannot be optimized.
87717 ** will be recorded in iCursor and iColumn. There might not be any
87733 /* This term must be of the form t1.a==t2.b where t2 is in the
87734 ** chngToIN set but t1 is not. This term will be either preceeded
87768 ** of both right and left sides must be such that no type
87839 ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it
87846 int idxTerm /* Index of the term to be analyzed */
87848 WhereTerm *pTerm; /* The term to be analyzed */
87850 Expr *pExpr; /* The expression to be analyzed */
87885 extraRight = x-1; /* ON clause terms may not be used with an index
88101 ** This routine decides if pIdx can be used to satisfy the ORDER BY
88110 ** constraints. Any of these columns may be missing from the ORDER BY
88111 ** clause and the match can still be a success.
88113 ** All terms of the ORDER BY that match against the index must be either
88123 int base, /* Cursor number for the table to be sorted */
88204 /* Indices can only be used if all ORDER BY terms past the
88216 ** tables in the join, then we are assured that the index can be used
88227 ** this index can be used for sorting. */
88243 ** The results need not be exact. This is only used for estimating
88309 ** This routine attempts to find an scanning strategy that can be used
88312 ** The table associated with FROM clause term pSrc may be either a
88324 const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */
88551 ** In a join, this routine might be called multiple times for the
88601 /* The module name must be defined. Also, by this point there must
88602 ** be a pointer to an sqlite3_vtab structure. Otherwise
88625 ** join might be different so we have to recompute the usable flag
88661 /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
88663 ** (cost<lowestCost) test below will never be true.
88691 ** may be thought of as divided into (SQLITE_INDEX_SAMPLES+1) regions.
88726 /* pVal comes from sqlite3ValueFromExpr() so the type cannot be NULL */
88818 ** This function is used to estimate the number of rows that will be visited
88839 ** then nEq should be passed the value 1 (as the range restricted column,
88844 ** then nEq should be passed 0.
88862 WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */
88863 WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
88941 ** * The estimated number of rows that will be retrieved. (The
88946 ** * Whether or not there must be separate lookups in the
88968 int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */
89046 ** Number of equality terms that can be implemented using the index.
89073 ** An estimate on the amount of the table that must be searched. A
89168 ** index), determine if all required column data may be obtained without
89217 /* If all information can be taken directly from the index, we avoid
89219 ** this needs to be fixed.)
89255 ** is set, then reverse the order that the index will be scanned
89322 ** Disabling a term causes that term to not be tested in the inner loop
89387 ** term can be either X=expr or X IN (...). pTerm is the term to be
89398 WhereTerm *pTerm, /* The term of the WHERE clause to be coded */
89459 ** a==5 and b IN (1,2,3). The current values for a and b will be stored
89485 ** no conversion should be attempted before using a t2.b value as part of
89487 ** string in this example would be set to SQLITE_AFF_NONE.
89565 int iLevel, /* Which level of pWInfo->a[] should be coded */
89574 WhereLevel *pLevel; /* The where level to be coded */
89760 ** the right-most column can be an inequality - the rest must
89771 ** The z<10 term of the following cannot be used, only
89776 ** N may be zero if there are inequality constraints.
89809 Index *pIdx; /* The index we will be using */
89882 /* Since the comparison is to be performed with no conversions
89920 /* Since the comparison is to be performed with no conversions
90100 ** terms from the notReady table could not be tested and will
90101 ** need to be tested later.
90134 /* Insert code to test every subexpression that can be completely
90246 ** Note that the loops might not be nested in the order in which they
90265 ** refer to those indices, a complete table scan can be avoided and the
90267 ** to see if there are indices that can be used to speed up the loop.
90299 ** If an index can be used so that the natural output order of the table
90305 ** If the where clause loops cannot be arranged to provide the correct
90310 SrcList *pTabList, /* A list of all tables to be scanned */
90348 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
90387 ** When assigning bitmask values to FROM clause cursors, it must be
90403 ** equal to pTabList->nSrc but might be shortened to 1 if the
90468 ** next nested loop. The FROM clause entries may be iterated through
90474 ** for the given FROM clause entry as would be selected if the entry
90476 ** is chosen such that the cost of running that table cannot be reduced
90503 int doNotReorder; /* True if this table should not be reordered */
90821 ** the table need never be read from. This is a performance boost,
90937 ** new Expr to populate pOut. Set the span of pOut to be the identifier
91000 ** This section will be null unless lemon is run with the -m switch.
91025 ** have fall-back values which should be used if the
91088 /* Define the yytestcase() macro to be a no-op if is not already defined
91093 ** code the yytestcase() macro should be turned off. But it is useful
91129 ** and that yy_default[S] should be used instead.
91750 ** <li> A FILE* to which trace output should be written.
92230 ** symbol. The symbol can be either a terminal or nonterminal.
92237 YYMINORTYPE *yypminor /* The object to be destroyed */
92334 /* There is no mechanism by which the parser stack can be popped below
92356 ** <li> A pointer to the parser. This should be a pointer
92363 void *p, /* The parser to be deleted */
92512 yyParser *yypParser, /* The parser to be shifted */
94067 /* Here code is inserted which will be executed whenever the
94104 /* Here code is inserted which will be executed whenever the
94304 ** need to be translated.
94353 ** might be implemented more directly using a hand-written hash table.
94621 ** If X is a character that can be used in an identifier then
94622 ** IdChar(X) will be true. Otherwise it is false.
94626 ** sqlite3IsIdChar[X] must be 1.
95097 ** This code used to be part of the tokenizer.c source file. But by
95098 ** separating it out, the code will be automatically omitted from
95157 ** (5) TRIGGER We are in the middle of a trigger definition that must be
95182 ** to recognize the end of a trigger can be omitted. All we have to do
95340 ** above, except that the parameter is required to be UTF-16 encoded, not
95381 ** other files are for internal use by SQLite and should not be
95508 ** name of a directory, then that directory will be used to store
95518 ** This routine must be called to initialize the memory allocation,
95521 ** this routine will be called automatically by key routines such as
95536 ** Let X be the first thread to enter this routine. Let Y be some other
95558 ** to sqlite3_initialize() should be a no-op. But the initialization
95559 ** must be complete. So isInit must not be set until the very end
95567 ** there is not much SQLite is going to be able to do.
95603 ** subsystem could not be initialized or the system failed to allocate
95610 ** that we will be able to handle recursive calls into
95613 ** recursive calls might also be possible.
95672 ** Undo the effects of sqlite3_initialize(). Must not be called while
95705 ** This routine should only be called when there are no outstanding
95880 /* The size of a lookaside slot needs to be larger than a pointer
95881 ** to be useful.
95992 ** This collating sequence is intended to be used for "case independant
96035 ** database handle object, it does not close any savepoints that may be open
96070 ** SQL statements below, as the v-table implementation may be storing
96159 ** So it needs to be freed here. Todo: Why not roll the temp schema into
96336 ** be invoked every nOps opcodes.
96383 ** that it is designed to be called by internal code. The difference is
96586 ** Register a function to be invoked when a transaction comments.
96605 ** Register a callback to be invoked each time a row is updated,
96623 ** Register a callback to be invoked each time a transaction is rolled
96641 ** This function returns true if main-memory should be used instead of
96683 ** A virtual database can be either a disk file (that is automatically
96684 ** deleted when the file is closed) or it an be held entirely in memory.
96791 ** be cleared before returning. Do this directly, instead of via
96872 ** then any copies made by synthCollSeq() need to be invalidated.
96874 ** to be called.
96906 ** initializer must be kept in sync with the SQLITE_LIMIT_*
96927 # error SQLITE_MAX_LENGTH must be at least 100
96930 # error SQLITE_MAX_SQL_LENGTH must be at least 100
96933 # error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH
96936 # error SQLITE_MAX_COMPOUND_SELECT must be at least 2
96939 # error SQLITE_MAX_VDBE_OP must be at least 40
96942 # error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000
96945 # error SQLITE_MAX_ATTACHED must be between 0 and 30
96948 # error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1
96954 # error SQLITE_MAX_TRIGGER_DEPTH must be at least 1
97398 ** This function is now an anachronism. It used to be used to recover from a
97522 /* The following block stores the meta information that will be returned
97790 ** argument N is a bitmask of optimizations to be disabled. For normal
97791 ** operation N should be 0. The idea is that a test program (like the
98020 ** to the user because it requires a lock that will not be available
98093 ** be passed to the unlock-notify callback is larger than the
98099 ** is returned the transaction on connection db will still be
98113 ** connections. But it is the best that can be done under the
98193 ** are built from the bottom up, things will be described from the
98292 ** likely to be query targets.
98294 ** TODO(shess) It may be useful for blocking decisions to be more
98306 ** itself grows too big and must be split. The format of interior
98330 ** than pTerm[i+1], the subtree for that term will be rooted at
98351 ** This could be either a leaf node or an interior node. If the top
98390 ** MERGE_COUNT controls how often we merge segments. 16 seems to be
98398 ** which need to be scanned and merged. For instance, with 100k docs
98409 ** costs), and infrequent and non-existent terms still seem to be fast
98412 ** TODO(shess) That said, it would be nice to have a better query-side
98431 ** deletions and duplications. This would basically be a forced merge
98489 ** If tokenizers are to be allowed to call sqlite3_*() functions, then
98504 ** be used for the fts3 table (customized by the tokenizer clause arguments).
98508 ** that may be used to tokenize a specific input buffer based on
98519 ** Structure version. Should always be set to 0.
98535 ** code. If SQLITE_OK is returned, then *ppTokenizer should be set
98537 ** sqlite3_tokenizer.pModule variable should not be initialised by
98575 ** *ppToken should be set to point at a buffer containing the
98577 ** stemming has been performed). *pnBytes should be set to the length
98580 ** *piEndOffset. *piStartOffset should be set to the index of the first
98581 ** byte of the token in the input buffer. *piEndOffset should be set
98586 ** implementation. It is only required to be valid until the next call
98589 /* TODO(shess) current implementation requires pInput to be
98590 ** nul-terminated. This should either be fixed, or pInput/nBytes
98591 ** should be converted to zInput.
98646 ** The internals of this structure are intended to be opaque -- client
98668 ** Again, this structure is intended to be opaque, but it can't really
98669 ** be opaque because it is used by macros.
98770 ** FTS3 extension to be compiled outside of the
98869 ** Actualy, Fts3Cursor.eSearch can be greater than or equal to
98871 ** of the column to be searched. For example, in
98877 ** Fts3Cursor.eSearch will be set to FTS3_FULLTEXT_SEARCH+1. (+0 for a,
98879 ** indicating that all columns should be searched,
98880 ** then eSearch would be set to FTS3_FULLTEXT_SEARCH+4.
98889 ** For a sequence of tokens contained in "...", nToken will be the number
98914 ** be used to accelerate seeking to the required docid within the doclist.
99033 ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
99590 ** root node of a b-tree segment. The segment is guaranteed to be at least
99600 ** to be sure.
99668 ** specified term may be present on leaf node iChild.
99755 ** (in which case **pp will be 0x00 or 0x01).
100018 ** Values that may be used as the first parameter to fts3DoclistMerge().
100032 ** which is guaranteed to be large enough to hold the results. The number
100254 ** The returned doclist may be in one of two formats, depending on the
100293 ** may be a contiguous block of leaves.
100296 ** (unless the root node happens to be a leaf). It simply examines the
100297 ** b-tree structure to determine which leaves need to be inspected.
100305 /* The entire segment is stored on the root node (which must be a
100422 ** output of this function, the positions can be dropped as part
100423 ** of this merge. Either way, the result of this merge will be
100655 ** rowid should be written to *pRowid.
100680 /* The column value supplied by SQLite must be in range. */
100707 ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be
100856 /* There must be at least one argument passed to this function (otherwise
100895 /* There must be at least one argument passed to this function (otherwise
101248 ** be tested using a single build of testfixture.
101301 ** The standard isspace() can be awkward to use safely, because although it
101571 /* At this point this is probably a keyword. But for that to be true,
101634 /* If control flows to this point, this must be a regular token, or
101891 ** Column names must be nul-terminated strings.
101893 ** The iDefaultCol parameter should be passed the index of the table column
102028 ** expression parser. It should be called as follows:
102176 ** "pNew" is a pointer to the hash table that is to be initialized.
102255 ** The C syntax in this function definition may be unfamilar to some
102293 Fts3HashElem *pNew /* The element to be inserted */
102315 ** "new_size" must be a power of 2. The hash table might fail
102345 const Fts3Hash *pH, /* The pH to be searched */
102374 Fts3HashElem* elem, /* The element to be removed from the pH */
102555 int iToken; /* index of next token to be returned */
102590 ** string to be tokenized is zInput[0..nInput-1]. A cursor
102596 const char *zInput, int nInput, /* String to be tokenized */
102675 ** Let any sequence of one or more vowels be represented by V and let
102676 ** C be sequence of one or more consonants. Then every word can be
102752 ** first three letters and the first one cannot be in [wxy].
102778 int (*xCond)(const char*) /* Condition that must be true */
103064 ** Characters that can be part of a token. We assume any character
103065 ** whose value is greater than 0x80 (any UTF character) can be
103186 ** hash table. This function may be called as follows:
103194 ** If the <pointer> argument is specified, it must be a blob value
103195 ** containing a pointer to be stored as the hash data corresponding
103373 ** designed to be used in concert with the Tcl testing framework. This
103374 ** function must be called with two arguments:
103383 ** The return value is a string that may be interpreted as a Tcl
103541 ** can be used as designed by the C-code in the queryTokenizer and
103686 int iToken; /* index of next token to be returned */
103710 ** else we need to reindex. One solution would be a meta-table to
103747 ** string to be tokenized is pInput[0..nBytes-1]. A cursor
103753 const char *pInput, int nBytes, /* String to be tokenized */
103940 /* Variables set by fts3SegReaderNext(). These may be read directly
104173 ** Set *ppStmt to a statement handle that may be used to iterate through
104338 /* Positions cannot be negative; we use -1 as a terminator internally.
104510 ** (an integer) of a row about to be deleted. Remove all terms from the
104726 ** so that it can be reused when required by another query.
104930 ** The second argument to this function is expected to be a statement of
105185 /* An unusual case: this is the first term to be added to the node
105190 ** this is not expected to be a serious problem.
105359 ** be passed NULL. This function will allocate a new SegmentWriter object
105367 int isCopyTerm, /* True if buffer zTerm must be copied */
105426 ** a) be greater than the largest term on the leaf node just written
105429 ** b) be less than or equal to the term about to be added to the new
105432 ** In other words, it must be the prefix of zTerm 1 byte longer than
105471 /* Save the current term so that it can be used to prefix-compress the next.
105498 ** database. This function must be called after all terms have been added
105840 ** of Fts3SegReader objects is the same. The doclists must be merged
106437 Snippet *pSnippet, /* The Snippet object to be filled in */
106513 ** This function removes any entries that should not be present after
106536 Snippet *pSnippet, /* The set of snippet offsets to be trimmed */
106558 ** then iLeft will be set to 2 (token number of ghi) and nToken will
106559 ** be set to 4.
106583 ** If one cannot be found, then remove snippets ii..(ii+N-1)
106726 ** of matching words some of which might be in zDoc. zDoc is column
106731 ** to be a little left or right so that the break point is better.
107012 ** calls to fts3LoadSnippetBuffer() with the same arguments will be no-ops),
107571 /* Either, both or none of the following may be set to activate
107578 ** Exactly one of the following must be set to 1.
108315 ** would be filtered (excluded) by the constraints in the
108665 ** and then a linear search of an R-Tree node. This should be
108686 ** A <= or < can be used if there is a prior >= or >.
108687 ** A >= or > can be used if there is a prior < or <=.
108901 /* Select the child node which will be enlarged the least if pCell
109630 ** the Rtree.pDeleted list. Its contents will be re-inserted later on.
109915 ** about to be deleted.
110301 ** human readable strings. This can be used for debugging and analysis.
110496 ** 4. uPattern is to be handled as an ordinary character
110591 "ESCAPE expression must be a single character", -1);
110718 ** should be invoked with two arguments. The second argument is the name
110804 ** types to an SQLite database connection. It is intended to be called
110992 ** string to be tokenized is pInput[0..nBytes-1]. A cursor