summaryrefslogtreecommitdiff
path: root/c/loadable-ext-sqlite3.h
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2023-11-26 16:23:55 +0100
committerGravatar Vincent Rischmann2023-11-26 16:23:55 +0100
commitf90936c695aac7fc2ec5b0ab84cade51695f15b3 (patch)
tree977b9531a435238c28432e7b0eb6f1e5dc670be2 /c/loadable-ext-sqlite3.h
parentMerge branch 'fix-latest-zig' (diff)
downloadzig-sqlite-f90936c695aac7fc2ec5b0ab84cade51695f15b3.tar.gz
zig-sqlite-f90936c695aac7fc2ec5b0ab84cade51695f15b3.tar.xz
zig-sqlite-f90936c695aac7fc2ec5b0ab84cade51695f15b3.zip
run 'preprocess-files' to update the C headers
Diffstat (limited to 'c/loadable-ext-sqlite3.h')
-rw-r--r--c/loadable-ext-sqlite3.h764
1 files changed, 583 insertions, 181 deletions
diff --git a/c/loadable-ext-sqlite3.h b/c/loadable-ext-sqlite3.h
index 3895f81..6ca6914 100644
--- a/c/loadable-ext-sqlite3.h
+++ b/c/loadable-ext-sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
146** [sqlite3_libversion_number()], [sqlite3_sourceid()], 146** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147** [sqlite_version()] and [sqlite_source_id()]. 147** [sqlite_version()] and [sqlite_source_id()].
148*/ 148*/
149#define SQLITE_VERSION "3.39.3" 149#define SQLITE_VERSION "3.44.0"
150#define SQLITE_VERSION_NUMBER 3039003 150#define SQLITE_VERSION_NUMBER 3044000
151#define SQLITE_SOURCE_ID "2022-09-05 11:02:23 4635f4a69c8c2a8df242b384a992aea71224e39a2ccab42d8c0b0602f1e826e8" 151#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301"
152 152
153/* 153/*
154** CAPI3REF: Run-Time Library Version Numbers 154** CAPI3REF: Run-Time Library Version Numbers
@@ -513,6 +513,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
513#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) 513#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
514#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8)) 514#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
515#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8)) 515#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
516#define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
516#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) 517#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
517#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8)) 518#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
518#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) 519#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
@@ -548,6 +549,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
548#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8)) 549#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8))
549#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) 550#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
550#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) 551#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
552#define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
551#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) 553#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
552#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) 554#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
553#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) 555#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
@@ -655,13 +657,17 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
655** 657**
656** SQLite uses one of these integer values as the second 658** SQLite uses one of these integer values as the second
657** argument to calls it makes to the xLock() and xUnlock() methods 659** argument to calls it makes to the xLock() and xUnlock() methods
658** of an [sqlite3_io_methods] object. 660** of an [sqlite3_io_methods] object. These values are ordered from
661** lest restrictive to most restrictive.
662**
663** The argument to xLock() is always SHARED or higher. The argument to
664** xUnlock is either SHARED or NONE.
659*/ 665*/
660#define SQLITE_LOCK_NONE 0 666#define SQLITE_LOCK_NONE 0 /* xUnlock() only */
661#define SQLITE_LOCK_SHARED 1 667#define SQLITE_LOCK_SHARED 1 /* xLock() or xUnlock() */
662#define SQLITE_LOCK_RESERVED 2 668#define SQLITE_LOCK_RESERVED 2 /* xLock() only */
663#define SQLITE_LOCK_PENDING 3 669#define SQLITE_LOCK_PENDING 3 /* xLock() only */
664#define SQLITE_LOCK_EXCLUSIVE 4 670#define SQLITE_LOCK_EXCLUSIVE 4 /* xLock() only */
665 671
666/* 672/*
667** CAPI3REF: Synchronization Type Flags 673** CAPI3REF: Synchronization Type Flags
@@ -739,7 +745,14 @@ struct sqlite3_file {
739** <li> [SQLITE_LOCK_PENDING], or 745** <li> [SQLITE_LOCK_PENDING], or
740** <li> [SQLITE_LOCK_EXCLUSIVE]. 746** <li> [SQLITE_LOCK_EXCLUSIVE].
741** </ul> 747** </ul>
742** xLock() increases the lock. xUnlock() decreases the lock. 748** xLock() upgrades the database file lock. In other words, xLock() moves the
749** database file lock in the direction NONE toward EXCLUSIVE. The argument to
750** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
751** SQLITE_LOCK_NONE. If the database file lock is already at or above the
752** requested lock, then the call to xLock() is a no-op.
753** xUnlock() downgrades the database file lock to either SHARED or NONE.
754* If the lock is already at or below the requested lock state, then the call
755** to xUnlock() is a no-op.
743** The xCheckReservedLock() method checks whether any database connection, 756** The xCheckReservedLock() method checks whether any database connection,
744** either in this process or in some other process, is holding a RESERVED, 757** either in this process or in some other process, is holding a RESERVED,
745** PENDING, or EXCLUSIVE lock on the file. It returns true 758** PENDING, or EXCLUSIVE lock on the file. It returns true
@@ -844,9 +857,8 @@ struct sqlite3_io_methods {
844** opcode causes the xFileControl method to write the current state of 857** opcode causes the xFileControl method to write the current state of
845** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], 858** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
846** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) 859** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
847** into an integer that the pArg argument points to. This capability 860** into an integer that the pArg argument points to.
848** is used during testing and is only available when the SQLITE_TEST 861** This capability is only available if SQLite is compiled with [SQLITE_DEBUG].
849** compile-time option is used.
850** 862**
851** <li>[[SQLITE_FCNTL_SIZE_HINT]] 863** <li>[[SQLITE_FCNTL_SIZE_HINT]]
852** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS 864** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
@@ -1150,7 +1162,6 @@ struct sqlite3_io_methods {
1150** in wal mode after the client has finished copying pages from the wal 1162** in wal mode after the client has finished copying pages from the wal
1151** file to the database file, but before the *-shm file is updated to 1163** file to the database file, but before the *-shm file is updated to
1152** record the fact that the pages have been checkpointed. 1164** record the fact that the pages have been checkpointed.
1153** </ul>
1154** 1165**
1155** <li>[[SQLITE_FCNTL_EXTERNAL_READER]] 1166** <li>[[SQLITE_FCNTL_EXTERNAL_READER]]
1156** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect 1167** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect
@@ -1163,10 +1174,16 @@ struct sqlite3_io_methods {
1163** the database is not a wal-mode db, or if there is no such connection in any 1174** the database is not a wal-mode db, or if there is no such connection in any
1164** other process. This opcode cannot be used to detect transactions opened 1175** other process. This opcode cannot be used to detect transactions opened
1165** by clients within the current process, only within other processes. 1176** by clients within the current process, only within other processes.
1166** </ul>
1167** 1177**
1168** <li>[[SQLITE_FCNTL_CKSM_FILE]] 1178** <li>[[SQLITE_FCNTL_CKSM_FILE]]
1169** Used by the cksmvfs VFS module only. 1179** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the
1180** [checksum VFS shim] only.
1181**
1182** <li>[[SQLITE_FCNTL_RESET_CACHE]]
1183** If there is currently no transaction open on the database, and the
1184** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control
1185** purges the contents of the in-memory page cache. If there is an open
1186** transaction, or if the db is a temp-db, this opcode is a no-op, not an error.
1170** </ul> 1187** </ul>
1171*/ 1188*/
1172#define SQLITE_FCNTL_LOCKSTATE 1 1189#define SQLITE_FCNTL_LOCKSTATE 1
@@ -1209,6 +1226,7 @@ struct sqlite3_io_methods {
1209#define SQLITE_FCNTL_CKPT_START 39 1226#define SQLITE_FCNTL_CKPT_START 39
1210#define SQLITE_FCNTL_EXTERNAL_READER 40 1227#define SQLITE_FCNTL_EXTERNAL_READER 40
1211#define SQLITE_FCNTL_CKSM_FILE 41 1228#define SQLITE_FCNTL_CKSM_FILE 41
1229#define SQLITE_FCNTL_RESET_CACHE 42
1212 1230
1213/* deprecated names */ 1231/* deprecated names */
1214#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE 1232#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -1239,6 +1257,26 @@ typedef struct sqlite3_mutex sqlite3_mutex;
1239typedef struct sqlite3_api_routines sqlite3_api_routines; 1257typedef struct sqlite3_api_routines sqlite3_api_routines;
1240 1258
1241/* 1259/*
1260** CAPI3REF: File Name
1261**
1262** Type [sqlite3_filename] is used by SQLite to pass filenames to the
1263** xOpen method of a [VFS]. It may be cast to (const char*) and treated
1264** as a normal, nul-terminated, UTF-8 buffer containing the filename, but
1265** may also be passed to special APIs such as:
1266**
1267** <ul>
1268** <li> sqlite3_filename_database()
1269** <li> sqlite3_filename_journal()
1270** <li> sqlite3_filename_wal()
1271** <li> sqlite3_uri_parameter()
1272** <li> sqlite3_uri_boolean()
1273** <li> sqlite3_uri_int64()
1274** <li> sqlite3_uri_key()
1275** </ul>
1276*/
1277typedef const char *sqlite3_filename;
1278
1279/*
1242** CAPI3REF: OS Interface Object 1280** CAPI3REF: OS Interface Object
1243** 1281**
1244** An instance of the sqlite3_vfs object defines the interface between 1282** An instance of the sqlite3_vfs object defines the interface between
@@ -1416,7 +1454,7 @@ struct sqlite3_vfs {
1416 sqlite3_vfs *pNext; /* Next registered VFS */ 1454 sqlite3_vfs *pNext; /* Next registered VFS */
1417 const char *zName; /* Name of this virtual file system */ 1455 const char *zName; /* Name of this virtual file system */
1418 void *pAppData; /* Pointer to application-specific data */ 1456 void *pAppData; /* Pointer to application-specific data */
1419 int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, 1457 int (*xOpen)(sqlite3_vfs*, sqlite3_filename zName, sqlite3_file*,
1420 int flags, int *pOutFlags); 1458 int flags, int *pOutFlags);
1421 int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); 1459 int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
1422 int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); 1460 int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
@@ -1599,20 +1637,23 @@ struct sqlite3_vfs {
1599** must ensure that no other SQLite interfaces are invoked by other 1637** must ensure that no other SQLite interfaces are invoked by other
1600** threads while sqlite3_config() is running.</b> 1638** threads while sqlite3_config() is running.</b>
1601** 1639**
1602** The sqlite3_config() interface
1603** may only be invoked prior to library initialization using
1604** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1605** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1606** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1607** Note, however, that ^sqlite3_config() can be called as part of the
1608** implementation of an application-defined [sqlite3_os_init()].
1609**
1610** The first argument to sqlite3_config() is an integer 1640** The first argument to sqlite3_config() is an integer
1611** [configuration option] that determines 1641** [configuration option] that determines
1612** what property of SQLite is to be configured. Subsequent arguments 1642** what property of SQLite is to be configured. Subsequent arguments
1613** vary depending on the [configuration option] 1643** vary depending on the [configuration option]
1614** in the first argument. 1644** in the first argument.
1615** 1645**
1646** For most configuration options, the sqlite3_config() interface
1647** may only be invoked prior to library initialization using
1648** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1649** The exceptional configuration options that may be invoked at any time
1650** are called "anytime configuration options".
1651** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1652** [sqlite3_shutdown()] with a first argument that is not an anytime
1653** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
1654** Note, however, that ^sqlite3_config() can be called as part of the
1655** implementation of an application-defined [sqlite3_os_init()].
1656**
1616** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. 1657** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1617** ^If the option is unknown or SQLite is unable to set the option 1658** ^If the option is unknown or SQLite is unable to set the option
1618** then this routine returns a non-zero [error code]. 1659** then this routine returns a non-zero [error code].
@@ -1718,6 +1759,23 @@ struct sqlite3_mem_methods {
1718** These constants are the available integer configuration options that 1759** These constants are the available integer configuration options that
1719** can be passed as the first argument to the [sqlite3_config()] interface. 1760** can be passed as the first argument to the [sqlite3_config()] interface.
1720** 1761**
1762** Most of the configuration options for sqlite3_config()
1763** will only work if invoked prior to [sqlite3_initialize()] or after
1764** [sqlite3_shutdown()]. The few exceptions to this rule are called
1765** "anytime configuration options".
1766** ^Calling [sqlite3_config()] with a first argument that is not an
1767** anytime configuration option in between calls to [sqlite3_initialize()] and
1768** [sqlite3_shutdown()] is a no-op that returns SQLITE_MISUSE.
1769**
1770** The set of anytime configuration options can change (by insertions
1771** and/or deletions) from one release of SQLite to the next.
1772** As of SQLite version 3.42.0, the complete set of anytime configuration
1773** options is:
1774** <ul>
1775** <li> SQLITE_CONFIG_LOG
1776** <li> SQLITE_CONFIG_PCACHE_HDRSZ
1777** </ul>
1778**
1721** New configuration options may be added in future releases of SQLite. 1779** New configuration options may be added in future releases of SQLite.
1722** Existing configuration options might be discontinued. Applications 1780** Existing configuration options might be discontinued. Applications
1723** should check the return code from [sqlite3_config()] to make sure that 1781** should check the return code from [sqlite3_config()] to make sure that
@@ -2048,7 +2106,7 @@ struct sqlite3_mem_methods {
2048** is stored in each sorted record and the required column values loaded 2106** is stored in each sorted record and the required column values loaded
2049** from the database as records are returned in sorted order. The default 2107** from the database as records are returned in sorted order. The default
2050** value for this option is to never use this optimization. Specifying a 2108** value for this option is to never use this optimization. Specifying a
2051** negative value for this option restores the default behaviour. 2109** negative value for this option restores the default behavior.
2052** This option is only available if SQLite is compiled with the 2110** This option is only available if SQLite is compiled with the
2053** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. 2111** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
2054** 2112**
@@ -2064,28 +2122,28 @@ struct sqlite3_mem_methods {
2064** compile-time option is not set, then the default maximum is 1073741824. 2122** compile-time option is not set, then the default maximum is 1073741824.
2065** </dl> 2123** </dl>
2066*/ 2124*/
2067#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ 2125#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
2068#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ 2126#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
2069#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ 2127#define SQLITE_CONFIG_SERIALIZED 3 /* nil */
2070#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ 2128#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */
2071#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ 2129#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */
2072#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */ 2130#define SQLITE_CONFIG_SCRATCH 6 /* No longer used */
2073#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ 2131#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */
2074#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ 2132#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */
2075#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ 2133#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */
2076#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ 2134#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */
2077#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ 2135#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
2078/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ 2136/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
2079#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ 2137#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
2080#define SQLITE_CONFIG_PCACHE 14 /* no-op */ 2138#define SQLITE_CONFIG_PCACHE 14 /* no-op */
2081#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ 2139#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
2082#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ 2140#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
2083#define SQLITE_CONFIG_URI 17 /* int */ 2141#define SQLITE_CONFIG_URI 17 /* int */
2084#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ 2142#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
2085#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ 2143#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
2086#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ 2144#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
2087#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ 2145#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
2088#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ 2146#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
2089#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ 2147#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
2090#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ 2148#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
2091#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ 2149#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
@@ -2126,7 +2184,7 @@ struct sqlite3_mem_methods {
2126** configuration for a database connection can only be changed when that 2184** configuration for a database connection can only be changed when that
2127** connection is not currently using lookaside memory, or in other words 2185** connection is not currently using lookaside memory, or in other words
2128** when the "current value" returned by 2186** when the "current value" returned by
2129** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero. 2187** [sqlite3_db_status](D,[SQLITE_DBSTATUS_LOOKASIDE_USED],...) is zero.
2130** Any attempt to change the lookaside memory configuration when lookaside 2188** Any attempt to change the lookaside memory configuration when lookaside
2131** memory is in use leaves the configuration unchanged and returns 2189** memory is in use leaves the configuration unchanged and returns
2132** [SQLITE_BUSY].)^</dd> 2190** [SQLITE_BUSY].)^</dd>
@@ -2223,7 +2281,7 @@ struct sqlite3_mem_methods {
2223** database handle, SQLite checks if this will mean that there are now no 2281** database handle, SQLite checks if this will mean that there are now no
2224** connections at all to the database. If so, it performs a checkpoint 2282** connections at all to the database. If so, it performs a checkpoint
2225** operation before closing the connection. This option may be used to 2283** operation before closing the connection. This option may be used to
2226** override this behaviour. The first parameter passed to this operation 2284** override this behavior. The first parameter passed to this operation
2227** is an integer - positive to disable checkpoints-on-close, or zero (the 2285** is an integer - positive to disable checkpoints-on-close, or zero (the
2228** default) to enable them, and negative to leave the setting unchanged. 2286** default) to enable them, and negative to leave the setting unchanged.
2229** The second parameter is a pointer to an integer 2287** The second parameter is a pointer to an integer
@@ -2276,8 +2334,12 @@ struct sqlite3_mem_methods {
2276** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0); 2334** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
2277** </ol> 2335** </ol>
2278** Because resetting a database is destructive and irreversible, the 2336** Because resetting a database is destructive and irreversible, the
2279** process requires the use of this obscure API and multiple steps to help 2337** process requires the use of this obscure API and multiple steps to
2280** ensure that it does not happen by accident. 2338** help ensure that it does not happen by accident. Because this
2339** feature must be capable of resetting corrupt databases, and
2340** shutting down virtual tables may require access to that corrupt
2341** storage, the library must abandon any installed virtual tables
2342** without calling their xDestroy() methods.
2281** 2343**
2282** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt> 2344** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>
2283** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the 2345** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the
@@ -2288,6 +2350,7 @@ struct sqlite3_mem_methods {
2288** <ul> 2350** <ul>
2289** <li> The [PRAGMA writable_schema=ON] statement. 2351** <li> The [PRAGMA writable_schema=ON] statement.
2290** <li> The [PRAGMA journal_mode=OFF] statement. 2352** <li> The [PRAGMA journal_mode=OFF] statement.
2353** <li> The [PRAGMA schema_version=N] statement.
2291** <li> Writes to the [sqlite_dbpage] virtual table. 2354** <li> Writes to the [sqlite_dbpage] virtual table.
2292** <li> Direct writes to [shadow tables]. 2355** <li> Direct writes to [shadow tables].
2293** </ul> 2356** </ul>
@@ -2315,7 +2378,7 @@ struct sqlite3_mem_methods {
2315** </dd> 2378** </dd>
2316** 2379**
2317** [[SQLITE_DBCONFIG_DQS_DML]] 2380** [[SQLITE_DBCONFIG_DQS_DML]]
2318** <dt>SQLITE_DBCONFIG_DQS_DML</td> 2381** <dt>SQLITE_DBCONFIG_DQS_DML</dt>
2319** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates 2382** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
2320** the legacy [double-quoted string literal] misfeature for DML statements 2383** the legacy [double-quoted string literal] misfeature for DML statements
2321** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The 2384** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
@@ -2324,7 +2387,7 @@ struct sqlite3_mem_methods {
2324** </dd> 2387** </dd>
2325** 2388**
2326** [[SQLITE_DBCONFIG_DQS_DDL]] 2389** [[SQLITE_DBCONFIG_DQS_DDL]]
2327** <dt>SQLITE_DBCONFIG_DQS_DDL</td> 2390** <dt>SQLITE_DBCONFIG_DQS_DDL</dt>
2328** <dd>The SQLITE_DBCONFIG_DQS option activates or deactivates 2391** <dd>The SQLITE_DBCONFIG_DQS option activates or deactivates
2329** the legacy [double-quoted string literal] misfeature for DDL statements, 2392** the legacy [double-quoted string literal] misfeature for DDL statements,
2330** such as CREATE TABLE and CREATE INDEX. The 2393** such as CREATE TABLE and CREATE INDEX. The
@@ -2333,7 +2396,7 @@ struct sqlite3_mem_methods {
2333** </dd> 2396** </dd>
2334** 2397**
2335** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]] 2398** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]]
2336** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</td> 2399** <dt>SQLITE_DBCONFIG_TRUSTED_SCHEMA</dt>
2337** <dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to 2400** <dd>The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to
2338** assume that database schemas are untainted by malicious content. 2401** assume that database schemas are untainted by malicious content.
2339** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite 2402** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite
@@ -2353,7 +2416,7 @@ struct sqlite3_mem_methods {
2353** </dd> 2416** </dd>
2354** 2417**
2355** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]] 2418** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]]
2356** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</td> 2419** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</dt>
2357** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates 2420** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
2358** the legacy file format flag. When activated, this flag causes all newly 2421** the legacy file format flag. When activated, this flag causes all newly
2359** created database file to have a schema format version number (the 4-byte 2422** created database file to have a schema format version number (the 4-byte
@@ -2362,7 +2425,7 @@ struct sqlite3_mem_methods {
2362** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting, 2425** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
2363** newly created databases are generally not understandable by SQLite versions 2426** newly created databases are generally not understandable by SQLite versions
2364** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there 2427** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there
2365** is now scarcely any need to generated database files that are compatible 2428** is now scarcely any need to generate database files that are compatible
2366** all the way back to version 3.0.0, and so this setting is of little 2429** all the way back to version 3.0.0, and so this setting is of little
2367** practical use, but is provided so that SQLite can continue to claim the 2430** practical use, but is provided so that SQLite can continue to claim the
2368** ability to generate new database files that are compatible with version 2431** ability to generate new database files that are compatible with version
@@ -2371,8 +2434,40 @@ struct sqlite3_mem_methods {
2371** the [VACUUM] command will fail with an obscure error when attempting to 2434** the [VACUUM] command will fail with an obscure error when attempting to
2372** process a table with generated columns and a descending index. This is 2435** process a table with generated columns and a descending index. This is
2373** not considered a bug since SQLite versions 3.3.0 and earlier do not support 2436** not considered a bug since SQLite versions 3.3.0 and earlier do not support
2374** either generated columns or decending indexes. 2437** either generated columns or descending indexes.
2438** </dd>
2439**
2440** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]]
2441** <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</dt>
2442** <dd>The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in
2443** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2444** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2445** statistics. For statistics to be collected, the flag must be set on
2446** the database handle both when the SQL statement is prepared and when it
2447** is stepped. The flag is set (collection of statistics is enabled)
2448** by default. This option takes two arguments: an integer and a pointer to
2449** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2450** leave unchanged the statement scanstatus option. If the second argument
2451** is not NULL, then the value of the statement scanstatus setting after
2452** processing the first argument is written into the integer that the second
2453** argument points to.
2375** </dd> 2454** </dd>
2455**
2456** [[SQLITE_DBCONFIG_REVERSE_SCANORDER]]
2457** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
2458** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
2459** in which tables and indexes are scanned so that the scans start at the end
2460** and work toward the beginning rather than starting at the beginning and
2461** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2462** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2463** two arguments which are an integer and a pointer to an integer. The first
2464** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2465** reverse scan order flag, respectively. If the second argument is not NULL,
2466** then 0 or 1 is written into the integer that the second argument points to
2467** depending on if the reverse scan order flag is set after processing the
2468** first argument.
2469** </dd>
2470**
2376** </dl> 2471** </dl>
2377*/ 2472*/
2378#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ 2473#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
@@ -2393,7 +2488,9 @@ struct sqlite3_mem_methods {
2393#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */ 2488#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2394#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */ 2489#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2395#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */ 2490#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2396#define SQLITE_DBCONFIG_MAX 1017 /* Largest DBCONFIG */ 2491#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2492#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2493#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2397 2494
2398/* 2495/*
2399** CAPI3REF: Enable Or Disable Extended Result Codes 2496** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -2608,6 +2705,10 @@ struct sqlite3_mem_methods {
2608** ^A call to sqlite3_interrupt(D) that occurs when there are no running 2705** ^A call to sqlite3_interrupt(D) that occurs when there are no running
2609** SQL statements is a no-op and has no effect on SQL statements 2706** SQL statements is a no-op and has no effect on SQL statements
2610** that are started after the sqlite3_interrupt() call returns. 2707** that are started after the sqlite3_interrupt() call returns.
2708**
2709** ^The [sqlite3_is_interrupted(D)] interface can be used to determine whether
2710** or not an interrupt is currently in effect for [database connection] D.
2711** It returns 1 if an interrupt is currently in effect, or 0 otherwise.
2611*/ 2712*/
2612 2713
2613/* 2714/*
@@ -3191,8 +3292,8 @@ struct sqlite3_mem_methods {
3191** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same 3292** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
3192** information as is provided by the [sqlite3_profile()] callback. 3293** information as is provided by the [sqlite3_profile()] callback.
3193** ^The P argument is a pointer to the [prepared statement] and the 3294** ^The P argument is a pointer to the [prepared statement] and the
3194** X argument points to a 64-bit integer which is the estimated of 3295** X argument points to a 64-bit integer which is approximately
3195** the number of nanosecond that the prepared statement took to run. 3296** the number of nanoseconds that the prepared statement took to run.
3196** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. 3297** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
3197** 3298**
3198** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt> 3299** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
@@ -3224,8 +3325,10 @@ struct sqlite3_mem_methods {
3224** M argument should be the bitwise OR-ed combination of 3325** M argument should be the bitwise OR-ed combination of
3225** zero or more [SQLITE_TRACE] constants. 3326** zero or more [SQLITE_TRACE] constants.
3226** 3327**
3227** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides 3328** ^Each call to either sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P)
3228** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). 3329** overrides (cancels) all prior calls to sqlite3_trace(D,X,P) or
3330** sqlite3_trace_v2(D,M,X,P) for the [database connection] D. Each
3331** database connection may have at most one trace callback.
3229** 3332**
3230** ^The X callback is invoked whenever any of the events identified by 3333** ^The X callback is invoked whenever any of the events identified by
3231** mask M occur. ^The integer return value from the callback is currently 3334** mask M occur. ^The integer return value from the callback is currently
@@ -3249,7 +3352,7 @@ struct sqlite3_mem_methods {
3249** 3352**
3250** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback 3353** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
3251** function X to be invoked periodically during long running calls to 3354** function X to be invoked periodically during long running calls to
3252** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for 3355** [sqlite3_step()] and [sqlite3_prepare()] and similar for
3253** database connection D. An example use for this 3356** database connection D. An example use for this
3254** interface is to keep a GUI updated during a large query. 3357** interface is to keep a GUI updated during a large query.
3255** 3358**
@@ -3274,6 +3377,13 @@ struct sqlite3_mem_methods {
3274** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their 3377** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3275** database connections for the meaning of "modify" in this paragraph. 3378** database connections for the meaning of "modify" in this paragraph.
3276** 3379**
3380** The progress handler callback would originally only be invoked from the
3381** bytecode engine. It still might be invoked during [sqlite3_prepare()]
3382** and similar because those routines might force a reparse of the schema
3383** which involves running the bytecode engine. However, beginning with
3384** SQLite version 3.41.0, the progress handler callback might also be
3385** invoked directly from [sqlite3_prepare()] while analyzing and generating
3386** code for complex queries.
3277*/ 3387*/
3278 3388
3279/* 3389/*
@@ -3309,13 +3419,18 @@ struct sqlite3_mem_methods {
3309** 3419**
3310** <dl> 3420** <dl>
3311** ^(<dt>[SQLITE_OPEN_READONLY]</dt> 3421** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
3312** <dd>The database is opened in read-only mode. If the database does not 3422** <dd>The database is opened in read-only mode. If the database does
3313** already exist, an error is returned.</dd>)^ 3423** not already exist, an error is returned.</dd>)^
3314** 3424**
3315** ^(<dt>[SQLITE_OPEN_READWRITE]</dt> 3425** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
3316** <dd>The database is opened for reading and writing if possible, or reading 3426** <dd>The database is opened for reading and writing if possible, or
3317** only if the file is write protected by the operating system. In either 3427** reading only if the file is write protected by the operating
3318** case the database must already exist, otherwise an error is returned.</dd>)^ 3428** system. In either case the database must already exist, otherwise
3429** an error is returned. For historical reasons, if opening in
3430** read-write mode fails due to OS-level permissions, an attempt is
3431** made to open it in read-only mode. [sqlite3_db_readonly()] can be
3432** used to determine whether the database is actually
3433** read-write.</dd>)^
3319** 3434**
3320** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> 3435** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
3321** <dd>The database is opened for reading and writing, and is created if 3436** <dd>The database is opened for reading and writing, and is created if
@@ -3353,6 +3468,9 @@ struct sqlite3_mem_methods {
3353** <dd>The database is opened [shared cache] enabled, overriding 3468** <dd>The database is opened [shared cache] enabled, overriding
3354** the default shared cache setting provided by 3469** the default shared cache setting provided by
3355** [sqlite3_enable_shared_cache()].)^ 3470** [sqlite3_enable_shared_cache()].)^
3471** The [use of shared cache mode is discouraged] and hence shared cache
3472** capabilities may be omitted from many builds of SQLite. In such cases,
3473** this option is a no-op.
3356** 3474**
3357** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> 3475** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt>
3358** <dd>The database is opened [shared cache] disabled, overriding 3476** <dd>The database is opened [shared cache] disabled, overriding
@@ -3368,7 +3486,7 @@ struct sqlite3_mem_methods {
3368** to return an extended result code.</dd> 3486** to return an extended result code.</dd>
3369** 3487**
3370** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> 3488** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3371** <dd>The database filename is not allowed to be a symbolic link</dd> 3489** <dd>The database filename is not allowed to contain a symbolic link</dd>
3372** </dl>)^ 3490** </dl>)^
3373** 3491**
3374** If the 3rd parameter to sqlite3_open_v2() is not one of the 3492** If the 3rd parameter to sqlite3_open_v2() is not one of the
@@ -3558,7 +3676,7 @@ struct sqlite3_mem_methods {
3558** as F) must be one of: 3676** as F) must be one of:
3559** <ul> 3677** <ul>
3560** <li> A database filename pointer created by the SQLite core and 3678** <li> A database filename pointer created by the SQLite core and
3561** passed into the xOpen() method of a VFS implemention, or 3679** passed into the xOpen() method of a VFS implementation, or
3562** <li> A filename obtained from [sqlite3_db_filename()], or 3680** <li> A filename obtained from [sqlite3_db_filename()], or
3563** <li> A new filename constructed using [sqlite3_create_filename()]. 3681** <li> A new filename constructed using [sqlite3_create_filename()].
3564** </ul> 3682** </ul>
@@ -3663,7 +3781,7 @@ struct sqlite3_mem_methods {
3663/* 3781/*
3664** CAPI3REF: Create and Destroy VFS Filenames 3782** CAPI3REF: Create and Destroy VFS Filenames
3665** 3783**
3666** These interfces are provided for use by [VFS shim] implementations and 3784** These interfaces are provided for use by [VFS shim] implementations and
3667** are not useful outside of that context. 3785** are not useful outside of that context.
3668** 3786**
3669** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of 3787** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of
@@ -3735,6 +3853,7 @@ struct sqlite3_mem_methods {
3735** 3853**
3736** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language 3854** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
3737** text that describes the error, as either UTF-8 or UTF-16 respectively. 3855** text that describes the error, as either UTF-8 or UTF-16 respectively.
3856** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
3738** ^(Memory to hold the error message string is managed internally. 3857** ^(Memory to hold the error message string is managed internally.
3739** The application does not need to worry about freeing the result. 3858** The application does not need to worry about freeing the result.
3740** However, the error string might be overwritten or deallocated by 3859** However, the error string might be overwritten or deallocated by
@@ -4147,6 +4266,40 @@ typedef struct sqlite3_stmt sqlite3_stmt;
4147*/ 4266*/
4148 4267
4149/* 4268/*
4269** CAPI3REF: Change The EXPLAIN Setting For A Prepared Statement
4270** METHOD: sqlite3_stmt
4271**
4272** The sqlite3_stmt_explain(S,E) interface changes the EXPLAIN
4273** setting for [prepared statement] S. If E is zero, then S becomes
4274** a normal prepared statement. If E is 1, then S behaves as if
4275** its SQL text began with "[EXPLAIN]". If E is 2, then S behaves as if
4276** its SQL text began with "[EXPLAIN QUERY PLAN]".
4277**
4278** Calling sqlite3_stmt_explain(S,E) might cause S to be reprepared.
4279** SQLite tries to avoid a reprepare, but a reprepare might be necessary
4280** on the first transition into EXPLAIN or EXPLAIN QUERY PLAN mode.
4281**
4282** Because of the potential need to reprepare, a call to
4283** sqlite3_stmt_explain(S,E) will fail with SQLITE_ERROR if S cannot be
4284** reprepared because it was created using [sqlite3_prepare()] instead of
4285** the newer [sqlite3_prepare_v2()] or [sqlite3_prepare_v3()] interfaces and
4286** hence has no saved SQL text with which to reprepare.
4287**
4288** Changing the explain setting for a prepared statement does not change
4289** the original SQL text for the statement. Hence, if the SQL text originally
4290** began with EXPLAIN or EXPLAIN QUERY PLAN, but sqlite3_stmt_explain(S,0)
4291** is called to convert the statement into an ordinary statement, the EXPLAIN
4292** or EXPLAIN QUERY PLAN keywords will still appear in the sqlite3_sql(S)
4293** output, even though the statement now acts like a normal SQL statement.
4294**
4295** This routine returns SQLITE_OK if the explain mode is successfully
4296** changed, or an error code if the explain mode could not be changed.
4297** The explain mode cannot be changed while a statement is active.
4298** Hence, it is good practice to call [sqlite3_reset(S)]
4299** immediately prior to calling sqlite3_stmt_explain(S,E).
4300*/
4301
4302/*
4150** CAPI3REF: Determine If A Prepared Statement Has Been Reset 4303** CAPI3REF: Determine If A Prepared Statement Has Been Reset
4151** METHOD: sqlite3_stmt 4304** METHOD: sqlite3_stmt
4152** 4305**
@@ -4308,7 +4461,7 @@ typedef struct sqlite3_context sqlite3_context;
4308** with it may be passed. ^It is called to dispose of the BLOB or string even 4461** with it may be passed. ^It is called to dispose of the BLOB or string even
4309** if the call to the bind API fails, except the destructor is not called if 4462** if the call to the bind API fails, except the destructor is not called if
4310** the third parameter is a NULL pointer or the fourth parameter is negative. 4463** the third parameter is a NULL pointer or the fourth parameter is negative.
4311** ^ (2) The special constant, [SQLITE_STATIC], may be passsed to indicate that 4464** ^ (2) The special constant, [SQLITE_STATIC], may be passed to indicate that
4312** the application remains responsible for disposing of the object. ^In this 4465** the application remains responsible for disposing of the object. ^In this
4313** case, the object and the provided pointer to it must remain valid until 4466** case, the object and the provided pointer to it must remain valid until
4314** either the prepared statement is finalized or the same SQL parameter is 4467** either the prepared statement is finalized or the same SQL parameter is
@@ -4944,19 +5097,32 @@ typedef struct sqlite3_context sqlite3_context;
4944** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S 5097** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
4945** back to the beginning of its program. 5098** back to the beginning of its program.
4946** 5099**
4947** ^If the most recent call to [sqlite3_step(S)] for the 5100** ^The return code from [sqlite3_reset(S)] indicates whether or not
4948** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], 5101** the previous evaluation of prepared statement S completed successfully.
4949** or if [sqlite3_step(S)] has never before been called on S, 5102** ^If [sqlite3_step(S)] has never before been called on S or if
4950** then [sqlite3_reset(S)] returns [SQLITE_OK]. 5103** [sqlite3_step(S)] has not been called since the previous call
5104** to [sqlite3_reset(S)], then [sqlite3_reset(S)] will return
5105** [SQLITE_OK].
4951** 5106**
4952** ^If the most recent call to [sqlite3_step(S)] for the 5107** ^If the most recent call to [sqlite3_step(S)] for the
4953** [prepared statement] S indicated an error, then 5108** [prepared statement] S indicated an error, then
4954** [sqlite3_reset(S)] returns an appropriate [error code]. 5109** [sqlite3_reset(S)] returns an appropriate [error code].
5110** ^The [sqlite3_reset(S)] interface might also return an [error code]
5111** if there were no prior errors but the process of resetting
5112** the prepared statement caused a new error. ^For example, if an
5113** [INSERT] statement with a [RETURNING] clause is only stepped one time,
5114** that one call to [sqlite3_step(S)] might return SQLITE_ROW but
5115** the overall statement might still fail and the [sqlite3_reset(S)] call
5116** might return SQLITE_BUSY if locking constraints prevent the
5117** database change from committing. Therefore, it is important that
5118** applications check the return code from [sqlite3_reset(S)] even if
5119** no prior call to [sqlite3_step(S)] indicated a problem.
4955** 5120**
4956** ^The [sqlite3_reset(S)] interface does not change the values 5121** ^The [sqlite3_reset(S)] interface does not change the values
4957** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. 5122** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4958*/ 5123*/
4959 5124
5125
4960/* 5126/*
4961** CAPI3REF: Create Or Redefine SQL Functions 5127** CAPI3REF: Create Or Redefine SQL Functions
4962** KEYWORDS: {function creation routines} 5128** KEYWORDS: {function creation routines}
@@ -5119,10 +5285,21 @@ typedef struct sqlite3_context sqlite3_context;
5119** from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in 5285** from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in
5120** schema structures such as [CHECK constraints], [DEFAULT clauses], 5286** schema structures such as [CHECK constraints], [DEFAULT clauses],
5121** [expression indexes], [partial indexes], or [generated columns]. 5287** [expression indexes], [partial indexes], or [generated columns].
5122** The SQLITE_DIRECTONLY flags is a security feature which is recommended 5288** <p>
5123** for all [application-defined SQL functions], and especially for functions 5289** The SQLITE_DIRECTONLY flag is recommended for any
5124** that have side-effects or that could potentially leak sensitive 5290** [application-defined SQL function]
5125** information. 5291** that has side-effects or that could potentially leak sensitive information.
5292** This will prevent attacks in which an application is tricked
5293** into using a database file that has had its schema surreptitiously
5294** modified to invoke the application-defined function in ways that are
5295** harmful.
5296** <p>
5297** Some people say it is good practice to set SQLITE_DIRECTONLY on all
5298** [application-defined SQL functions], regardless of whether or not they
5299** are security sensitive, as doing so prevents those functions from being used
5300** inside of the database schema, and thus ensures that the database
5301** can be inspected and modified using generic tools (such as the [CLI])
5302** that do not have access to the application-defined functions.
5126** </dd> 5303** </dd>
5127** 5304**
5128** [[SQLITE_INNOCUOUS]] <dt>SQLITE_INNOCUOUS</dt><dd> 5305** [[SQLITE_INNOCUOUS]] <dt>SQLITE_INNOCUOUS</dt><dd>
@@ -5307,6 +5484,27 @@ typedef struct sqlite3_context sqlite3_context;
5307*/ 5484*/
5308 5485
5309/* 5486/*
5487** CAPI3REF: Report the internal text encoding state of an sqlite3_value object
5488** METHOD: sqlite3_value
5489**
5490** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
5491** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding
5492** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
5493** returns something other than SQLITE_TEXT, then the return value from
5494** sqlite3_value_encoding(X) is meaningless. ^Calls to
5495** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)],
5496** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
5497** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
5498** thus change the return from subsequent calls to sqlite3_value_encoding(X).
5499**
5500** This routine is intended for used by applications that test and validate
5501** the SQLite implementation. This routine is inquiring about the opaque
5502** internal state of an [sqlite3_value] object. Ordinary applications should
5503** not need to know what the internal state of an sqlite3_value object is and
5504** hence should not need to use this interface.
5505*/
5506
5507/*
5310** CAPI3REF: Finding The Subtype Of SQL Values 5508** CAPI3REF: Finding The Subtype Of SQL Values
5311** METHOD: sqlite3_value 5509** METHOD: sqlite3_value
5312** 5510**
@@ -5355,7 +5553,7 @@ typedef struct sqlite3_context sqlite3_context;
5355** 5553**
5356** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer 5554** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
5357** when first called if N is less than or equal to zero or if a memory 5555** when first called if N is less than or equal to zero or if a memory
5358** allocate error occurs. 5556** allocation error occurs.
5359** 5557**
5360** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is 5558** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
5361** determined by the N parameter on first successful call. Changing the 5559** determined by the N parameter on first successful call. Changing the
@@ -5407,32 +5605,32 @@ typedef struct sqlite3_context sqlite3_context;
5407** METHOD: sqlite3_context 5605** METHOD: sqlite3_context
5408** 5606**
5409** These functions may be used by (non-aggregate) SQL functions to 5607** These functions may be used by (non-aggregate) SQL functions to
5410** associate metadata with argument values. If the same value is passed to 5608** associate auxiliary data with argument values. If the same argument
5411** multiple invocations of the same SQL function during query execution, under 5609** value is passed to multiple invocations of the same SQL function during
5412** some circumstances the associated metadata may be preserved. An example 5610** query execution, under some circumstances the associated auxiliary data
5413** of where this might be useful is in a regular-expression matching 5611** might be preserved. An example of where this might be useful is in a
5414** function. The compiled version of the regular expression can be stored as 5612** regular-expression matching function. The compiled version of the regular
5415** metadata associated with the pattern string. 5613** expression can be stored as auxiliary data associated with the pattern string.
5416** Then as long as the pattern string remains the same, 5614** Then as long as the pattern string remains the same,
5417** the compiled regular expression can be reused on multiple 5615** the compiled regular expression can be reused on multiple
5418** invocations of the same function. 5616** invocations of the same function.
5419** 5617**
5420** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata 5618** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
5421** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument 5619** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
5422** value to the application-defined function. ^N is zero for the left-most 5620** value to the application-defined function. ^N is zero for the left-most
5423** function argument. ^If there is no metadata 5621** function argument. ^If there is no auxiliary data
5424** associated with the function argument, the sqlite3_get_auxdata(C,N) interface 5622** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
5425** returns a NULL pointer. 5623** returns a NULL pointer.
5426** 5624**
5427** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th 5625** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
5428** argument of the application-defined function. ^Subsequent 5626** N-th argument of the application-defined function. ^Subsequent
5429** calls to sqlite3_get_auxdata(C,N) return P from the most recent 5627** calls to sqlite3_get_auxdata(C,N) return P from the most recent
5430** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or 5628** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
5431** NULL if the metadata has been discarded. 5629** NULL if the auxiliary data has been discarded.
5432** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, 5630** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
5433** SQLite will invoke the destructor function X with parameter P exactly 5631** SQLite will invoke the destructor function X with parameter P exactly
5434** once, when the metadata is discarded. 5632** once, when the auxiliary data is discarded.
5435** SQLite is free to discard the metadata at any time, including: <ul> 5633** SQLite is free to discard the auxiliary data at any time, including: <ul>
5436** <li> ^(when the corresponding function parameter changes)^, or 5634** <li> ^(when the corresponding function parameter changes)^, or
5437** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the 5635** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
5438** SQL statement)^, or 5636** SQL statement)^, or
@@ -5448,7 +5646,7 @@ typedef struct sqlite3_context sqlite3_context;
5448** function implementation should not make any use of P after 5646** function implementation should not make any use of P after
5449** sqlite3_set_auxdata() has been called. 5647** sqlite3_set_auxdata() has been called.
5450** 5648**
5451** ^(In practice, metadata is preserved between function calls for 5649** ^(In practice, auxiliary data is preserved between function calls for
5452** function parameters that are compile-time constants, including literal 5650** function parameters that are compile-time constants, including literal
5453** values and [parameters] and expressions composed from the same.)^ 5651** values and [parameters] and expressions composed from the same.)^
5454** 5652**
@@ -5458,8 +5656,63 @@ typedef struct sqlite3_context sqlite3_context;
5458** 5656**
5459** These routines must be called from the same thread in which 5657** These routines must be called from the same thread in which
5460** the SQL function is running. 5658** the SQL function is running.
5659**
5660** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()].
5461*/ 5661*/
5462 5662
5663/*
5664** CAPI3REF: Database Connection Client Data
5665** METHOD: sqlite3
5666**
5667** These functions are used to associate one or more named pointers
5668** with a [database connection].
5669** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P
5670** to be attached to [database connection] D using name N. Subsequent
5671** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P
5672** or a NULL pointer if there were no prior calls to
5673** sqlite3_set_clientdata() with the same values of D and N.
5674** Names are compared using strcmp() and are thus case sensitive.
5675**
5676** If P and X are both non-NULL, then the destructor X is invoked with
5677** argument P on the first of the following occurrences:
5678** <ul>
5679** <li> An out-of-memory error occurs during the call to
5680** sqlite3_set_clientdata() which attempts to register pointer P.
5681** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made
5682** with the same D and N parameters.
5683** <li> The database connection closes. SQLite does not make any guarantees
5684** about the order in which destructors are called, only that all
5685** destructors will be called exactly once at some point during the
5686** database connection closing process.
5687** </ul>
5688**
5689** SQLite does not do anything with client data other than invoke
5690** destructors on the client data at the appropriate time. The intended
5691** use for client data is to provide a mechanism for wrapper libraries
5692** to store additional information about an SQLite database connection.
5693**
5694** There is no limit (other than available memory) on the number of different
5695** client data pointers (with different names) that can be attached to a
5696** single database connection. However, the implementation is optimized
5697** for the case of having only one or two different client data names.
5698** Applications and wrapper libraries are discouraged from using more than
5699** one client data name each.
5700**
5701** There is no way to enumerate the client data pointers
5702** associated with a database connection. The N parameter can be thought
5703** of as a secret key such that only code that knows the secret key is able
5704** to access the associated data.
5705**
5706** Security Warning: These interfaces should not be exposed in scripting
5707** languages or in other circumstances where it might be possible for an
5708** an attacker to invoke them. Any agent that can invoke these interfaces
5709** can probably also take control of the process.
5710**
5711** Database connection client data is only available for SQLite
5712** version 3.44.0 ([dateof:3.44.0]) and later.
5713**
5714** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()].
5715*/
5463 5716
5464/* 5717/*
5465** CAPI3REF: Constants Defining Special Destructor Behavior 5718** CAPI3REF: Constants Defining Special Destructor Behavior
@@ -5555,9 +5808,10 @@ typedef void (*sqlite3_destructor_type)(void*);
5555** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]. 5808** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
5556** ^SQLite takes the text result from the application from 5809** ^SQLite takes the text result from the application from
5557** the 2nd parameter of the sqlite3_result_text* interfaces. 5810** the 2nd parameter of the sqlite3_result_text* interfaces.
5558** ^If the 3rd parameter to the sqlite3_result_text* interfaces 5811** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
5559** is negative, then SQLite takes result text from the 2nd parameter 5812** other than sqlite3_result_text64() is negative, then SQLite computes
5560** through the first zero character. 5813** the string length itself by searching the 2nd parameter for the first
5814** zero character.
5561** ^If the 3rd parameter to the sqlite3_result_text* interfaces 5815** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5562** is non-negative, then as many bytes (not characters) of the text 5816** is non-negative, then as many bytes (not characters) of the text
5563** pointed to by the 2nd parameter are taken as the application-defined 5817** pointed to by the 2nd parameter are taken as the application-defined
@@ -5773,6 +6027,13 @@ typedef void (*sqlite3_destructor_type)(void*);
5773** of the default VFS is not implemented correctly, or not implemented at 6027** of the default VFS is not implemented correctly, or not implemented at
5774** all, then the behavior of sqlite3_sleep() may deviate from the description 6028** all, then the behavior of sqlite3_sleep() may deviate from the description
5775** in the previous paragraphs. 6029** in the previous paragraphs.
6030**
6031** If a negative argument is passed to sqlite3_sleep() the results vary by
6032** VFS and operating system. Some system treat a negative argument as an
6033** instruction to sleep forever. Others understand it to mean do not sleep
6034** at all. ^In SQLite version 3.42.0 and later, a negative
6035** argument passed into sqlite3_sleep() is changed to zero before it is relayed
6036** down into the xSleep method of the VFS.
5776*/ 6037*/
5777 6038
5778/* 6039/*
@@ -6013,7 +6274,7 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
6013*/ 6274*/
6014 6275
6015/* 6276/*
6016** CAPI3REF: Allowed return values from [sqlite3_txn_state()] 6277** CAPI3REF: Allowed return values from sqlite3_txn_state()
6017** KEYWORDS: {transaction state} 6278** KEYWORDS: {transaction state}
6018** 6279**
6019** These constants define the current transaction state of a database file. 6280** These constants define the current transaction state of a database file.
@@ -6116,7 +6377,7 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
6116** function C that is invoked prior to each autovacuum of the database 6377** function C that is invoked prior to each autovacuum of the database
6117** file. ^The callback is passed a copy of the generic data pointer (P), 6378** file. ^The callback is passed a copy of the generic data pointer (P),
6118** the schema-name of the attached database that is being autovacuumed, 6379** the schema-name of the attached database that is being autovacuumed,
6119** the the size of the database file in pages, the number of free pages, 6380** the size of the database file in pages, the number of free pages,
6120** and the number of bytes per page, respectively. The callback should 6381** and the number of bytes per page, respectively. The callback should
6121** return the number of free pages that should be removed by the 6382** return the number of free pages that should be removed by the
6122** autovacuum. ^If the callback returns zero, then no autovacuum happens. 6383** autovacuum. ^If the callback returns zero, then no autovacuum happens.
@@ -6142,7 +6403,7 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
6142** ^Each call to the sqlite3_autovacuum_pages() interface overrides all 6403** ^Each call to the sqlite3_autovacuum_pages() interface overrides all
6143** previous invocations for that database connection. ^If the callback 6404** previous invocations for that database connection. ^If the callback
6144** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, 6405** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
6145** then the autovacuum steps callback is cancelled. The return value 6406** then the autovacuum steps callback is canceled. The return value
6146** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might 6407** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
6147** be some other error code if something goes wrong. The current 6408** be some other error code if something goes wrong. The current
6148** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other 6409** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
@@ -6226,6 +6487,11 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
6226** to the same database. Sharing is enabled if the argument is true 6487** to the same database. Sharing is enabled if the argument is true
6227** and disabled if the argument is false.)^ 6488** and disabled if the argument is false.)^
6228** 6489**
6490** This interface is omitted if SQLite is compiled with
6491** [-DSQLITE_OMIT_SHARED_CACHE]. The [-DSQLITE_OMIT_SHARED_CACHE]
6492** compile-time option is recommended because the
6493** [use of shared cache mode is discouraged].
6494**
6229** ^Cache sharing is enabled and disabled for an entire process. 6495** ^Cache sharing is enabled and disabled for an entire process.
6230** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). 6496** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]).
6231** In prior versions of SQLite, 6497** In prior versions of SQLite,
@@ -6321,7 +6587,7 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
6321** ^The soft heap limit may not be greater than the hard heap limit. 6587** ^The soft heap limit may not be greater than the hard heap limit.
6322** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) 6588** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
6323** is invoked with a value of N that is greater than the hard heap limit, 6589** is invoked with a value of N that is greater than the hard heap limit,
6324** the the soft heap limit is set to the value of the hard heap limit. 6590** the soft heap limit is set to the value of the hard heap limit.
6325** ^The soft heap limit is automatically enabled whenever the hard heap 6591** ^The soft heap limit is automatically enabled whenever the hard heap
6326** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and 6592** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
6327** the soft heap limit is outside the range of 1..N, then the soft heap 6593** the soft heap limit is outside the range of 1..N, then the soft heap
@@ -6559,15 +6825,6 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
6559*/ 6825*/
6560 6826
6561/* 6827/*
6562** The interface to the virtual-table mechanism is currently considered
6563** to be experimental. The interface might change in incompatible ways.
6564** If this is a problem for you, do not use the interface at this time.
6565**
6566** When the virtual-table mechanism stabilizes, we will declare the
6567** interface fixed, support it indefinitely, and remove this comment.
6568*/
6569
6570/*
6571** Structures used by the virtual table interface 6828** Structures used by the virtual table interface
6572*/ 6829*/
6573typedef struct sqlite3_vtab sqlite3_vtab; 6830typedef struct sqlite3_vtab sqlite3_vtab;
@@ -6627,6 +6884,10 @@ struct sqlite3_module {
6627 /* The methods above are in versions 1 and 2 of the sqlite_module object. 6884 /* The methods above are in versions 1 and 2 of the sqlite_module object.
6628 ** Those below are for version 3 and greater. */ 6885 ** Those below are for version 3 and greater. */
6629 int (*xShadowName)(const char*); 6886 int (*xShadowName)(const char*);
6887 /* The methods above are in versions 1 through 3 of the sqlite_module object.
6888 ** Those below are for version 4 and greater. */
6889 int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema,
6890 const char *zTabName, int mFlags, char **pzErr);
6630}; 6891};
6631 6892
6632/* 6893/*
@@ -6685,10 +6946,10 @@ struct sqlite3_module {
6685** when the omit flag is true there is no guarantee that the constraint will 6946** when the omit flag is true there is no guarantee that the constraint will
6686** not be checked again using byte code.)^ 6947** not be checked again using byte code.)^
6687** 6948**
6688** ^The idxNum and idxPtr values are recorded and passed into the 6949** ^The idxNum and idxStr values are recorded and passed into the
6689** [xFilter] method. 6950** [xFilter] method.
6690** ^[sqlite3_free()] is used to free idxPtr if and only if 6951** ^[sqlite3_free()] is used to free idxStr if and only if
6691** needToFreeIdxPtr is true. 6952** needToFreeIdxStr is true.
6692** 6953**
6693** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in 6954** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
6694** the correct order to satisfy the ORDER BY clause so that no separate 6955** the correct order to satisfy the ORDER BY clause so that no separate
@@ -6808,7 +7069,7 @@ struct sqlite3_index_info {
6808** the [sqlite3_vtab_collation()] interface. For most real-world virtual 7069** the [sqlite3_vtab_collation()] interface. For most real-world virtual
6809** tables, the collating sequence of constraints does not matter (for example 7070** tables, the collating sequence of constraints does not matter (for example
6810** because the constraints are numeric) and so the sqlite3_vtab_collation() 7071** because the constraints are numeric) and so the sqlite3_vtab_collation()
6811** interface is no commonly needed. 7072** interface is not commonly needed.
6812*/ 7073*/
6813#define SQLITE_INDEX_CONSTRAINT_EQ 2 7074#define SQLITE_INDEX_CONSTRAINT_EQ 2
6814#define SQLITE_INDEX_CONSTRAINT_GT 4 7075#define SQLITE_INDEX_CONSTRAINT_GT 4
@@ -6949,16 +7210,6 @@ struct sqlite3_vtab_cursor {
6949*/ 7210*/
6950 7211
6951/* 7212/*
6952** The interface to the virtual-table mechanism defined above (back up
6953** to a comment remarkably similar to this one) is currently considered
6954** to be experimental. The interface might change in incompatible ways.
6955** If this is a problem for you, do not use the interface at this time.
6956**
6957** When the virtual-table mechanism stabilizes, we will declare the
6958** interface fixed, support it indefinitely, and remove this comment.
6959*/
6960
6961/*
6962** CAPI3REF: A Handle To An Open BLOB 7213** CAPI3REF: A Handle To An Open BLOB
6963** KEYWORDS: {BLOB handle} {BLOB handles} 7214** KEYWORDS: {BLOB handle} {BLOB handles}
6964** 7215**
@@ -7095,7 +7346,7 @@ typedef struct sqlite3_blob sqlite3_blob;
7095** code is returned and the transaction rolled back. 7346** code is returned and the transaction rolled back.
7096** 7347**
7097** Calling this function with an argument that is not a NULL pointer or an 7348** Calling this function with an argument that is not a NULL pointer or an
7098** open blob handle results in undefined behaviour. ^Calling this routine 7349** open blob handle results in undefined behavior. ^Calling this routine
7099** with a null pointer (such as would be returned by a failed call to 7350** with a null pointer (such as would be returned by a failed call to
7100** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function 7351** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
7101** is passed a valid open blob handle, the values returned by the 7352** is passed a valid open blob handle, the values returned by the
@@ -7324,9 +7575,9 @@ typedef struct sqlite3_blob sqlite3_blob;
7324** is undefined if the mutex is not currently entered by the 7575** is undefined if the mutex is not currently entered by the
7325** calling thread or is not currently allocated. 7576** calling thread or is not currently allocated.
7326** 7577**
7327** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or 7578** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(),
7328** sqlite3_mutex_leave() is a NULL pointer, then all three routines 7579** sqlite3_mutex_leave(), or sqlite3_mutex_free() is a NULL pointer,
7329** behave as no-ops. 7580** then any of the four routines behaves as a no-op.
7330** 7581**
7331** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. 7582** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
7332*/ 7583*/
@@ -7558,6 +7809,7 @@ struct sqlite3_mutex_methods {
7558#define SQLITE_TESTCTRL_PRNG_SAVE 5 7809#define SQLITE_TESTCTRL_PRNG_SAVE 5
7559#define SQLITE_TESTCTRL_PRNG_RESTORE 6 7810#define SQLITE_TESTCTRL_PRNG_RESTORE 6
7560#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ 7811#define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
7812#define SQLITE_TESTCTRL_FK_NO_ACTION 7
7561#define SQLITE_TESTCTRL_BITVEC_TEST 8 7813#define SQLITE_TESTCTRL_BITVEC_TEST 8
7562#define SQLITE_TESTCTRL_FAULT_INSTALL 9 7814#define SQLITE_TESTCTRL_FAULT_INSTALL 9
7563#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 7815#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
@@ -7586,7 +7838,8 @@ struct sqlite3_mutex_methods {
7586#define SQLITE_TESTCTRL_TRACEFLAGS 31 7838#define SQLITE_TESTCTRL_TRACEFLAGS 31
7587#define SQLITE_TESTCTRL_TUNE 32 7839#define SQLITE_TESTCTRL_TUNE 32
7588#define SQLITE_TESTCTRL_LOGEST 33 7840#define SQLITE_TESTCTRL_LOGEST 33
7589#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */ 7841#define SQLITE_TESTCTRL_USELONGDOUBLE 34
7842#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
7590 7843
7591/* 7844/*
7592** CAPI3REF: SQL Keyword Checking 7845** CAPI3REF: SQL Keyword Checking
@@ -8523,7 +8776,7 @@ typedef struct sqlite3_backup sqlite3_backup;
8523** if the application incorrectly accesses the destination [database connection] 8776** if the application incorrectly accesses the destination [database connection]
8524** and so no error code is reported, but the operations may malfunction 8777** and so no error code is reported, but the operations may malfunction
8525** nevertheless. Use of the destination database connection while a 8778** nevertheless. Use of the destination database connection while a
8526** backup is in progress might also also cause a mutex deadlock. 8779** backup is in progress might also cause a mutex deadlock.
8527** 8780**
8528** If running in [shared cache mode], the application must 8781** If running in [shared cache mode], the application must
8529** guarantee that the shared cache used by the destination database 8782** guarantee that the shared cache used by the destination database
@@ -8917,7 +9170,7 @@ typedef struct sqlite3_backup sqlite3_backup;
8917*/ 9170*/
8918#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */ 9171#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
8919#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */ 9172#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
8920#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */ 9173#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */
8921#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */ 9174#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
8922 9175
8923/* 9176/*
@@ -8984,7 +9237,7 @@ typedef struct sqlite3_backup sqlite3_backup;
8984** [[SQLITE_VTAB_DIRECTONLY]]<dt>SQLITE_VTAB_DIRECTONLY</dt> 9237** [[SQLITE_VTAB_DIRECTONLY]]<dt>SQLITE_VTAB_DIRECTONLY</dt>
8985** <dd>Calls of the form 9238** <dd>Calls of the form
8986** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the 9239** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the
8987** the [xConnect] or [xCreate] methods of a [virtual table] implmentation 9240** the [xConnect] or [xCreate] methods of a [virtual table] implementation
8988** prohibits that virtual table from being used from within triggers and 9241** prohibits that virtual table from being used from within triggers and
8989** views. 9242** views.
8990** </dd> 9243** </dd>
@@ -8992,18 +9245,28 @@ typedef struct sqlite3_backup sqlite3_backup;
8992** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt> 9245** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt>
8993** <dd>Calls of the form 9246** <dd>Calls of the form
8994** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the 9247** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the
8995** the [xConnect] or [xCreate] methods of a [virtual table] implmentation 9248** the [xConnect] or [xCreate] methods of a [virtual table] implementation
8996** identify that virtual table as being safe to use from within triggers 9249** identify that virtual table as being safe to use from within triggers
8997** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the 9250** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the
8998** virtual table can do no serious harm even if it is controlled by a 9251** virtual table can do no serious harm even if it is controlled by a
8999** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS 9252** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS
9000** flag unless absolutely necessary. 9253** flag unless absolutely necessary.
9001** </dd> 9254** </dd>
9255**
9256** [[SQLITE_VTAB_USES_ALL_SCHEMAS]]<dt>SQLITE_VTAB_USES_ALL_SCHEMAS</dt>
9257** <dd>Calls of the form
9258** [sqlite3_vtab_config](db,SQLITE_VTAB_USES_ALL_SCHEMA) from within the
9259** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9260** instruct the query planner to begin at least a read transaction on
9261** all schemas ("main", "temp", and any ATTACH-ed databases) whenever the
9262** virtual table is used.
9263** </dd>
9002** </dl> 9264** </dl>
9003*/ 9265*/
9004#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 9266#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
9005#define SQLITE_VTAB_INNOCUOUS 2 9267#define SQLITE_VTAB_INNOCUOUS 2
9006#define SQLITE_VTAB_DIRECTONLY 3 9268#define SQLITE_VTAB_DIRECTONLY 3
9269#define SQLITE_VTAB_USES_ALL_SCHEMAS 4
9007 9270
9008/* 9271/*
9009** CAPI3REF: Determine The Virtual Table Conflict Policy 9272** CAPI3REF: Determine The Virtual Table Conflict Policy
@@ -9160,7 +9423,7 @@ typedef struct sqlite3_backup sqlite3_backup;
9160** communicated to the xBestIndex method as a 9423** communicated to the xBestIndex method as a
9161** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use 9424** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
9162** this constraint, it must set the corresponding 9425** this constraint, it must set the corresponding
9163** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under 9426** aConstraintUsage[].argvIndex to a positive integer. ^(Then, under
9164** the usual mode of handling IN operators, SQLite generates [bytecode] 9427** the usual mode of handling IN operators, SQLite generates [bytecode]
9165** that invokes the [xFilter|xFilter() method] once for each value 9428** that invokes the [xFilter|xFilter() method] once for each value
9166** on the right-hand side of the IN operator.)^ Thus the virtual table 9429** on the right-hand side of the IN operator.)^ Thus the virtual table
@@ -9228,21 +9491,20 @@ typedef struct sqlite3_backup sqlite3_backup;
9228** is undefined and probably harmful. 9491** is undefined and probably harmful.
9229** 9492**
9230** The X parameter in a call to sqlite3_vtab_in_first(X,P) or 9493** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
9231** sqlite3_vtab_in_next(X,P) must be one of the parameters to the 9494** sqlite3_vtab_in_next(X,P) should be one of the parameters to the
9232** xFilter method which invokes these routines, and specifically 9495** xFilter method which invokes these routines, and specifically
9233** a parameter that was previously selected for all-at-once IN constraint 9496** a parameter that was previously selected for all-at-once IN constraint
9234** processing use the [sqlite3_vtab_in()] interface in the 9497** processing use the [sqlite3_vtab_in()] interface in the
9235** [xBestIndex|xBestIndex method]. ^(If the X parameter is not 9498** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
9236** an xFilter argument that was selected for all-at-once IN constraint 9499** an xFilter argument that was selected for all-at-once IN constraint
9237** processing, then these routines return [SQLITE_MISUSE])^ or perhaps 9500** processing, then these routines return [SQLITE_ERROR].)^
9238** exhibit some other undefined or harmful behavior.
9239** 9501**
9240** ^(Use these routines to access all values on the right-hand side 9502** ^(Use these routines to access all values on the right-hand side
9241** of the IN constraint using code like the following: 9503** of the IN constraint using code like the following:
9242** 9504**
9243** <blockquote><pre> 9505** <blockquote><pre>
9244** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal); 9506** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
9245** &nbsp; rc==SQLITE_OK && pVal 9507** &nbsp; rc==SQLITE_OK && pVal;
9246** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal) 9508** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
9247** &nbsp; ){ 9509** &nbsp; ){
9248** &nbsp; // do something with pVal 9510** &nbsp; // do something with pVal
@@ -9337,6 +9599,10 @@ typedef struct sqlite3_backup sqlite3_backup;
9337** managed by the prepared statement S and will be automatically freed when 9599** managed by the prepared statement S and will be automatically freed when
9338** S is finalized. 9600** S is finalized.
9339** 9601**
9602** Not all values are available for all query elements. When a value is
9603** not available, the output variable is set to -1 if the value is numeric,
9604** or to NULL if it is a string (SQLITE_SCANSTAT_NAME).
9605**
9340** <dl> 9606** <dl>
9341** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt> 9607** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
9342** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be 9608** <dd>^The [sqlite3_int64] variable pointed to by the V parameter will be
@@ -9364,12 +9630,24 @@ typedef struct sqlite3_backup sqlite3_backup;
9364** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] 9630** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
9365** description for the X-th loop. 9631** description for the X-th loop.
9366** 9632**
9367** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt> 9633** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECTID</dt>
9368** <dd>^The "int" variable pointed to by the V parameter will be set to the 9634** <dd>^The "int" variable pointed to by the V parameter will be set to the
9369** "select-id" for the X-th loop. The select-id identifies which query or 9635** id for the X-th query plan element. The id value is unique within the
9370** subquery the loop is part of. The main query has a select-id of zero. 9636** statement. The select-id is the same value as is output in the first
9371** The select-id is the same value as is output in the first column 9637** column of an [EXPLAIN QUERY PLAN] query.
9372** of an [EXPLAIN QUERY PLAN] query. 9638**
9639** [[SQLITE_SCANSTAT_PARENTID]] <dt>SQLITE_SCANSTAT_PARENTID</dt>
9640** <dd>The "int" variable pointed to by the V parameter will be set to the
9641** the id of the parent of the current query element, if applicable, or
9642** to zero if the query element has no parent. This is the same value as
9643** returned in the second column of an [EXPLAIN QUERY PLAN] query.
9644**
9645** [[SQLITE_SCANSTAT_NCYCLE]] <dt>SQLITE_SCANSTAT_NCYCLE</dt>
9646** <dd>The sqlite3_int64 output value is set to the number of cycles,
9647** according to the processor time-stamp counter, that elapsed while the
9648** query element was being processed. This value is not available for
9649** all query elements - if it is unavailable the output variable is
9650** set to -1.
9373** </dl> 9651** </dl>
9374*/ 9652*/
9375#define SQLITE_SCANSTAT_NLOOP 0 9653#define SQLITE_SCANSTAT_NLOOP 0
@@ -9378,12 +9656,14 @@ typedef struct sqlite3_backup sqlite3_backup;
9378#define SQLITE_SCANSTAT_NAME 3 9656#define SQLITE_SCANSTAT_NAME 3
9379#define SQLITE_SCANSTAT_EXPLAIN 4 9657#define SQLITE_SCANSTAT_EXPLAIN 4
9380#define SQLITE_SCANSTAT_SELECTID 5 9658#define SQLITE_SCANSTAT_SELECTID 5
9659#define SQLITE_SCANSTAT_PARENTID 6
9660#define SQLITE_SCANSTAT_NCYCLE 7
9381 9661
9382/* 9662/*
9383** CAPI3REF: Prepared Statement Scan Status 9663** CAPI3REF: Prepared Statement Scan Status
9384** METHOD: sqlite3_stmt 9664** METHOD: sqlite3_stmt
9385** 9665**
9386** This interface returns information about the predicted and measured 9666** These interfaces return information about the predicted and measured
9387** performance for pStmt. Advanced applications can use this 9667** performance for pStmt. Advanced applications can use this
9388** interface to compare the predicted and the measured performance and 9668** interface to compare the predicted and the measured performance and
9389** issue warnings and/or rerun [ANALYZE] if discrepancies are found. 9669** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
@@ -9394,24 +9674,36 @@ typedef struct sqlite3_backup sqlite3_backup;
9394** 9674**
9395** The "iScanStatusOp" parameter determines which status information to return. 9675** The "iScanStatusOp" parameter determines which status information to return.
9396** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior 9676** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
9397** of this interface is undefined. 9677** of this interface is undefined. ^The requested measurement is written into
9398** ^The requested measurement is written into a variable pointed to by 9678** a variable pointed to by the "pOut" parameter.
9399** the "pOut" parameter. 9679**
9400** Parameter "idx" identifies the specific loop to retrieve statistics for. 9680** The "flags" parameter must be passed a mask of flags. At present only
9401** Loops are numbered starting from zero. ^If idx is out of range - less than 9681** one flag is defined - SQLITE_SCANSTAT_COMPLEX. If SQLITE_SCANSTAT_COMPLEX
9402** zero or greater than or equal to the total number of loops used to implement 9682** is specified, then status information is available for all elements
9403** the statement - a non-zero value is returned and the variable that pOut 9683** of a query plan that are reported by "EXPLAIN QUERY PLAN" output. If
9404** points to is unchanged. 9684** SQLITE_SCANSTAT_COMPLEX is not specified, then only query plan elements
9405** 9685** that correspond to query loops (the "SCAN..." and "SEARCH..." elements of
9406** ^Statistics might not be available for all loops in all statements. ^In cases 9686** the EXPLAIN QUERY PLAN output) are available. Invoking API
9407** where there exist loops with no available statistics, this function behaves 9687** sqlite3_stmt_scanstatus() is equivalent to calling
9408** as if the loop did not exist - it returns non-zero and leave the variable 9688** sqlite3_stmt_scanstatus_v2() with a zeroed flags parameter.
9409** that pOut points to unchanged. 9689**
9690** Parameter "idx" identifies the specific query element to retrieve statistics
9691** for. Query elements are numbered starting from zero. A value of -1 may be
9692** to query for statistics regarding the entire query. ^If idx is out of range
9693** - less than -1 or greater than or equal to the total number of query
9694** elements used to implement the statement - a non-zero value is returned and
9695** the variable that pOut points to is unchanged.
9410** 9696**
9411** See also: [sqlite3_stmt_scanstatus_reset()] 9697** See also: [sqlite3_stmt_scanstatus_reset()]
9412*/ 9698*/
9413 9699
9414/* 9700/*
9701** CAPI3REF: Prepared Statement Scan Status
9702** KEYWORDS: {scan status flags}
9703*/
9704#define SQLITE_SCANSTAT_COMPLEX 0x0001
9705
9706/*
9415** CAPI3REF: Zero Scan-Status Counters 9707** CAPI3REF: Zero Scan-Status Counters
9416** METHOD: sqlite3_stmt 9708** METHOD: sqlite3_stmt
9417** 9709**
@@ -9498,6 +9790,10 @@ typedef struct sqlite3_backup sqlite3_backup;
9498** function is not defined for operations on WITHOUT ROWID tables, or for 9790** function is not defined for operations on WITHOUT ROWID tables, or for
9499** DELETE operations on rowid tables. 9791** DELETE operations on rowid tables.
9500** 9792**
9793** ^The sqlite3_preupdate_hook(D,C,P) function returns the P argument from
9794** the previous call on the same [database connection] D, or NULL for
9795** the first call on D.
9796**
9501** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()], 9797** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],
9502** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces 9798** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces
9503** provide additional information about a preupdate event. These routines 9799** provide additional information about a preupdate event. These routines
@@ -9537,7 +9833,7 @@ typedef struct sqlite3_backup sqlite3_backup;
9537** When the [sqlite3_blob_write()] API is used to update a blob column, 9833** When the [sqlite3_blob_write()] API is used to update a blob column,
9538** the pre-update hook is invoked with SQLITE_DELETE. This is because the 9834** the pre-update hook is invoked with SQLITE_DELETE. This is because the
9539** in this case the new values are not available. In this case, when a 9835** in this case the new values are not available. In this case, when a
9540** callback made with op==SQLITE_DELETE is actuall a write using the 9836** callback made with op==SQLITE_DELETE is actually a write using the
9541** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns 9837** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns
9542** the index of the column being written. In other cases, where the 9838** the index of the column being written. In other cases, where the
9543** pre-update hook is being invoked for some other reason, including a 9839** pre-update hook is being invoked for some other reason, including a
@@ -9763,6 +10059,13 @@ typedef struct sqlite3_snapshot {
9763** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy 10059** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
9764** of the database exists. 10060** of the database exists.
9765** 10061**
10062** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set,
10063** the returned buffer content will remain accessible and unchanged
10064** until either the next write operation on the connection or when
10065** the connection is closed, and applications must not modify the
10066** buffer. If the bit had been clear, the returned buffer will not
10067** be accessed by SQLite after the call.
10068**
9766** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the 10069** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
9767** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory 10070** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
9768** allocation error occurs. 10071** allocation error occurs.
@@ -9805,6 +10108,9 @@ typedef struct sqlite3_snapshot {
9805** SQLite will try to increase the buffer size using sqlite3_realloc64() 10108** SQLite will try to increase the buffer size using sqlite3_realloc64()
9806** if writes on the database cause it to grow larger than M bytes. 10109** if writes on the database cause it to grow larger than M bytes.
9807** 10110**
10111** Applications must not modify the buffer P or invalidate it before
10112** the database connection D is closed.
10113**
9808** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the 10114** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
9809** database is currently in a read transaction or is involved in a backup 10115** database is currently in a read transaction or is involved in a backup
9810** operation. 10116** operation.
@@ -9813,6 +10119,13 @@ typedef struct sqlite3_snapshot {
9813** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the 10119** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
9814** function returns SQLITE_ERROR. 10120** function returns SQLITE_ERROR.
9815** 10121**
10122** The deserialized database should not be in [WAL mode]. If the database
10123** is in WAL mode, then any attempt to use the database file will result
10124** in an [SQLITE_CANTOPEN] error. The application can set the
10125** [file format version numbers] (bytes 18 and 19) of the input database P
10126** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the
10127** database file into rollback mode and work around this limitation.
10128**
9816** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the 10129** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
9817** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then 10130** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
9818** [sqlite3_free()] is invoked on argument P prior to returning. 10131** [sqlite3_free()] is invoked on argument P prior to returning.
@@ -9854,6 +10167,19 @@ typedef struct sqlite3_snapshot {
9854# undef double 10167# undef double
9855#endif 10168#endif
9856 10169
10170#if defined(__wasi__)
10171# undef SQLITE_WASI
10172# define SQLITE_WASI 1
10173# undef SQLITE_OMIT_WAL
10174# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
10175# ifndef SQLITE_OMIT_LOAD_EXTENSION
10176# define SQLITE_OMIT_LOAD_EXTENSION
10177# endif
10178# ifndef SQLITE_THREADSAFE
10179# define SQLITE_THREADSAFE 0
10180# endif
10181#endif
10182
9857#ifdef __cplusplus 10183#ifdef __cplusplus
9858} /* End of the 'extern "C"' block */ 10184} /* End of the 'extern "C"' block */
9859#endif 10185#endif
@@ -10041,16 +10367,19 @@ typedef struct sqlite3_changeset_iter sqlite3_changeset_iter;
10041*/ 10367*/
10042 10368
10043/* 10369/*
10044** CAPIREF: Conigure a Session Object 10370** CAPI3REF: Configure a Session Object
10045** METHOD: sqlite3_session 10371** METHOD: sqlite3_session
10046** 10372**
10047** This method is used to configure a session object after it has been 10373** This method is used to configure a session object after it has been
10048** created. At present the only valid value for the second parameter is 10374** created. At present the only valid values for the second parameter are
10049** [SQLITE_SESSION_OBJCONFIG_SIZE]. 10375** [SQLITE_SESSION_OBJCONFIG_SIZE] and [SQLITE_SESSION_OBJCONFIG_ROWID].
10050** 10376**
10051** Arguments for sqlite3session_object_config() 10377*/
10378
10379/*
10380** CAPI3REF: Options for sqlite3session_object_config
10052** 10381**
10053** The following values may passed as the the 4th parameter to 10382** The following values may passed as the the 2nd parameter to
10054** sqlite3session_object_config(). 10383** sqlite3session_object_config().
10055** 10384**
10056** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd> 10385** <dt>SQLITE_SESSION_OBJCONFIG_SIZE <dd>
@@ -10066,11 +10395,21 @@ typedef struct sqlite3_changeset_iter sqlite3_changeset_iter;
10066** 10395**
10067** It is an error (SQLITE_MISUSE) to attempt to modify this setting after 10396** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
10068** the first table has been attached to the session object. 10397** the first table has been attached to the session object.
10398**
10399** <dt>SQLITE_SESSION_OBJCONFIG_ROWID <dd>
10400** This option is used to set, clear or query the flag that enables
10401** collection of data for tables with no explicit PRIMARY KEY.
10402**
10403** Normally, tables with no explicit PRIMARY KEY are simply ignored
10404** by the sessions module. However, if this flag is set, it behaves
10405** as if such tables have a column "_rowid_ INTEGER PRIMARY KEY" inserted
10406** as their leftmost columns.
10407**
10408** It is an error (SQLITE_MISUSE) to attempt to modify this setting after
10409** the first table has been attached to the session object.
10069*/ 10410*/
10070 10411#define SQLITE_SESSION_OBJCONFIG_SIZE 1
10071/* 10412#define SQLITE_SESSION_OBJCONFIG_ROWID 2
10072*/
10073#define SQLITE_SESSION_OBJCONFIG_SIZE 1
10074 10413
10075/* 10414/*
10076** CAPI3REF: Enable Or Disable A Session Object 10415** CAPI3REF: Enable Or Disable A Session Object
@@ -10743,6 +11082,12 @@ typedef struct sqlite3_changeset_iter sqlite3_changeset_iter;
10743 11082
10744 11083
10745/* 11084/*
11085** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
11086*/
11087
11088
11089
11090/*
10746** CAPI3REF: Changegroup Handle 11091** CAPI3REF: Changegroup Handle
10747** 11092**
10748** A changegroup is an object used to combine two or more 11093** A changegroup is an object used to combine two or more
@@ -10788,6 +11133,37 @@ typedef struct sqlite3_changegroup sqlite3_changegroup;
10788*/ 11133*/
10789 11134
10790/* 11135/*
11136** CAPI3REF: Add a Schema to a Changegroup
11137** METHOD: sqlite3_changegroup_schema
11138**
11139** This method may be used to optionally enforce the rule that the changesets
11140** added to the changegroup handle must match the schema of database zDb
11141** ("main", "temp", or the name of an attached database). If
11142** sqlite3changegroup_add() is called to add a changeset that is not compatible
11143** with the configured schema, SQLITE_SCHEMA is returned and the changegroup
11144** object is left in an undefined state.
11145**
11146** A changeset schema is considered compatible with the database schema in
11147** the same way as for sqlite3changeset_apply(). Specifically, for each
11148** table in the changeset, there exists a database table with:
11149**
11150** <ul>
11151** <li> The name identified by the changeset, and
11152** <li> at least as many columns as recorded in the changeset, and
11153** <li> the primary key columns in the same position as recorded in
11154** the changeset.
11155** </ul>
11156**
11157** The output of the changegroup object always has the same schema as the
11158** database nominated using this function. In cases where changesets passed
11159** to sqlite3changegroup_add() have fewer columns than the corresponding table
11160** in the database schema, these are filled in using the default column
11161** values from the database schema. This makes it possible to combined
11162** changesets that have different numbers of columns for a single table
11163** within a changegroup, provided that they are otherwise compatible.
11164*/
11165
11166/*
10791** CAPI3REF: Add A Changeset To A Changegroup 11167** CAPI3REF: Add A Changeset To A Changegroup
10792** METHOD: sqlite3_changegroup 11168** METHOD: sqlite3_changegroup
10793** 11169**
@@ -10855,13 +11231,18 @@ typedef struct sqlite3_changegroup sqlite3_changegroup;
10855** If the new changeset contains changes to a table that is already present 11231** If the new changeset contains changes to a table that is already present
10856** in the changegroup, then the number of columns and the position of the 11232** in the changegroup, then the number of columns and the position of the
10857** primary key columns for the table must be consistent. If this is not the 11233** primary key columns for the table must be consistent. If this is not the
10858** case, this function fails with SQLITE_SCHEMA. If the input changeset 11234** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup
10859** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is 11235** object has been configured with a database schema using the
10860** returned. Or, if an out-of-memory condition occurs during processing, this 11236** sqlite3changegroup_schema() API, then it is possible to combine changesets
10861** function returns SQLITE_NOMEM. In all cases, if an error occurs the state 11237** with different numbers of columns for a single table, provided that
10862** of the final contents of the changegroup is undefined. 11238** they are otherwise compatible.
10863** 11239**
10864** If no error occurs, SQLITE_OK is returned. 11240** If the input changeset appears to be corrupt and the corruption is
11241** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition
11242** occurs during processing, this function returns SQLITE_NOMEM.
11243**
11244** In all cases, if an error occurs the state of the final contents of the
11245** changegroup is undefined. If no error occurs, SQLITE_OK is returned.
10865*/ 11246*/
10866 11247
10867/* 11248/*
@@ -11074,9 +11455,30 @@ typedef struct sqlite3_changegroup sqlite3_changegroup;
11074** Invert the changeset before applying it. This is equivalent to inverting 11455** Invert the changeset before applying it. This is equivalent to inverting
11075** a changeset using sqlite3changeset_invert() before applying it. It is 11456** a changeset using sqlite3changeset_invert() before applying it. It is
11076** an error to specify this flag with a patchset. 11457** an error to specify this flag with a patchset.
11458**
11459** <dt>SQLITE_CHANGESETAPPLY_IGNORENOOP <dd>
11460** Do not invoke the conflict handler callback for any changes that
11461** would not actually modify the database even if they were applied.
11462** Specifically, this means that the conflict handler is not invoked
11463** for:
11464** <ul>
11465** <li>a delete change if the row being deleted cannot be found,
11466** <li>an update change if the modified fields are already set to
11467** their new values in the conflicting row, or
11468** <li>an insert change if all fields of the conflicting row match
11469** the row being inserted.
11470** </ul>
11471**
11472** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
11473** If this flag it set, then all foreign key constraints in the target
11474** database behave as if they were declared with "ON UPDATE NO ACTION ON
11475** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
11476** or SET DEFAULT.
11077*/ 11477*/
11078#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 11478#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
11079#define SQLITE_CHANGESETAPPLY_INVERT 0x0002 11479#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
11480#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
11481#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
11080 11482
11081/* 11483/*
11082** CAPI3REF: Constants Passed To The Conflict Handler 11484** CAPI3REF: Constants Passed To The Conflict Handler
@@ -11723,7 +12125,7 @@ struct Fts5PhraseIter {
11723** See xPhraseFirstColumn above. 12125** See xPhraseFirstColumn above.
11724*/ 12126*/
11725struct Fts5ExtensionApi { 12127struct Fts5ExtensionApi {
11726 int iVersion; /* Currently always set to 3 */ 12128 int iVersion; /* Currently always set to 2 */
11727 12129
11728 void *(*xUserData)(Fts5Context*); 12130 void *(*xUserData)(Fts5Context*);
11729 12131
@@ -11952,8 +12354,8 @@ struct Fts5ExtensionApi {
11952** as separate queries of the FTS index are required for each synonym. 12354** as separate queries of the FTS index are required for each synonym.
11953** 12355**
11954** When using methods (2) or (3), it is important that the tokenizer only 12356** When using methods (2) or (3), it is important that the tokenizer only
11955** provide synonyms when tokenizing document text (method (2)) or query 12357** provide synonyms when tokenizing document text (method (3)) or query
11956** text (method (3)), not both. Doing so will not cause any errors, but is 12358** text (method (2)), not both. Doing so will not cause any errors, but is
11957** inefficient. 12359** inefficient.
11958*/ 12360*/
11959typedef struct Fts5Tokenizer Fts5Tokenizer; 12361typedef struct Fts5Tokenizer Fts5Tokenizer;
@@ -12001,7 +12403,7 @@ struct fts5_api {
12001 int (*xCreateTokenizer)( 12403 int (*xCreateTokenizer)(
12002 fts5_api *pApi, 12404 fts5_api *pApi,
12003 const char *zName, 12405 const char *zName,
12004 void *pContext, 12406 void *pUserData,
12005 fts5_tokenizer *pTokenizer, 12407 fts5_tokenizer *pTokenizer,
12006 void (*xDestroy)(void*) 12408 void (*xDestroy)(void*)
12007 ); 12409 );
@@ -12010,7 +12412,7 @@ struct fts5_api {
12010 int (*xFindTokenizer)( 12412 int (*xFindTokenizer)(
12011 fts5_api *pApi, 12413 fts5_api *pApi,
12012 const char *zName, 12414 const char *zName,
12013 void **ppContext, 12415 void **ppUserData,
12014 fts5_tokenizer *pTokenizer 12416 fts5_tokenizer *pTokenizer
12015 ); 12417 );
12016 12418
@@ -12018,7 +12420,7 @@ struct fts5_api {
12018 int (*xCreateFunction)( 12420 int (*xCreateFunction)(
12019 fts5_api *pApi, 12421 fts5_api *pApi,
12020 const char *zName, 12422 const char *zName,
12021 void *pContext, 12423 void *pUserData,
12022 fts5_extension_function xFunction, 12424 fts5_extension_function xFunction,
12023 void (*xDestroy)(void*) 12425 void (*xDestroy)(void*)
12024 ); 12426 );