Index: third_party/sqlite/amalgamation/sqlite3.h |
diff --git a/third_party/sqlite/amalgamation/sqlite3.h b/third_party/sqlite/amalgamation/sqlite3.h |
index 91ac9145f8979ae8931d0c47f9ca4b56a9148aa6..db1831a52fc4f7e73efa95476ea5a01df7d71181 100644 |
--- a/third_party/sqlite/amalgamation/sqlite3.h |
+++ b/third_party/sqlite/amalgamation/sqlite3.h |
@@ -107,9 +107,9 @@ extern "C" { |
** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
** [sqlite_version()] and [sqlite_source_id()]. |
*/ |
-#define SQLITE_VERSION "3.7.6.3" |
-#define SQLITE_VERSION_NUMBER 3007006 |
-#define SQLITE_SOURCE_ID "2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e" |
+#define SQLITE_VERSION "3.8.7.4" |
+#define SQLITE_VERSION_NUMBER 3008007 |
+#define SQLITE_SOURCE_ID "2014-12-09 01:34:36 f66f7a17b78ba617acde90fc810107f34f1a1f2e" |
/* |
** CAPI3REF: Run-Time Library Version Numbers |
@@ -177,7 +177,7 @@ SQLITE_API const char *sqlite3_compileoption_get(int N); |
** CAPI3REF: Test To See If The Library Is Threadsafe |
** |
** ^The sqlite3_threadsafe() function returns zero if and only if |
-** SQLite was compiled mutexing code omitted due to the |
+** SQLite was compiled with mutexing code omitted due to the |
** [SQLITE_THREADSAFE] compile-time option being set to 0. |
** |
** SQLite can be compiled with or without mutexes. When |
@@ -219,7 +219,8 @@ SQLITE_API int sqlite3_threadsafe(void); |
** the opaque structure named "sqlite3". It is useful to think of an sqlite3 |
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and |
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] |
-** is its destructor. There are many other interfaces (such as |
+** and [sqlite3_close_v2()] are its destructors. There are many other |
+** interfaces (such as |
** [sqlite3_prepare_v2()], [sqlite3_create_function()], and |
** [sqlite3_busy_timeout()] to name but three) that are methods on an |
** sqlite3 object. |
@@ -266,28 +267,46 @@ typedef sqlite_uint64 sqlite3_uint64; |
/* |
** CAPI3REF: Closing A Database Connection |
** |
-** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. |
-** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is |
-** successfully destroyed and all associated resources are deallocated. |
-** |
-** Applications must [sqlite3_finalize | finalize] all [prepared statements] |
-** and [sqlite3_blob_close | close] all [BLOB handles] associated with |
-** the [sqlite3] object prior to attempting to close the object. ^If |
-** sqlite3_close() is called on a [database connection] that still has |
-** outstanding [prepared statements] or [BLOB handles], then it returns |
-** SQLITE_BUSY. |
-** |
-** ^If [sqlite3_close()] is invoked while a transaction is open, |
+** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors |
+** for the [sqlite3] object. |
+** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if |
+** the [sqlite3] object is successfully destroyed and all associated |
+** resources are deallocated. |
+** |
+** ^If the database connection is associated with unfinalized prepared |
+** statements or unfinished sqlite3_backup objects then sqlite3_close() |
+** will leave the database connection open and return [SQLITE_BUSY]. |
+** ^If sqlite3_close_v2() is called with unfinalized prepared statements |
+** and/or unfinished sqlite3_backups, then the database connection becomes |
+** an unusable "zombie" which will automatically be deallocated when the |
+** last prepared statement is finalized or the last sqlite3_backup is |
+** finished. The sqlite3_close_v2() interface is intended for use with |
+** host languages that are garbage collected, and where the order in which |
+** destructors are called is arbitrary. |
+** |
+** Applications should [sqlite3_finalize | finalize] all [prepared statements], |
+** [sqlite3_blob_close | close] all [BLOB handles], and |
+** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated |
+** with the [sqlite3] object prior to attempting to close the object. ^If |
+** sqlite3_close_v2() is called on a [database connection] that still has |
+** outstanding [prepared statements], [BLOB handles], and/or |
+** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation |
+** of resources is deferred until all [prepared statements], [BLOB handles], |
+** and [sqlite3_backup] objects are also destroyed. |
+** |
+** ^If an [sqlite3] object is destroyed while a transaction is open, |
** the transaction is automatically rolled back. |
** |
-** The C parameter to [sqlite3_close(C)] must be either a NULL |
+** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)] |
+** must be either a NULL |
** pointer or an [sqlite3] object pointer obtained |
** from [sqlite3_open()], [sqlite3_open16()], or |
** [sqlite3_open_v2()], and not previously closed. |
-** ^Calling sqlite3_close() with a NULL pointer argument is a |
-** harmless no-op. |
+** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer |
+** argument is a harmless no-op. |
*/ |
-SQLITE_API int sqlite3_close(sqlite3 *); |
+SQLITE_API int sqlite3_close(sqlite3*); |
+SQLITE_API int sqlite3_close_v2(sqlite3*); |
/* |
** The type for a callback function. |
@@ -310,7 +329,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); |
** argument. ^If the callback function of the 3rd argument to |
** sqlite3_exec() is not NULL, then it is invoked for each result row |
** coming out of the evaluated SQL statements. ^The 4th argument to |
-** to sqlite3_exec() is relayed through to the 1st argument of each |
+** sqlite3_exec() is relayed through to the 1st argument of each |
** callback invocation. ^If the callback pointer to sqlite3_exec() |
** is NULL, then no callback is ever invoked and result rows are |
** ignored. |
@@ -351,7 +370,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); |
** <ul> |
** <li> The application must insure that the 1st parameter to sqlite3_exec() |
** is a valid and open [database connection]. |
-** <li> The application must not close [database connection] specified by |
+** <li> The application must not close the [database connection] specified by |
** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. |
** <li> The application must not modify the SQL statement text passed into |
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. |
@@ -367,15 +386,14 @@ SQLITE_API int sqlite3_exec( |
/* |
** CAPI3REF: Result Codes |
-** KEYWORDS: SQLITE_OK {error code} {error codes} |
-** KEYWORDS: {result code} {result codes} |
+** KEYWORDS: {result code definitions} |
** |
** Many SQLite functions return an integer result code from the set shown |
-** here in order to indicates success or failure. |
+** here in order to indicate success or failure. |
** |
** New error codes may be added in future versions of SQLite. |
** |
-** See also: [SQLITE_IOERR_READ | extended result codes] |
+** See also: [extended result code definitions] |
*/ |
#define SQLITE_OK 0 /* Successful result */ |
/* beginning-of-error-codes */ |
@@ -405,32 +423,27 @@ SQLITE_API int sqlite3_exec( |
#define SQLITE_FORMAT 24 /* Auxiliary database format error */ |
#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ |
#define SQLITE_NOTADB 26 /* File opened that is not a database file */ |
+#define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */ |
+#define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */ |
#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ |
#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ |
/* end-of-error-codes */ |
/* |
** CAPI3REF: Extended Result Codes |
-** KEYWORDS: {extended error code} {extended error codes} |
-** KEYWORDS: {extended result code} {extended result codes} |
+** KEYWORDS: {extended result code definitions} |
** |
-** In its default configuration, SQLite API routines return one of 26 integer |
-** [SQLITE_OK | result codes]. However, experience has shown that many of |
+** In its default configuration, SQLite API routines return one of 30 integer |
+** [result codes]. However, experience has shown that many of |
** these result codes are too coarse-grained. They do not provide as |
** much information about problems as programmers might like. In an effort to |
** address this, newer versions of SQLite (version 3.3.8 and later) include |
** support for additional result codes that provide more detailed information |
-** about errors. The extended result codes are enabled or disabled |
+** about errors. These [extended result codes] are enabled or disabled |
** on a per database connection basis using the |
-** [sqlite3_extended_result_codes()] API. |
-** |
-** Some of the available extended result codes are listed here. |
-** One may expect the number of extended result codes will be expand |
-** over time. Software that uses extended result codes should expect |
-** to see new result codes in future releases of SQLite. |
-** |
-** The SQLITE_OK result code will never be extended. It will always |
-** be exactly zero. |
+** [sqlite3_extended_result_codes()] API. Or, the extended code for |
+** the most recent error can be obtained using |
+** [sqlite3_extended_errcode()]. |
*/ |
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) |
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) |
@@ -452,17 +465,46 @@ SQLITE_API int sqlite3_exec( |
#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8)) |
#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) |
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) |
+#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) |
+#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) |
+#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) |
+#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) |
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) |
+#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) |
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) |
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) |
+#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) |
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) |
+#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) |
+#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) |
+#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) |
+#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) |
+#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) |
+#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) |
+#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8)) |
+#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8)) |
+#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) |
+#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8)) |
+#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8)) |
+#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8)) |
+#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8)) |
+#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8)) |
+#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) |
+#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) |
+#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) |
+#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) |
+#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) |
+#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) |
+#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) |
+#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) |
+#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) |
/* |
** CAPI3REF: Flags For File Open Operations |
** |
** These bit values are intended for use in the |
** 3rd parameter to the [sqlite3_open_v2()] interface and |
-** in the 4th parameter to the xOpen method of the |
-** [sqlite3_vfs] object. |
+** in the 4th parameter to the [sqlite3_vfs.xOpen] method. |
*/ |
#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ |
#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ |
@@ -470,6 +512,8 @@ SQLITE_API int sqlite3_exec( |
#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ |
#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ |
#define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ |
+#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ |
+#define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */ |
#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ |
#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ |
#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ |
@@ -489,7 +533,7 @@ SQLITE_API int sqlite3_exec( |
** CAPI3REF: Device Characteristics |
** |
** The xDeviceCharacteristics method of the [sqlite3_io_methods] |
-** object returns an integer which is a vector of the these |
+** object returns an integer which is a vector of these |
** bit values expressing I/O characteristics of the mass storage |
** device that holds the file that the [sqlite3_io_methods] |
** refers to. |
@@ -503,7 +547,15 @@ SQLITE_API int sqlite3_exec( |
** first then the size of the file is extended, never the other |
** way around. The SQLITE_IOCAP_SEQUENTIAL property means that |
** information is written to disk in the same order as calls |
-** to xWrite(). |
+** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that |
+** after reboot following a crash or power loss, the only bytes in a |
+** file that were written at the application level might have changed |
+** and that adjacent bytes, even bytes within the same sector are |
+** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
+** flag indicate that a file cannot be deleted when open. The |
+** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on |
+** read-only media and cannot be changed even by processes with |
+** elevated privileges. |
*/ |
#define SQLITE_IOCAP_ATOMIC 0x00000001 |
#define SQLITE_IOCAP_ATOMIC512 0x00000002 |
@@ -517,6 +569,8 @@ SQLITE_API int sqlite3_exec( |
#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 |
#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 |
#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 |
+#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 |
+#define SQLITE_IOCAP_IMMUTABLE 0x00002000 |
/* |
** CAPI3REF: File Locking Levels |
@@ -580,17 +634,18 @@ struct sqlite3_file { |
/* |
** CAPI3REF: OS Interface File Virtual Methods Object |
** |
-** Every file opened by the [sqlite3_vfs] xOpen method populates an |
+** Every file opened by the [sqlite3_vfs.xOpen] method populates an |
** [sqlite3_file] object (or, more commonly, a subclass of the |
** [sqlite3_file] object) with a pointer to an instance of this object. |
** This object defines the methods used to perform various operations |
** against the open file represented by the [sqlite3_file] object. |
** |
-** If the xOpen method sets the sqlite3_file.pMethods element |
+** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element |
** to a non-NULL pointer, then the sqlite3_io_methods.xClose method |
-** may be invoked even if the xOpen reported that it failed. The |
-** only way to prevent a call to xClose following a failed xOpen |
-** is for the xOpen to set the sqlite3_file.pMethods element to NULL. |
+** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The |
+** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] |
+** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element |
+** to NULL. |
** |
** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or |
** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). |
@@ -622,7 +677,7 @@ struct sqlite3_file { |
** locking strategy (for example to use dot-file locks), to inquire |
** about the status of a lock, or to break stale locks. The SQLite |
** core reserves all opcodes less than 100 for its own use. |
-** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. |
+** A [file control opcodes | list of opcodes] less than 100 is available. |
** Applications that define a custom xFileControl method should use opcodes |
** greater than 100 to avoid conflicts. VFS implementations should |
** return [SQLITE_NOTFOUND] for file control opcodes that they do not |
@@ -687,11 +742,15 @@ struct sqlite3_io_methods { |
void (*xShmBarrier)(sqlite3_file*); |
int (*xShmUnmap)(sqlite3_file*, int deleteFlag); |
/* Methods above are valid for version 2 */ |
+ int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp); |
+ int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); |
+ /* Methods above are valid for version 3 */ |
/* Additional methods may be added in future releases */ |
}; |
/* |
** CAPI3REF: Standard File Control Opcodes |
+** KEYWORDS: {file control opcodes} {file control opcode} |
** |
** These integer constants are opcodes for the xFileControl method |
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] |
@@ -704,7 +763,8 @@ struct sqlite3_io_methods { |
** into an integer that the pArg argument points to. This capability |
** is used during testing and only needs to be supported when SQLITE_TEST |
** is defined. |
-** |
+** <ul> |
+** <li>[[SQLITE_FCNTL_SIZE_HINT]] |
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS |
** layer a hint of how large the database file will grow to be during the |
** current transaction. This hint is not guaranteed to be accurate but it |
@@ -712,6 +772,7 @@ struct sqlite3_io_methods { |
** file space based on this hint in order to help writes to the database |
** file run faster. |
** |
+** <li>[[SQLITE_FCNTL_CHUNK_SIZE]] |
** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS |
** extends and truncates the database file in chunks of a size specified |
** by the user. The fourth argument to [sqlite3_file_control()] should |
@@ -720,30 +781,195 @@ struct sqlite3_io_methods { |
** chunks (say 1MB at a time), may reduce file-system fragmentation and |
** improve performance on some systems. |
** |
+** <li>[[SQLITE_FCNTL_FILE_POINTER]] |
** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer |
** to the [sqlite3_file] object associated with a particular database |
** connection. See the [sqlite3_file_control()] documentation for |
** additional information. |
** |
-** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by |
-** SQLite and sent to all VFSes in place of a call to the xSync method |
-** when the database connection has [PRAGMA synchronous] set to OFF.)^ |
-** Some specialized VFSes need this signal in order to operate correctly |
-** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most |
-** VFSes do not need this signal and should silently ignore this opcode. |
-** Applications should not call [sqlite3_file_control()] with this |
-** opcode as doing so may disrupt the operation of the specialized VFSes |
-** that do require it. |
+** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] |
+** No longer in use. |
+** |
+** <li>[[SQLITE_FCNTL_SYNC]] |
+** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and |
+** sent to the VFS immediately before the xSync method is invoked on a |
+** database file descriptor. Or, if the xSync method is not invoked |
+** because the user has configured SQLite with |
+** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place |
+** of the xSync method. In most cases, the pointer argument passed with |
+** this file-control is NULL. However, if the database file is being synced |
+** as part of a multi-database commit, the argument points to a nul-terminated |
+** string containing the transactions master-journal file name. VFSes that |
+** do not need this signal should silently ignore this opcode. Applications |
+** should not call [sqlite3_file_control()] with this opcode as doing so may |
+** disrupt the operation of the specialized VFSes that do require it. |
+** |
+** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]] |
+** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite |
+** and sent to the VFS after a transaction has been committed immediately |
+** but before the database is unlocked. VFSes that do not need this signal |
+** should silently ignore this opcode. Applications should not call |
+** [sqlite3_file_control()] with this opcode as doing so may disrupt the |
+** operation of the specialized VFSes that do require it. |
+** |
+** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]] |
+** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic |
+** retry counts and intervals for certain disk I/O operations for the |
+** windows [VFS] in order to provide robustness in the presence of |
+** anti-virus programs. By default, the windows VFS will retry file read, |
+** file write, and file delete operations up to 10 times, with a delay |
+** of 25 milliseconds before the first retry and with the delay increasing |
+** by an additional 25 milliseconds with each subsequent retry. This |
+** opcode allows these two values (10 retries and 25 milliseconds of delay) |
+** to be adjusted. The values are changed for all database connections |
+** within the same process. The argument is a pointer to an array of two |
+** integers where the first integer i the new retry count and the second |
+** integer is the delay. If either integer is negative, then the setting |
+** is not changed but instead the prior value of that setting is written |
+** into the array entry, allowing the current retry settings to be |
+** interrogated. The zDbName parameter is ignored. |
+** |
+** <li>[[SQLITE_FCNTL_PERSIST_WAL]] |
+** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the |
+** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary |
+** write ahead log and shared memory files used for transaction control |
+** are automatically deleted when the latest connection to the database |
+** closes. Setting persistent WAL mode causes those files to persist after |
+** close. Persisting the files is useful when other processes that do not |
+** have write permission on the directory containing the database file want |
+** to read the database file, as the WAL and shared memory files must exist |
+** in order for the database to be readable. The fourth parameter to |
+** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
+** That integer is 0 to disable persistent WAL mode or 1 to enable persistent |
+** WAL mode. If the integer is -1, then it is overwritten with the current |
+** WAL persistence setting. |
+** |
+** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]] |
+** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the |
+** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting |
+** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the |
+** xDeviceCharacteristics methods. The fourth parameter to |
+** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
+** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage |
+** mode. If the integer is -1, then it is overwritten with the current |
+** zero-damage mode setting. |
+** |
+** <li>[[SQLITE_FCNTL_OVERWRITE]] |
+** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening |
+** a write transaction to indicate that, unless it is rolled back for some |
+** reason, the entire database file will be overwritten by the current |
+** transaction. This is used by VACUUM operations. |
+** |
+** <li>[[SQLITE_FCNTL_VFSNAME]] |
+** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of |
+** all [VFSes] in the VFS stack. The names are of all VFS shims and the |
+** final bottom-level VFS are written into memory obtained from |
+** [sqlite3_malloc()] and the result is stored in the char* variable |
+** that the fourth parameter of [sqlite3_file_control()] points to. |
+** The caller is responsible for freeing the memory when done. As with |
+** all file-control actions, there is no guarantee that this will actually |
+** do anything. Callers should initialize the char* variable to a NULL |
+** pointer in case this file-control is not implemented. This file-control |
+** is intended for diagnostic use only. |
+** |
+** <li>[[SQLITE_FCNTL_PRAGMA]] |
+** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] |
+** file control is sent to the open [sqlite3_file] object corresponding |
+** to the database file to which the pragma statement refers. ^The argument |
+** to the [SQLITE_FCNTL_PRAGMA] file control is an array of |
+** pointers to strings (char**) in which the second element of the array |
+** is the name of the pragma and the third element is the argument to the |
+** pragma or NULL if the pragma has no argument. ^The handler for an |
+** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element |
+** of the char** argument point to a string obtained from [sqlite3_mprintf()] |
+** or the equivalent and that string will become the result of the pragma or |
+** the error message if the pragma fails. ^If the |
+** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal |
+** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] |
+** file control returns [SQLITE_OK], then the parser assumes that the |
+** VFS has handled the PRAGMA itself and the parser generates a no-op |
+** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns |
+** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means |
+** that the VFS encountered an error while handling the [PRAGMA] and the |
+** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] |
+** file control occurs at the beginning of pragma statement analysis and so |
+** it is able to override built-in [PRAGMA] statements. |
+** |
+** <li>[[SQLITE_FCNTL_BUSYHANDLER]] |
+** ^The [SQLITE_FCNTL_BUSYHANDLER] |
+** file-control may be invoked by SQLite on the database file handle |
+** shortly after it is opened in order to provide a custom VFS with access |
+** to the connections busy-handler callback. The argument is of type (void **) |
+** - an array of two (void *) values. The first (void *) actually points |
+** to a function of type (int (*)(void *)). In order to invoke the connections |
+** busy-handler, this function should be invoked with the second (void *) in |
+** the array as the only argument. If it returns non-zero, then the operation |
+** should be retried. If it returns zero, the custom VFS should abandon the |
+** current operation. |
+** |
+** <li>[[SQLITE_FCNTL_TEMPFILENAME]] |
+** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control |
+** to have SQLite generate a |
+** temporary filename using the same algorithm that is followed to generate |
+** temporary filenames for TEMP tables and other internal uses. The |
+** argument should be a char** which will be filled with the filename |
+** written into memory obtained from [sqlite3_malloc()]. The caller should |
+** invoke [sqlite3_free()] on the result to avoid a memory leak. |
+** |
+** <li>[[SQLITE_FCNTL_MMAP_SIZE]] |
+** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the |
+** maximum number of bytes that will be used for memory-mapped I/O. |
+** The argument is a pointer to a value of type sqlite3_int64 that |
+** is an advisory maximum number of bytes in the file to memory map. The |
+** pointer is overwritten with the old value. The limit is not changed if |
+** the value originally pointed to is negative, and so the current limit |
+** can be queried by passing in a pointer to a negative number. This |
+** file-control is used internally to implement [PRAGMA mmap_size]. |
+** |
+** <li>[[SQLITE_FCNTL_TRACE]] |
+** The [SQLITE_FCNTL_TRACE] file control provides advisory information |
+** to the VFS about what the higher layers of the SQLite stack are doing. |
+** This file control is used by some VFS activity tracing [shims]. |
+** The argument is a zero-terminated string. Higher layers in the |
+** SQLite stack may generate instances of this file control if |
+** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled. |
+** |
+** <li>[[SQLITE_FCNTL_HAS_MOVED]] |
+** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a |
+** pointer to an integer and it writes a boolean into that integer depending |
+** on whether or not the file has been renamed, moved, or deleted since it |
+** was first opened. |
+** |
+** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]] |
+** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This |
+** opcode causes the xFileControl method to swap the file handle with the one |
+** pointed to by the pArg argument. This capability is used during testing |
+** and only needs to be supported when SQLITE_TEST is defined. |
+** |
+** </ul> |
*/ |
-#define SQLITE_FCNTL_LOCKSTATE 1 |
-#define SQLITE_GET_LOCKPROXYFILE 2 |
-#define SQLITE_SET_LOCKPROXYFILE 3 |
-#define SQLITE_LAST_ERRNO 4 |
-#define SQLITE_FCNTL_SIZE_HINT 5 |
-#define SQLITE_FCNTL_CHUNK_SIZE 6 |
-#define SQLITE_FCNTL_FILE_POINTER 7 |
-#define SQLITE_FCNTL_SYNC_OMITTED 8 |
- |
+#define SQLITE_FCNTL_LOCKSTATE 1 |
+#define SQLITE_GET_LOCKPROXYFILE 2 |
+#define SQLITE_SET_LOCKPROXYFILE 3 |
+#define SQLITE_LAST_ERRNO 4 |
+#define SQLITE_FCNTL_SIZE_HINT 5 |
+#define SQLITE_FCNTL_CHUNK_SIZE 6 |
+#define SQLITE_FCNTL_FILE_POINTER 7 |
+#define SQLITE_FCNTL_SYNC_OMITTED 8 |
+#define SQLITE_FCNTL_WIN32_AV_RETRY 9 |
+#define SQLITE_FCNTL_PERSIST_WAL 10 |
+#define SQLITE_FCNTL_OVERWRITE 11 |
+#define SQLITE_FCNTL_VFSNAME 12 |
+#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 |
+#define SQLITE_FCNTL_PRAGMA 14 |
+#define SQLITE_FCNTL_BUSYHANDLER 15 |
+#define SQLITE_FCNTL_TEMPFILENAME 16 |
+#define SQLITE_FCNTL_MMAP_SIZE 18 |
+#define SQLITE_FCNTL_TRACE 19 |
+#define SQLITE_FCNTL_HAS_MOVED 20 |
+#define SQLITE_FCNTL_SYNC 21 |
+#define SQLITE_FCNTL_COMMIT_PHASETWO 22 |
+#define SQLITE_FCNTL_WIN32_SET_HANDLE 23 |
/* |
** CAPI3REF: Mutex Handle |
@@ -762,7 +988,8 @@ typedef struct sqlite3_mutex sqlite3_mutex; |
** |
** An instance of the sqlite3_vfs object defines the interface between |
** the SQLite core and the underlying operating system. The "vfs" |
-** in the name of the object stands for "virtual file system". |
+** in the name of the object stands for "virtual file system". See |
+** the [VFS | VFS documentation] for further information. |
** |
** The value of the iVersion field is initially 1 but may be larger in |
** future versions of SQLite. Additional fields may be appended to this |
@@ -791,12 +1018,13 @@ typedef struct sqlite3_mutex sqlite3_mutex; |
** The zName field holds the name of the VFS module. The name must |
** be unique across all VFS modules. |
** |
+** [[sqlite3_vfs.xOpen]] |
** ^SQLite guarantees that the zFilename parameter to xOpen |
** is either a NULL pointer or string obtained |
** from xFullPathname() with an optional suffix added. |
** ^If a suffix is added to the zFilename parameter, it will |
** consist of a single "-" character followed by no more than |
-** 10 alphanumeric and/or "-" characters. |
+** 11 alphanumeric and/or "-" characters. |
** ^SQLite further guarantees that |
** the string will be valid and unchanged until xClose() is |
** called. Because of the previous sentence, |
@@ -868,6 +1096,7 @@ typedef struct sqlite3_mutex sqlite3_mutex; |
** element will be valid after xOpen returns regardless of the success |
** or failure of the xOpen call. |
** |
+** [[sqlite3_vfs.xAccess]] |
** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] |
** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to |
** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] |
@@ -892,7 +1121,7 @@ typedef struct sqlite3_mutex sqlite3_mutex; |
** method returns a Julian Day Number for the current date and time as |
** a floating point value. |
** ^The xCurrentTimeInt64() method returns, as an integer, the Julian |
-** Day Number multipled by 86400000 (the number of milliseconds in |
+** Day Number multiplied by 86400000 (the number of milliseconds in |
** a 24-hour day). |
** ^SQLite will use the xCurrentTimeInt64() method to get the current |
** date and time if that method is available (if iVersion is 2 or |
@@ -1114,9 +1343,9 @@ SQLITE_API int sqlite3_os_end(void); |
** implementation of an application-defined [sqlite3_os_init()]. |
** |
** The first argument to sqlite3_config() is an integer |
-** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines |
+** [configuration option] that determines |
** what property of SQLite is to be configured. Subsequent arguments |
-** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] |
+** vary depending on the [configuration option] |
** in the first argument. |
** |
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. |
@@ -1168,16 +1397,10 @@ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); |
** order to verify that SQLite recovers gracefully from such |
** conditions. |
** |
-** The xMalloc and xFree methods must work like the |
-** malloc() and free() functions from the standard C library. |
-** The xRealloc method must work like realloc() from the standard C library |
-** with the exception that if the second argument to xRealloc is zero, |
-** xRealloc must be a no-op - it must not perform any allocation or |
-** deallocation. ^SQLite guarantees that the second argument to |
+** The xMalloc, xRealloc, and xFree methods must work like the |
+** malloc(), realloc() and free() functions from the standard C library. |
+** ^SQLite guarantees that the second argument to |
** xRealloc is always a value returned by a prior call to xRoundup. |
-** And so in cases where xRoundup always returns a positive number, |
-** xRealloc can perform exactly as the standard library realloc() and |
-** still be in compliance with this specification. |
** |
** xSize should return the allocated size of a memory allocation |
** previously obtained from xMalloc or xRealloc. The allocated size |
@@ -1191,7 +1414,7 @@ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); |
** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, |
** that causes the corresponding memory allocation to fail. |
** |
-** The xInit method initializes the memory allocator. (For example, |
+** The xInit method initializes the memory allocator. For example, |
** it might allocate any require mutexes or initialize internal data |
** structures. The xShutdown method is invoked (indirectly) by |
** [sqlite3_shutdown()] and should deallocate any resources acquired |
@@ -1226,6 +1449,7 @@ struct sqlite3_mem_methods { |
/* |
** CAPI3REF: Configuration Options |
+** KEYWORDS: {configuration option} |
** |
** These constants are the available integer configuration options that |
** can be passed as the first argument to the [sqlite3_config()] interface. |
@@ -1238,7 +1462,7 @@ struct sqlite3_mem_methods { |
** is invoked. |
** |
** <dl> |
-** <dt>SQLITE_CONFIG_SINGLETHREAD</dt> |
+** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt> |
** <dd>There are no arguments to this option. ^This option sets the |
** [threading mode] to Single-thread. In other words, it disables |
** all mutexing and puts SQLite into a mode where it can only be used |
@@ -1249,7 +1473,7 @@ struct sqlite3_mem_methods { |
** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD |
** configuration option.</dd> |
** |
-** <dt>SQLITE_CONFIG_MULTITHREAD</dt> |
+** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt> |
** <dd>There are no arguments to this option. ^This option sets the |
** [threading mode] to Multi-thread. In other words, it disables |
** mutexing on [database connection] and [prepared statement] objects. |
@@ -1263,7 +1487,7 @@ struct sqlite3_mem_methods { |
** [sqlite3_config()] will return [SQLITE_ERROR] if called with the |
** SQLITE_CONFIG_MULTITHREAD configuration option.</dd> |
** |
-** <dt>SQLITE_CONFIG_SERIALIZED</dt> |
+** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt> |
** <dd>There are no arguments to this option. ^This option sets the |
** [threading mode] to Serialized. In other words, this option enables |
** all mutexes including the recursive |
@@ -1279,7 +1503,7 @@ struct sqlite3_mem_methods { |
** [sqlite3_config()] will return [SQLITE_ERROR] if called with the |
** SQLITE_CONFIG_SERIALIZED configuration option.</dd> |
** |
-** <dt>SQLITE_CONFIG_MALLOC</dt> |
+** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt> |
** <dd> ^(This option takes a single argument which is a pointer to an |
** instance of the [sqlite3_mem_methods] structure. The argument specifies |
** alternative low-level memory allocation routines to be used in place of |
@@ -1287,7 +1511,7 @@ struct sqlite3_mem_methods { |
** its own private copy of the content of the [sqlite3_mem_methods] structure |
** before the [sqlite3_config()] call returns.</dd> |
** |
-** <dt>SQLITE_CONFIG_GETMALLOC</dt> |
+** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt> |
** <dd> ^(This option takes a single argument which is a pointer to an |
** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] |
** structure is filled with the currently defined memory allocation routines.)^ |
@@ -1295,7 +1519,7 @@ struct sqlite3_mem_methods { |
** routines with a wrapper that simulations memory allocation failure or |
** tracks memory usage, for example. </dd> |
** |
-** <dt>SQLITE_CONFIG_MEMSTATUS</dt> |
+** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt> |
** <dd> ^This option takes single argument of type int, interpreted as a |
** boolean, which enables or disables the collection of memory allocation |
** statistics. ^(When memory allocation statistics are disabled, the |
@@ -1311,7 +1535,7 @@ struct sqlite3_mem_methods { |
** allocation statistics are disabled by default. |
** </dd> |
** |
-** <dt>SQLITE_CONFIG_SCRATCH</dt> |
+** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt> |
** <dd> ^This option specifies a static memory buffer that SQLite can use for |
** scratch memory. There are three arguments: A pointer an 8-byte |
** aligned memory buffer from which the scratch allocations will be |
@@ -1327,11 +1551,11 @@ struct sqlite3_mem_methods { |
** scratch memory beyond what is provided by this configuration option, then |
** [sqlite3_malloc()] will be used to obtain the memory needed.</dd> |
** |
-** <dt>SQLITE_CONFIG_PAGECACHE</dt> |
+** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt> |
** <dd> ^This option specifies a static memory buffer that SQLite can use for |
-** the database page cache with the default page cache implemenation. |
+** the database page cache with the default page cache implementation. |
** This configuration should not be used if an application-define page |
-** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
+** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option. |
** There are three arguments to this option: A pointer to 8-byte aligned |
** memory, the size of each page buffer (sz), and the number of pages (N). |
** The sz argument should be the size of the largest database page |
@@ -1348,7 +1572,7 @@ struct sqlite3_mem_methods { |
** be aligned to an 8-byte boundary or subsequent behavior of SQLite |
** will be undefined.</dd> |
** |
-** <dt>SQLITE_CONFIG_HEAP</dt> |
+** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt> |
** <dd> ^This option specifies a static memory buffer that SQLite will use |
** for all of its dynamic memory allocation needs beyond those provided |
** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. |
@@ -1362,10 +1586,10 @@ struct sqlite3_mem_methods { |
** allocator is engaged to handle all of SQLites memory allocation needs. |
** The first pointer (the memory pointer) must be aligned to an 8-byte |
** boundary or subsequent behavior of SQLite will be undefined. |
-** The minimum allocation size is capped at 2^12. Reasonable values |
-** for the minimum allocation size are 2^5 through 2^8.</dd> |
+** The minimum allocation size is capped at 2**12. Reasonable values |
+** for the minimum allocation size are 2**5 through 2**8.</dd> |
** |
-** <dt>SQLITE_CONFIG_MUTEX</dt> |
+** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt> |
** <dd> ^(This option takes a single argument which is a pointer to an |
** instance of the [sqlite3_mutex_methods] structure. The argument specifies |
** alternative low-level mutex routines to be used in place |
@@ -1377,7 +1601,7 @@ struct sqlite3_mem_methods { |
** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will |
** return [SQLITE_ERROR].</dd> |
** |
-** <dt>SQLITE_CONFIG_GETMUTEX</dt> |
+** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt> |
** <dd> ^(This option takes a single argument which is a pointer to an |
** instance of the [sqlite3_mutex_methods] structure. The |
** [sqlite3_mutex_methods] |
@@ -1390,7 +1614,7 @@ struct sqlite3_mem_methods { |
** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will |
** return [SQLITE_ERROR].</dd> |
** |
-** <dt>SQLITE_CONFIG_LOOKASIDE</dt> |
+** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt> |
** <dd> ^(This option takes two arguments that determine the default |
** memory allocation for the lookaside memory allocator on each |
** [database connection]. The first argument is the |
@@ -1400,19 +1624,21 @@ struct sqlite3_mem_methods { |
** verb to [sqlite3_db_config()] can be used to change the lookaside |
** configuration on individual connections.)^ </dd> |
** |
-** <dt>SQLITE_CONFIG_PCACHE</dt> |
+** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt> |
** <dd> ^(This option takes a single argument which is a pointer to |
-** an [sqlite3_pcache_methods] object. This object specifies the interface |
+** an [sqlite3_pcache_methods2] object. This object specifies the interface |
** to a custom page cache implementation.)^ ^SQLite makes a copy of the |
** object and uses it for page cache memory allocations.</dd> |
** |
-** <dt>SQLITE_CONFIG_GETPCACHE</dt> |
+** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt> |
** <dd> ^(This option takes a single argument which is a pointer to an |
-** [sqlite3_pcache_methods] object. SQLite copies of the current |
+** [sqlite3_pcache_methods2] object. SQLite copies of the current |
** page cache implementation into that object.)^ </dd> |
** |
-** <dt>SQLITE_CONFIG_LOG</dt> |
-** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a |
+** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt> |
+** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite |
+** global [error log]. |
+** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a |
** function with a call signature of void(*)(void*,int,const char*), |
** and a pointer to void. ^If the function pointer is not NULL, it is |
** invoked by [sqlite3_log()] to process each logging event. ^If the |
@@ -1429,6 +1655,74 @@ struct sqlite3_mem_methods { |
** In a multi-threaded application, the application-defined logger |
** function must be threadsafe. </dd> |
** |
+** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI |
+** <dd>^(This option takes a single argument of type int. If non-zero, then |
+** URI handling is globally enabled. If the parameter is zero, then URI handling |
+** is globally disabled.)^ ^If URI handling is globally enabled, all filenames |
+** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or |
+** specified as part of [ATTACH] commands are interpreted as URIs, regardless |
+** of whether or not the [SQLITE_OPEN_URI] flag is set when the database |
+** connection is opened. ^If it is globally disabled, filenames are |
+** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the |
+** database connection is opened. ^(By default, URI handling is globally |
+** disabled. The default value may be changed by compiling with the |
+** [SQLITE_USE_URI] symbol defined.)^ |
+** |
+** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN |
+** <dd>^This option takes a single integer argument which is interpreted as |
+** a boolean in order to enable or disable the use of covering indices for |
+** full table scans in the query optimizer. ^The default setting is determined |
+** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" |
+** if that compile-time option is omitted. |
+** The ability to disable the use of covering indices for full table scans |
+** is because some incorrectly coded legacy applications might malfunction |
+** when the optimization is enabled. Providing the ability to |
+** disable the optimization allows the older, buggy application code to work |
+** without change even with newer versions of SQLite. |
+** |
+** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]] |
+** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE |
+** <dd> These options are obsolete and should not be used by new code. |
+** They are retained for backwards compatibility but are now no-ops. |
+** </dd> |
+** |
+** [[SQLITE_CONFIG_SQLLOG]] |
+** <dt>SQLITE_CONFIG_SQLLOG |
+** <dd>This option is only available if sqlite is compiled with the |
+** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should |
+** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int). |
+** The second should be of type (void*). The callback is invoked by the library |
+** in three separate circumstances, identified by the value passed as the |
+** fourth parameter. If the fourth parameter is 0, then the database connection |
+** passed as the second argument has just been opened. The third argument |
+** points to a buffer containing the name of the main database file. If the |
+** fourth parameter is 1, then the SQL statement that the third parameter |
+** points to has just been executed. Or, if the fourth parameter is 2, then |
+** the connection being passed as the second parameter is being closed. The |
+** third parameter is passed NULL In this case. An example of using this |
+** configuration option can be seen in the "test_sqllog.c" source file in |
+** the canonical SQLite source tree.</dd> |
+** |
+** [[SQLITE_CONFIG_MMAP_SIZE]] |
+** <dt>SQLITE_CONFIG_MMAP_SIZE |
+** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values |
+** that are the default mmap size limit (the default setting for |
+** [PRAGMA mmap_size]) and the maximum allowed mmap size limit. |
+** ^The default setting can be overridden by each database connection using |
+** either the [PRAGMA mmap_size] command, or by using the |
+** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size |
+** cannot be changed at run-time. Nor may the maximum allowed mmap size |
+** exceed the compile-time maximum mmap size set by the |
+** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^ |
+** ^If either argument to this option is negative, then that argument is |
+** changed to its compile-time default. |
+** |
+** [[SQLITE_CONFIG_WIN32_HEAPSIZE]] |
+** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE |
+** <dd>^This option is only available if SQLite is compiled for Windows |
+** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined. |
+** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value |
+** that specifies the maximum size of the created heap. |
** </dl> |
*/ |
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ |
@@ -1444,9 +1738,16 @@ struct sqlite3_mem_methods { |
#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ |
/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ |
#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ |
-#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ |
-#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ |
+#define SQLITE_CONFIG_PCACHE 14 /* no-op */ |
+#define SQLITE_CONFIG_GETPCACHE 15 /* no-op */ |
#define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ |
+#define SQLITE_CONFIG_URI 17 /* int */ |
+#define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ |
+#define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ |
+#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ |
+#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ |
+#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ |
+#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ |
/* |
** CAPI3REF: Database Connection Configuration Options |
@@ -1523,22 +1824,28 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); |
/* |
** CAPI3REF: Last Insert Rowid |
** |
-** ^Each entry in an SQLite table has a unique 64-bit signed |
+** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) |
+** has a unique 64-bit signed |
** integer key called the [ROWID | "rowid"]. ^The rowid is always available |
** as an undeclared column named ROWID, OID, or _ROWID_ as long as those |
** names are not also used by explicitly declared columns. ^If |
** the table has a column of type [INTEGER PRIMARY KEY] then that column |
** is another alias for the rowid. |
** |
-** ^This routine returns the [rowid] of the most recent |
-** successful [INSERT] into the database from the [database connection] |
-** in the first argument. ^If no successful [INSERT]s |
-** have ever occurred on that database connection, zero is returned. |
-** |
-** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted |
-** row is returned by this routine as long as the trigger is running. |
-** But once the trigger terminates, the value returned by this routine |
-** reverts to the last value inserted before the trigger fired.)^ |
+** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the |
+** most recent successful [INSERT] into a rowid table or [virtual table] |
+** on database connection D. |
+** ^Inserts into [WITHOUT ROWID] tables are not recorded. |
+** ^If no successful [INSERT]s into rowid tables |
+** have ever occurred on the database connection D, |
+** then sqlite3_last_insert_rowid(D) returns zero. |
+** |
+** ^(If an [INSERT] occurs within a trigger or within a [virtual table] |
+** method, then this routine will return the [rowid] of the inserted |
+** row as long as the trigger or virtual table method is running. |
+** But once the trigger or virtual table method ends, the value returned |
+** by this routine reverts to what it was before the trigger or virtual |
+** table method began.)^ |
** |
** ^An [INSERT] that fails due to a constraint violation is not a |
** successful [INSERT] and does not change the value returned by this |
@@ -1723,27 +2030,33 @@ SQLITE_API int sqlite3_complete16(const void *sql); |
/* |
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors |
** |
-** ^This routine sets a callback function that might be invoked whenever |
-** an attempt is made to open a database table that another thread |
-** or process has locked. |
+** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X |
+** that might be invoked with argument P whenever |
+** an attempt is made to access a database table associated with |
+** [database connection] D when another thread |
+** or process has the table locked. |
+** The sqlite3_busy_handler() interface is used to implement |
+** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. |
** |
-** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] |
+** ^If the busy callback is NULL, then [SQLITE_BUSY] |
** is returned immediately upon encountering the lock. ^If the busy callback |
** is not NULL, then the callback might be invoked with two arguments. |
** |
** ^The first argument to the busy handler is a copy of the void* pointer which |
** is the third argument to sqlite3_busy_handler(). ^The second argument to |
** the busy handler callback is the number of times that the busy handler has |
-** been invoked for this locking event. ^If the |
+** been invoked for the same locking event. ^If the |
** busy callback returns 0, then no additional attempts are made to |
-** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. |
+** access the database and [SQLITE_BUSY] is returned |
+** to the application. |
** ^If the callback returns non-zero, then another attempt |
-** is made to open the database for reading and the cycle repeats. |
+** is made to access the database and the cycle repeats. |
** |
** The presence of a busy handler does not guarantee that it will be invoked |
** when there is lock contention. ^If SQLite determines that invoking the busy |
** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] |
-** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. |
+** to the application instead of invoking the |
+** busy handler. |
** Consider a scenario where one process is holding a read lock that |
** it is trying to promote to a reserved lock and |
** a second process is holding a reserved lock that it is trying |
@@ -1757,28 +2070,15 @@ SQLITE_API int sqlite3_complete16(const void *sql); |
** |
** ^The default busy callback is NULL. |
** |
-** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] |
-** when SQLite is in the middle of a large transaction where all the |
-** changes will not fit into the in-memory cache. SQLite will |
-** already hold a RESERVED lock on the database file, but it needs |
-** to promote this lock to EXCLUSIVE so that it can spill cache |
-** pages into the database file without harm to concurrent |
-** readers. ^If it is unable to promote the lock, then the in-memory |
-** cache will be left in an inconsistent state and so the error |
-** code is promoted from the relatively benign [SQLITE_BUSY] to |
-** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion |
-** forces an automatic rollback of the changes. See the |
-** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError"> |
-** CorruptionFollowingBusyError</a> wiki page for a discussion of why |
-** this is important. |
-** |
** ^(There can only be a single busy handler defined for each |
** [database connection]. Setting a new busy handler clears any |
** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] |
-** will also set or clear the busy handler. |
+** or evaluating [PRAGMA busy_timeout=N] will change the |
+** busy handler and thus clear any previously set busy handler. |
** |
** The busy callback should not take any actions which modify the |
-** database connection that invoked the busy handler. Any such actions |
+** database connection that invoked the busy handler. In other words, |
+** the busy handler is not reentrant. Any such actions |
** result in undefined behavior. |
** |
** A busy handler must not close the database connection |
@@ -1794,15 +2094,17 @@ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); |
** will sleep multiple times until at least "ms" milliseconds of sleeping |
** have accumulated. ^After at least "ms" milliseconds of sleeping, |
** the handler returns 0 which causes [sqlite3_step()] to return |
-** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. |
+** [SQLITE_BUSY]. |
** |
** ^Calling this routine with an argument less than or equal to zero |
** turns off all busy handlers. |
** |
** ^(There can only be a single busy handler for a particular |
-** [database connection] any any given moment. If another busy handler |
+** [database connection] at any given moment. If another busy handler |
** was defined (using [sqlite3_busy_handler()]) prior to calling |
** this routine, that other busy handler is cleared.)^ |
+** |
+** See also: [PRAGMA busy_timeout] |
*/ |
SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); |
@@ -1927,7 +2229,7 @@ SQLITE_API void sqlite3_free_table(char **result); |
** All of the usual printf() formatting options apply. In addition, there |
** is are "%q", "%Q", and "%z" options. |
** |
-** ^(The %q option works like %s in that it substitutes a null-terminated |
+** ^(The %q option works like %s in that it substitutes a nul-terminated |
** string from the argument list. But %q also doubles every '\'' character. |
** %q is designed for use inside a string literal.)^ By doubling each '\'' |
** character it escapes that character and allows it to be inserted into |
@@ -2002,6 +2304,10 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); |
** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns |
** a NULL pointer. |
** |
+** ^The sqlite3_malloc64(N) routine works just like |
+** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead |
+** of a signed 32-bit integer. |
+** |
** ^Calling sqlite3_free() with a pointer previously returned |
** by sqlite3_malloc() or sqlite3_realloc() releases that memory so |
** that it might be reused. ^The sqlite3_free() routine is |
@@ -2013,24 +2319,38 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); |
** might result if sqlite3_free() is called with a non-NULL pointer that |
** was not obtained from sqlite3_malloc() or sqlite3_realloc(). |
** |
-** ^(The sqlite3_realloc() interface attempts to resize a |
-** prior memory allocation to be at least N bytes, where N is the |
-** second parameter. The memory allocation to be resized is the first |
-** parameter.)^ ^ If the first parameter to sqlite3_realloc() |
+** ^The sqlite3_realloc(X,N) interface attempts to resize a |
+** prior memory allocation X to be at least N bytes. |
+** ^If the X parameter to sqlite3_realloc(X,N) |
** is a NULL pointer then its behavior is identical to calling |
-** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). |
-** ^If the second parameter to sqlite3_realloc() is zero or |
+** sqlite3_malloc(N). |
+** ^If the N parameter to sqlite3_realloc(X,N) is zero or |
** negative then the behavior is exactly the same as calling |
-** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). |
-** ^sqlite3_realloc() returns a pointer to a memory allocation |
-** of at least N bytes in size or NULL if sufficient memory is unavailable. |
+** sqlite3_free(X). |
+** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation |
+** of at least N bytes in size or NULL if insufficient memory is available. |
** ^If M is the size of the prior allocation, then min(N,M) bytes |
** of the prior allocation are copied into the beginning of buffer returned |
-** by sqlite3_realloc() and the prior allocation is freed. |
-** ^If sqlite3_realloc() returns NULL, then the prior allocation |
-** is not freed. |
-** |
-** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() |
+** by sqlite3_realloc(X,N) and the prior allocation is freed. |
+** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the |
+** prior allocation is not freed. |
+** |
+** ^The sqlite3_realloc64(X,N) interfaces works the same as |
+** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead |
+** of a 32-bit signed integer. |
+** |
+** ^If X is a memory allocation previously obtained from sqlite3_malloc(), |
+** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then |
+** sqlite3_msize(X) returns the size of that memory allocation in bytes. |
+** ^The value returned by sqlite3_msize(X) might be larger than the number |
+** of bytes requested when X was allocated. ^If X is a NULL pointer then |
+** sqlite3_msize(X) returns zero. If X points to something that is not |
+** the beginning of memory allocation, or if it points to a formerly |
+** valid memory allocation that has now been freed, then the behavior |
+** of sqlite3_msize(X) is undefined and possibly harmful. |
+** |
+** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(), |
+** sqlite3_malloc64(), and sqlite3_realloc64() |
** is always aligned to at least an 8 byte boundary, or to a |
** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time |
** option is used. |
@@ -2040,12 +2360,12 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); |
** implementation of these routines to be omitted. That capability |
** is no longer provided. Only built-in memory allocators can be used. |
** |
-** The Windows OS interface layer calls |
+** Prior to SQLite version 3.7.10, the Windows OS interface layer called |
** the system malloc() and free() directly when converting |
** filenames between the UTF-8 encoding used by SQLite |
** and whatever filename encoding is used by the particular Windows |
-** installation. Memory allocation errors are detected, but |
-** they are reported back as [SQLITE_CANTOPEN] or |
+** installation. Memory allocation errors were detected, but |
+** they were reported back as [SQLITE_CANTOPEN] or |
** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. |
** |
** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] |
@@ -2058,8 +2378,11 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list); |
** [sqlite3_free()] or [sqlite3_realloc()]. |
*/ |
SQLITE_API void *sqlite3_malloc(int); |
+SQLITE_API void *sqlite3_malloc64(sqlite3_uint64); |
SQLITE_API void *sqlite3_realloc(void*, int); |
+SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64); |
SQLITE_API void sqlite3_free(void*); |
+SQLITE_API sqlite3_uint64 sqlite3_msize(void*); |
/* |
** CAPI3REF: Memory Allocator Statistics |
@@ -2097,11 +2420,13 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); |
** applications to access the same PRNG for other purposes. |
** |
** ^A call to this routine stores N bytes of randomness into buffer P. |
+** ^If N is less than one, then P can be a NULL pointer. |
** |
-** ^The first time this routine is invoked (either internally or by |
-** the application) the PRNG is seeded using randomness obtained |
-** from the xRandomness method of the default [sqlite3_vfs] object. |
-** ^On all subsequent invocations, the pseudo-randomness is generated |
+** ^If this routine has not been previously called or if the previous |
+** call had N less than one, then the PRNG is seeded using randomness |
+** obtained from the xRandomness method of the default [sqlite3_vfs] object. |
+** ^If the previous call to this routine had an N of 1 or more then |
+** the pseudo-randomness is generated |
** internally and without recourse to the [sqlite3_vfs] xRandomness |
** method. |
*/ |
@@ -2201,6 +2526,9 @@ SQLITE_API int sqlite3_set_authorizer( |
** to signal SQLite whether or not the action is permitted. See the |
** [sqlite3_set_authorizer | authorizer documentation] for additional |
** information. |
+** |
+** Note that SQLITE_IGNORE is also used as a [conflict resolution mode] |
+** returned from the [sqlite3_vtab_on_conflict()] interface. |
*/ |
#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ |
#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ |
@@ -2258,6 +2586,7 @@ SQLITE_API int sqlite3_set_authorizer( |
#define SQLITE_FUNCTION 31 /* NULL Function Name */ |
#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ |
#define SQLITE_COPY 0 /* No longer used */ |
+#define SQLITE_RECURSIVE 33 /* NULL NULL */ |
/* |
** CAPI3REF: Tracing And Profiling Functions |
@@ -2273,6 +2602,9 @@ SQLITE_API int sqlite3_set_authorizer( |
** as each triggered subprogram is entered. The callbacks for triggers |
** contain a UTF-8 SQL comment that identifies the trigger.)^ |
** |
+** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit |
+** the length of [bound parameter] expansion in the output of sqlite3_trace(). |
+** |
** ^The callback function registered by sqlite3_profile() is invoked |
** as each SQL statement finishes. ^The profile callback contains |
** the original statement text and an estimate of wall-clock time |
@@ -2298,9 +2630,10 @@ SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, |
** interface is to keep a GUI updated during a large query. |
** |
** ^The parameter P is passed through as the only parameter to the |
-** callback function X. ^The parameter N is the number of |
+** callback function X. ^The parameter N is the approximate number of |
** [virtual machine instructions] that are evaluated between successive |
-** invocations of the callback X. |
+** invocations of the callback X. ^If N is less than one then the progress |
+** handler is disabled. |
** |
** ^Only a single progress handler may be defined at one time per |
** [database connection]; setting a new progress handler cancels the |
@@ -2323,7 +2656,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
/* |
** CAPI3REF: Opening A New Database Connection |
** |
-** ^These routines open an SQLite database file whose name is given by the |
+** ^These routines open an SQLite database file as specified by the |
** filename argument. ^The filename argument is interpreted as UTF-8 for |
** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte |
** order for sqlite3_open16(). ^(A [database connection] handle is usually |
@@ -2336,9 +2669,9 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
** an English language description of the error following a failure of any |
** of the sqlite3_open() routines. |
** |
-** ^The default encoding for the database will be UTF-8 if |
-** sqlite3_open() or sqlite3_open_v2() is called and |
-** UTF-16 in the native byte order if sqlite3_open16() is used. |
+** ^The default encoding will be UTF-8 for databases created using |
+** sqlite3_open() or sqlite3_open_v2(). ^The default encoding for databases |
+** created using sqlite3_open16() will be UTF-16 in the native byte order. |
** |
** Whether or not an error occurs when it is opened, resources |
** associated with the [database connection] handle should be released by |
@@ -2350,7 +2683,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
** sqlite3_open_v2() can take one of |
** the following three values, optionally combined with the |
** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], |
-** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^ |
+** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ |
** |
** <dl> |
** ^(<dt>[SQLITE_OPEN_READONLY]</dt> |
@@ -2369,9 +2702,8 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
** </dl> |
** |
** If the 3rd parameter to sqlite3_open_v2() is not one of the |
-** combinations shown above or one of the combinations shown above combined |
-** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], |
-** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_PRIVATECACHE] flags, |
+** combinations shown above optionally combined with other |
+** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] |
** then the behavior is undefined. |
** |
** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection |
@@ -2386,6 +2718,11 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not |
** participate in [shared cache mode] even if it is enabled. |
** |
+** ^The fourth parameter to sqlite3_open_v2() is the name of the |
+** [sqlite3_vfs] object that defines the operating system interface that |
+** the new database connection should use. ^If the fourth parameter is |
+** a NULL pointer then the default [sqlite3_vfs] object is used. |
+** |
** ^If the filename is ":memory:", then a private, temporary in-memory database |
** is created for the connection. ^This in-memory database will vanish when |
** the database connection is closed. Future versions of SQLite might |
@@ -2398,16 +2735,149 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
** on-disk database will be created. ^This private database will be |
** automatically deleted as soon as the database connection is closed. |
** |
-** ^The fourth parameter to sqlite3_open_v2() is the name of the |
-** [sqlite3_vfs] object that defines the operating system interface that |
-** the new database connection should use. ^If the fourth parameter is |
-** a NULL pointer then the default [sqlite3_vfs] object is used. |
+** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3> |
+** |
+** ^If [URI filename] interpretation is enabled, and the filename argument |
+** begins with "file:", then the filename is interpreted as a URI. ^URI |
+** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is |
+** set in the fourth argument to sqlite3_open_v2(), or if it has |
+** been enabled globally using the [SQLITE_CONFIG_URI] option with the |
+** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. |
+** As of SQLite version 3.7.7, URI filename interpretation is turned off |
+** by default, but future releases of SQLite might enable URI filename |
+** interpretation by default. See "[URI filenames]" for additional |
+** information. |
+** |
+** URI filenames are parsed according to RFC 3986. ^If the URI contains an |
+** authority, then it must be either an empty string or the string |
+** "localhost". ^If the authority is not an empty string or "localhost", an |
+** error is returned to the caller. ^The fragment component of a URI, if |
+** present, is ignored. |
+** |
+** ^SQLite uses the path component of the URI as the name of the disk file |
+** which contains the database. ^If the path begins with a '/' character, |
+** then it is interpreted as an absolute path. ^If the path does not begin |
+** with a '/' (meaning that the authority section is omitted from the URI) |
+** then the path is interpreted as a relative path. |
+** ^(On windows, the first component of an absolute path |
+** is a drive specification (e.g. "C:").)^ |
+** |
+** [[core URI query parameters]] |
+** The query component of a URI may contain parameters that are interpreted |
+** either by SQLite itself, or by a [VFS | custom VFS implementation]. |
+** SQLite and its built-in [VFSes] interpret the |
+** following query parameters: |
+** |
+** <ul> |
+** <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of |
+** a VFS object that provides the operating system interface that should |
+** be used to access the database file on disk. ^If this option is set to |
+** an empty string the default VFS object is used. ^Specifying an unknown |
+** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is |
+** present, then the VFS specified by the option takes precedence over |
+** the value passed as the fourth parameter to sqlite3_open_v2(). |
+** |
+** <li> <b>mode</b>: ^(The mode parameter may be set to either "ro", "rw", |
+** "rwc", or "memory". Attempting to set it to any other value is |
+** an error)^. |
+** ^If "ro" is specified, then the database is opened for read-only |
+** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the |
+** third argument to sqlite3_open_v2(). ^If the mode option is set to |
+** "rw", then the database is opened for read-write (but not create) |
+** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had |
+** been set. ^Value "rwc" is equivalent to setting both |
+** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is |
+** set to "memory" then a pure [in-memory database] that never reads |
+** or writes from disk is used. ^It is an error to specify a value for |
+** the mode parameter that is less restrictive than that specified by |
+** the flags passed in the third parameter to sqlite3_open_v2(). |
+** |
+** <li> <b>cache</b>: ^The cache parameter may be set to either "shared" or |
+** "private". ^Setting it to "shared" is equivalent to setting the |
+** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to |
+** sqlite3_open_v2(). ^Setting the cache parameter to "private" is |
+** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. |
+** ^If sqlite3_open_v2() is used and the "cache" parameter is present in |
+** a URI filename, its value overrides any behavior requested by setting |
+** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. |
+** |
+** <li> <b>psow</b>: ^The psow parameter indicates whether or not the |
+** [powersafe overwrite] property does or does not apply to the |
+** storage media on which the database file resides. |
+** |
+** <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter |
+** which if set disables file locking in rollback journal modes. This |
+** is useful for accessing a database on a filesystem that does not |
+** support locking. Caution: Database corruption might result if two |
+** or more processes write to the same database and any one of those |
+** processes uses nolock=1. |
+** |
+** <li> <b>immutable</b>: ^The immutable parameter is a boolean query |
+** parameter that indicates that the database file is stored on |
+** read-only media. ^When immutable is set, SQLite assumes that the |
+** database file cannot be changed, even by a process with higher |
+** privilege, and so the database is opened read-only and all locking |
+** and change detection is disabled. Caution: Setting the immutable |
+** property on a database file that does in fact change can result |
+** in incorrect query results and/or [SQLITE_CORRUPT] errors. |
+** See also: [SQLITE_IOCAP_IMMUTABLE]. |
+** |
+** </ul> |
+** |
+** ^Specifying an unknown parameter in the query component of a URI is not an |
+** error. Future versions of SQLite might understand additional query |
+** parameters. See "[query parameters with special meaning to SQLite]" for |
+** additional information. |
+** |
+** [[URI filename examples]] <h3>URI filename examples</h3> |
+** |
+** <table border="1" align=center cellpadding=5> |
+** <tr><th> URI filenames <th> Results |
+** <tr><td> file:data.db <td> |
+** Open the file "data.db" in the current directory. |
+** <tr><td> file:/home/fred/data.db<br> |
+** file:///home/fred/data.db <br> |
+** file://localhost/home/fred/data.db <br> <td> |
+** Open the database file "/home/fred/data.db". |
+** <tr><td> file://darkstar/home/fred/data.db <td> |
+** An error. "darkstar" is not a recognized authority. |
+** <tr><td style="white-space:nowrap"> |
+** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db |
+** <td> Windows only: Open the file "data.db" on fred's desktop on drive |
+** C:. Note that the %20 escaping in this example is not strictly |
+** necessary - space characters can be used literally |
+** in URI filenames. |
+** <tr><td> file:data.db?mode=ro&cache=private <td> |
+** Open file "data.db" in the current directory for read-only access. |
+** Regardless of whether or not shared-cache mode is enabled by |
+** default, use a private cache. |
+** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td> |
+** Open file "/home/fred/data.db". Use the special VFS "unix-dotfile" |
+** that uses dot-files in place of posix advisory locking. |
+** <tr><td> file:data.db?mode=readonly <td> |
+** An error. "readonly" is not a valid option for the "mode" parameter. |
+** </table> |
+** |
+** ^URI hexadecimal escape sequences (%HH) are supported within the path and |
+** query components of a URI. A hexadecimal escape sequence consists of a |
+** percent sign - "%" - followed by exactly two hexadecimal digits |
+** specifying an octet value. ^Before the path or query components of a |
+** URI filename are interpreted, they are encoded using UTF-8 and all |
+** hexadecimal escape sequences replaced by a single byte containing the |
+** corresponding octet. If this process generates an invalid UTF-8 encoding, |
+** the results are undefined. |
** |
** <b>Note to Windows users:</b> The encoding used for the filename argument |
** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever |
** codepage is currently defined. Filenames containing international |
** characters must be converted to UTF-8 prior to passing them into |
** sqlite3_open() or sqlite3_open_v2(). |
+** |
+** <b>Note to Windows Runtime users:</b> The temporary directory must be set |
+** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various |
+** features that require the use of temporary files may fail. |
+** |
+** See also: [sqlite3_temp_directory] |
*/ |
SQLITE_API int sqlite3_open( |
const char *filename, /* Database filename (UTF-8) */ |
@@ -2425,6 +2895,50 @@ SQLITE_API int sqlite3_open_v2( |
); |
/* |
+** CAPI3REF: Obtain Values For URI Parameters |
+** |
+** These are utility routines, useful to VFS implementations, that check |
+** to see if a database file was a URI that contained a specific query |
+** parameter, and if so obtains the value of that query parameter. |
+** |
+** If F is the database filename pointer passed into the xOpen() method of |
+** a VFS implementation when the flags parameter to xOpen() has one or |
+** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and |
+** P is the name of the query parameter, then |
+** sqlite3_uri_parameter(F,P) returns the value of the P |
+** parameter if it exists or a NULL pointer if P does not appear as a |
+** query parameter on F. If P is a query parameter of F |
+** has no explicit value, then sqlite3_uri_parameter(F,P) returns |
+** a pointer to an empty string. |
+** |
+** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean |
+** parameter and returns true (1) or false (0) according to the value |
+** of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the |
+** value of query parameter P is one of "yes", "true", or "on" in any |
+** case or if the value begins with a non-zero number. The |
+** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of |
+** query parameter P is one of "no", "false", or "off" in any case or |
+** if the value begins with a numeric zero. If P is not a query |
+** parameter on F or if the value of P is does not match any of the |
+** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). |
+** |
+** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a |
+** 64-bit signed integer and returns that integer, or D if P does not |
+** exist. If the value of P is something other than an integer, then |
+** zero is returned. |
+** |
+** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and |
+** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and |
+** is not a database file pathname pointer that SQLite passed into the xOpen |
+** VFS method, then the behavior of this routine is undefined and probably |
+** undesirable. |
+*/ |
+SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); |
+SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); |
+SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); |
+ |
+ |
+/* |
** CAPI3REF: Error Codes And Messages |
** |
** ^The sqlite3_errcode() interface returns the numeric [result code] or |
@@ -2443,6 +2957,11 @@ SQLITE_API int sqlite3_open_v2( |
** However, the error string might be overwritten or deallocated by |
** subsequent calls to other SQLite interface functions.)^ |
** |
+** ^The sqlite3_errstr() interface returns the English-language text |
+** that describes the [result code], as UTF-8. |
+** ^(Memory to hold the error message string is managed internally |
+** and must not be freed by the application)^. |
+** |
** When the serialized [threading mode] is in use, it might be the |
** case that a second error occurs on a separate thread in between |
** the time of the first error and the call to these interfaces. |
@@ -2461,6 +2980,7 @@ SQLITE_API int sqlite3_errcode(sqlite3 *db); |
SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); |
SQLITE_API const char *sqlite3_errmsg(sqlite3*); |
SQLITE_API const void *sqlite3_errmsg16(sqlite3*); |
+SQLITE_API const char *sqlite3_errstr(int); |
/* |
** CAPI3REF: SQL Statement Object |
@@ -2539,44 +3059,50 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
** Additional information is available at [limits | Limits in SQLite]. |
** |
** <dl> |
-** ^(<dt>SQLITE_LIMIT_LENGTH</dt> |
+** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt> |
** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^ |
** |
-** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt> |
+** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt> |
** <dd>The maximum length of an SQL statement, in bytes.</dd>)^ |
** |
-** ^(<dt>SQLITE_LIMIT_COLUMN</dt> |
+** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt> |
** <dd>The maximum number of columns in a table definition or in the |
** result set of a [SELECT] or the maximum number of columns in an index |
** or in an ORDER BY or GROUP BY clause.</dd>)^ |
** |
-** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt> |
+** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt> |
** <dd>The maximum depth of the parse tree on any expression.</dd>)^ |
** |
-** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt> |
+** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt> |
** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^ |
** |
-** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt> |
+** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt> |
** <dd>The maximum number of instructions in a virtual machine program |
** used to implement an SQL statement. This limit is not currently |
** enforced, though that might be added in some future release of |
** SQLite.</dd>)^ |
** |
-** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt> |
+** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt> |
** <dd>The maximum number of arguments on a function.</dd>)^ |
** |
-** ^(<dt>SQLITE_LIMIT_ATTACHED</dt> |
+** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt> |
** <dd>The maximum number of [ATTACH | attached databases].)^</dd> |
** |
+** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] |
** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt> |
** <dd>The maximum length of the pattern argument to the [LIKE] or |
** [GLOB] operators.</dd>)^ |
** |
+** [[SQLITE_LIMIT_VARIABLE_NUMBER]] |
** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt> |
** <dd>The maximum index number of any [parameter] in an SQL statement.)^ |
** |
-** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt> |
+** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt> |
** <dd>The maximum depth of recursion for triggers.</dd>)^ |
+** |
+** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt> |
+** <dd>The maximum number of auxiliary worker threads that a single |
+** [prepared statement] may start.</dd>)^ |
** </dl> |
*/ |
#define SQLITE_LIMIT_LENGTH 0 |
@@ -2590,6 +3116,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 |
#define SQLITE_LIMIT_VARIABLE_NUMBER 9 |
#define SQLITE_LIMIT_TRIGGER_DEPTH 10 |
+#define SQLITE_LIMIT_WORKER_THREADS 11 |
/* |
** CAPI3REF: Compiling An SQL Statement |
@@ -2615,7 +3142,8 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
** that the supplied string is nul-terminated, then there is a small |
** performance advantage to be gained by passing an nByte parameter that |
** is equal to the number of bytes in the input string <i>including</i> |
-** the nul-terminator bytes. |
+** the nul-terminator bytes as this saves SQLite from having to |
+** make a copy of the input string. |
** |
** ^If pzTail is not NULL then *pzTail is made to point to the first byte |
** past the end of the first SQL statement in zSql. These routines only |
@@ -2645,7 +3173,8 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
** <li> |
** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it |
** always used to do, [sqlite3_step()] will automatically recompile the SQL |
-** statement and try to run it again. |
+** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY] |
+** retries will occur before sqlite3_step() gives up and returns an error. |
** </li> |
** |
** <li> |
@@ -2666,8 +3195,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
** ^The specific value of WHERE-clause [parameter] might influence the |
** choice of query plan if the parameter is the left-hand side of a [LIKE] |
** or [GLOB] operator or if the parameter is compared to an indexed column |
-** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. |
-** the |
+** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. |
** </li> |
** </ol> |
*/ |
@@ -2741,6 +3269,25 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
/* |
+** CAPI3REF: Determine If A Prepared Statement Has Been Reset |
+** |
+** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the |
+** [prepared statement] S has been stepped at least once using |
+** [sqlite3_step(S)] but has not run to completion and/or has not |
+** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) |
+** interface returns false if S is a NULL pointer. If S is not a |
+** NULL pointer and is not a pointer to a valid [prepared statement] |
+** object, then the behavior is undefined and probably undesirable. |
+** |
+** This interface can be used in combination [sqlite3_next_stmt()] |
+** to locate all prepared statements associated with a database |
+** connection that are in need of being reset. This can be used, |
+** for example, in diagnostic routines to search for prepared |
+** statements that are holding a transaction open. |
+*/ |
+SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*); |
+ |
+/* |
** CAPI3REF: Dynamically Typed Value Object |
** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} |
** |
@@ -2830,18 +3377,31 @@ typedef struct sqlite3_context sqlite3_context; |
** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). |
** |
** ^The third argument is the value to bind to the parameter. |
+** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16() |
+** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter |
+** is ignored and the end result is the same as sqlite3_bind_null(). |
** |
** ^(In those routines that have a fourth argument, its value is the |
** number of bytes in the parameter. To be clear: the value is the |
** number of <u>bytes</u> in the value, not the number of characters.)^ |
-** ^If the fourth parameter is negative, the length of the string is |
+** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() |
+** is negative, then the length of the string is |
** the number of bytes up to the first zero terminator. |
-** |
-** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and |
-** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or |
+** If the fourth parameter to sqlite3_bind_blob() is negative, then |
+** the behavior is undefined. |
+** If a non-negative fourth parameter is provided to sqlite3_bind_text() |
+** or sqlite3_bind_text16() or sqlite3_bind_text64() then |
+** that parameter must be the byte offset |
+** where the NUL terminator would occur assuming the string were NUL |
+** terminated. If any NUL characters occur at byte offsets less than |
+** the value of the fourth parameter then the resulting string value will |
+** contain embedded NULs. The result of expressions involving strings |
+** with embedded NULs is undefined. |
+** |
+** ^The fifth argument to the BLOB and string binding interfaces |
+** is a destructor used to dispose of the BLOB or |
** string after SQLite has finished with it. ^The destructor is called |
-** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(), |
-** sqlite3_bind_text(), or sqlite3_bind_text16() fails. |
+** to dispose of the BLOB or string even if the call to bind API fails. |
** ^If the fifth argument is |
** the special value [SQLITE_STATIC], then SQLite assumes that the |
** information is in static, unmanaged space and does not need to be freed. |
@@ -2849,6 +3409,14 @@ typedef struct sqlite3_context sqlite3_context; |
** SQLite makes its own private copy of the data immediately, before |
** the sqlite3_bind_*() routine returns. |
** |
+** ^The sixth argument to sqlite3_bind_text64() must be one of |
+** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] |
+** to specify the encoding of the text in the third parameter. If |
+** the sixth argument to sqlite3_bind_text64() is not one of the |
+** allowed values shown above, or if the text encoding is different |
+** from the encoding specified by the sixth parameter, then the behavior |
+** is undefined. |
+** |
** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that |
** is filled with zeroes. ^A zeroblob uses a fixed amount of memory |
** (just an integer to hold its size) while it is being processed. |
@@ -2869,6 +3437,9 @@ typedef struct sqlite3_context sqlite3_context; |
** |
** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an |
** [error code] if anything goes wrong. |
+** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB |
+** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or |
+** [SQLITE_MAX_LENGTH]. |
** ^[SQLITE_RANGE] is returned if the parameter |
** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. |
** |
@@ -2876,12 +3447,16 @@ typedef struct sqlite3_context sqlite3_context; |
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. |
*/ |
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); |
+SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64, |
+ void(*)(void*)); |
SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); |
SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); |
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); |
SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); |
-SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); |
+SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*)); |
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
+SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64, |
+ void(*)(void*), unsigned char encoding); |
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
@@ -3104,7 +3679,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); |
** ^[SQLITE_BUSY] means that the database engine was unable to acquire the |
** database locks it needs to do its job. ^If the statement is a [COMMIT] |
** or occurs outside of an explicit transaction, then you can retry the |
-** statement. If the statement is not a [COMMIT] and occurs within a |
+** statement. If the statement is not a [COMMIT] and occurs within an |
** explicit transaction then you should rollback the transaction before |
** continuing. |
** |
@@ -3169,6 +3744,12 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*); |
** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
** interfaces) then sqlite3_data_count(P) returns 0. |
** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
+** ^The sqlite3_data_count(P) routine returns 0 if the previous call to |
+** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) |
+** will return non-zero if previous call to [sqlite3_step](P) returned |
+** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum] |
+** where it always returns zero since each step of that multi-step |
+** pragma returns 0 columns of data. |
** |
** See also: [sqlite3_column_count()] |
*/ |
@@ -3268,7 +3849,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
** bytes in the string, not the number of characters. |
** |
** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), |
-** even empty strings, are always zero terminated. ^The return |
+** even empty strings, are always zero-terminated. ^The return |
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. |
** |
** ^The object returned by [sqlite3_column_value()] is an |
@@ -3291,19 +3872,19 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
** |
** <tr><td> NULL <td> INTEGER <td> Result is 0 |
** <tr><td> NULL <td> FLOAT <td> Result is 0.0 |
-** <tr><td> NULL <td> TEXT <td> Result is NULL pointer |
-** <tr><td> NULL <td> BLOB <td> Result is NULL pointer |
+** <tr><td> NULL <td> TEXT <td> Result is a NULL pointer |
+** <tr><td> NULL <td> BLOB <td> Result is a NULL pointer |
** <tr><td> INTEGER <td> FLOAT <td> Convert from integer to float |
** <tr><td> INTEGER <td> TEXT <td> ASCII rendering of the integer |
** <tr><td> INTEGER <td> BLOB <td> Same as INTEGER->TEXT |
-** <tr><td> FLOAT <td> INTEGER <td> Convert from float to integer |
+** <tr><td> FLOAT <td> INTEGER <td> [CAST] to INTEGER |
** <tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float |
-** <tr><td> FLOAT <td> BLOB <td> Same as FLOAT->TEXT |
-** <tr><td> TEXT <td> INTEGER <td> Use atoi() |
-** <tr><td> TEXT <td> FLOAT <td> Use atof() |
+** <tr><td> FLOAT <td> BLOB <td> [CAST] to BLOB |
+** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER |
+** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL |
** <tr><td> TEXT <td> BLOB <td> No change |
-** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi() |
-** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof() |
+** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER |
+** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL |
** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed |
** </table> |
** </blockquote>)^ |
@@ -3359,7 +3940,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
** described above, or until [sqlite3_step()] or [sqlite3_reset()] or |
** [sqlite3_finalize()] is called. ^The memory space used to hold strings |
** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned |
-** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into |
+** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into |
** [sqlite3_free()]. |
** |
** ^(If a memory allocation error occurs during the evaluation of any |
@@ -3383,7 +3964,7 @@ SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); |
** CAPI3REF: Destroy A Prepared Statement Object |
** |
** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
-** ^If the most recent evaluation of the statement encountered no errors or |
+** ^If the most recent evaluation of the statement encountered no errors |
** or if the statement is never been evaluated, then sqlite3_finalize() returns |
** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
** sqlite3_finalize(S) returns the appropriate [error code] or |
@@ -3468,15 +4049,24 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
** |
** ^The fourth parameter, eTextRep, specifies what |
** [SQLITE_UTF8 | text encoding] this SQL function prefers for |
-** its parameters. Every SQL function implementation must be able to work |
-** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be |
-** more efficient with one encoding than another. ^An application may |
-** invoke sqlite3_create_function() or sqlite3_create_function16() multiple |
-** times with the same function but with different values of eTextRep. |
+** its parameters. The application should set this parameter to |
+** [SQLITE_UTF16LE] if the function implementation invokes |
+** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the |
+** implementation invokes [sqlite3_value_text16be()] on an input, or |
+** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8] |
+** otherwise. ^The same SQL function may be registered multiple times using |
+** different preferred text encodings, with different implementations for |
+** each encoding. |
** ^When multiple implementations of the same function are available, SQLite |
** will pick the one that involves the least amount of data conversion. |
-** If there is only a single implementation which does not care what text |
-** encoding is used, then the fourth argument should be [SQLITE_ANY]. |
+** |
+** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC] |
+** to signal that the function will always return the same result given |
+** the same inputs within a single SQL statement. Most SQL functions are |
+** deterministic. The built-in [random()] SQL function is an example of a |
+** function that is not deterministic. The SQLite query planner is able to |
+** perform additional optimizations on deterministic functions, so use |
+** of the [SQLITE_DETERMINISTIC] flag is recommended where possible. |
** |
** ^(The fifth parameter is an arbitrary pointer. The implementation of the |
** function can gain access to this pointer using [sqlite3_user_data()].)^ |
@@ -3562,10 +4152,20 @@ SQLITE_API int sqlite3_create_function_v2( |
#define SQLITE_UTF16LE 2 |
#define SQLITE_UTF16BE 3 |
#define SQLITE_UTF16 4 /* Use native byte order */ |
-#define SQLITE_ANY 5 /* sqlite3_create_function only */ |
+#define SQLITE_ANY 5 /* Deprecated */ |
#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ |
/* |
+** CAPI3REF: Function Flags |
+** |
+** These constants may be ORed together with the |
+** [SQLITE_UTF8 | preferred text encoding] as the fourth argument |
+** to [sqlite3_create_function()], [sqlite3_create_function16()], or |
+** [sqlite3_create_function_v2()]. |
+*/ |
+#define SQLITE_DETERMINISTIC 0x800 |
+ |
+/* |
** CAPI3REF: Deprecated Functions |
** DEPRECATED |
** |
@@ -3581,7 +4181,8 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); |
SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
-SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); |
+SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int), |
+ void*,sqlite3_int64); |
#endif |
/* |
@@ -3604,7 +4205,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6 |
** object results in undefined behavior. |
** |
** ^These routines work just like the corresponding [column access functions] |
-** except that these routines take a single [protected sqlite3_value] object |
+** except that these routines take a single [protected sqlite3_value] object |
** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. |
** |
** ^The sqlite3_value_text16() interface extracts a UTF-16 string |
@@ -3661,14 +4262,17 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); |
** In those cases, sqlite3_aggregate_context() might be called for the |
** first time from within xFinal().)^ |
** |
-** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is |
-** less than or equal to zero or if a memory allocate error occurs. |
+** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer |
+** when first called if N is less than or equal to zero or if a memory |
+** allocate error occurs. |
** |
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
** determined by the N parameter on first successful call. Changing the |
** value of N in subsequent call to sqlite3_aggregate_context() within |
** the same aggregate function instance will not resize the memory |
-** allocation.)^ |
+** allocation.)^ Within the xFinal callback, it is customary to set |
+** N=0 in calls to sqlite3_aggregate_context(C,N) so that no |
+** pointless memory allocations occur. |
** |
** ^SQLite automatically frees the memory allocated by |
** sqlite3_aggregate_context() when the aggregate query concludes. |
@@ -3711,41 +4315,49 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); |
/* |
** CAPI3REF: Function Auxiliary Data |
** |
-** The following two functions may be used by scalar SQL functions to |
+** These functions may be used by (non-aggregate) SQL functions to |
** associate metadata with argument values. If the same value is passed to |
** multiple invocations of the same SQL function during query execution, under |
-** some circumstances the associated metadata may be preserved. This may |
-** be used, for example, to add a regular-expression matching scalar |
-** function. The compiled version of the regular expression is stored as |
-** metadata associated with the SQL value passed as the regular expression |
-** pattern. The compiled regular expression can be reused on multiple |
-** invocations of the same function so that the original pattern string |
-** does not need to be recompiled on each invocation. |
+** some circumstances the associated metadata may be preserved. An example |
+** of where this might be useful is in a regular-expression matching |
+** function. The compiled version of the regular expression can be stored as |
+** metadata associated with the pattern string. |
+** Then as long as the pattern string remains the same, |
+** the compiled regular expression can be reused on multiple |
+** invocations of the same function. |
** |
** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata |
** associated by the sqlite3_set_auxdata() function with the Nth argument |
-** value to the application-defined function. ^If no metadata has been ever |
-** been set for the Nth argument of the function, or if the corresponding |
-** function parameter has changed since the meta-data was set, |
-** then sqlite3_get_auxdata() returns a NULL pointer. |
-** |
-** ^The sqlite3_set_auxdata() interface saves the metadata |
-** pointed to by its 3rd parameter as the metadata for the N-th |
-** argument of the application-defined function. Subsequent |
-** calls to sqlite3_get_auxdata() might return this data, if it has |
-** not been destroyed. |
-** ^If it is not NULL, SQLite will invoke the destructor |
-** function given by the 4th parameter to sqlite3_set_auxdata() on |
-** the metadata when the corresponding function parameter changes |
-** or when the SQL statement completes, whichever comes first. |
-** |
-** SQLite is free to call the destructor and drop metadata on any |
-** parameter of any function at any time. ^The only guarantee is that |
-** the destructor will be called before the metadata is dropped. |
+** value to the application-defined function. ^If there is no metadata |
+** associated with the function argument, this sqlite3_get_auxdata() interface |
+** returns a NULL pointer. |
+** |
+** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th |
+** argument of the application-defined function. ^Subsequent |
+** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
+** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or |
+** NULL if the metadata has been discarded. |
+** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
+** SQLite will invoke the destructor function X with parameter P exactly |
+** once, when the metadata is discarded. |
+** SQLite is free to discard the metadata at any time, including: <ul> |
+** <li> when the corresponding function parameter changes, or |
+** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
+** SQL statement, or |
+** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or |
+** <li> during the original sqlite3_set_auxdata() call when a memory |
+** allocation error occurs. </ul>)^ |
+** |
+** Note the last bullet in particular. The destructor X in |
+** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the |
+** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
+** should be called near the end of the function implementation and the |
+** function implementation should not make any use of P after |
+** sqlite3_set_auxdata() has been called. |
** |
** ^(In practice, metadata is preserved between function calls for |
-** expressions that are constant at compile time. This includes literal |
-** values and [parameters].)^ |
+** function parameters that are compile-time constants, including literal |
+** values and [parameters] and expressions composed from the same.)^ |
** |
** These routines must be called from the same thread in which |
** the SQL function is running. |
@@ -3766,7 +4378,7 @@ SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(voi |
** the content before returning. |
** |
** The typedef is necessary to work around problems in certain |
-** C++ compilers. See ticket #2191. |
+** C++ compilers. |
*/ |
typedef void (*sqlite3_destructor_type)(void*); |
#define SQLITE_STATIC ((sqlite3_destructor_type)0) |
@@ -3819,11 +4431,11 @@ typedef void (*sqlite3_destructor_type)(void*); |
** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() |
** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. |
** |
-** ^The sqlite3_result_toobig() interface causes SQLite to throw an error |
-** indicating that a string or BLOB is too long to represent. |
+** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an |
+** error indicating that a string or BLOB is too long to represent. |
** |
-** ^The sqlite3_result_nomem() interface causes SQLite to throw an error |
-** indicating that a memory allocation failed. |
+** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an |
+** error indicating that a memory allocation failed. |
** |
** ^The sqlite3_result_int() interface sets the return value |
** of the application-defined function to be the 32-bit signed integer |
@@ -3840,6 +4452,10 @@ typedef void (*sqlite3_destructor_type)(void*); |
** set the return value of the application-defined function to be |
** a text string which is represented as UTF-8, UTF-16 native byte order, |
** UTF-16 little endian, or UTF-16 big endian, respectively. |
+** ^The sqlite3_result_text64() interface sets the return value of an |
+** application-defined function to be a text string in an encoding |
+** specified by the fifth (and last) parameter, which must be one |
+** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]. |
** ^SQLite takes the text result from the application from |
** the 2nd parameter of the sqlite3_result_text* interfaces. |
** ^If the 3rd parameter to the sqlite3_result_text* interfaces |
@@ -3848,7 +4464,12 @@ typedef void (*sqlite3_destructor_type)(void*); |
** ^If the 3rd parameter to the sqlite3_result_text* interfaces |
** is non-negative, then as many bytes (not characters) of the text |
** pointed to by the 2nd parameter are taken as the application-defined |
-** function result. |
+** function result. If the 3rd parameter is non-negative, then it |
+** must be the byte offset into the string where the NUL terminator would |
+** appear if the string where NUL terminated. If any NUL characters occur |
+** in the string at a byte offset that is less than the value of the 3rd |
+** parameter, then the resulting string will contain embedded NULs and the |
+** result of expressions operating on strings with embedded NULs is undefined. |
** ^If the 4th parameter to the sqlite3_result_text* interfaces |
** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that |
** function as the destructor on the text or BLOB result when it has |
@@ -3878,6 +4499,7 @@ typedef void (*sqlite3_destructor_type)(void*); |
** the [sqlite3_context] pointer, the results are undefined. |
*/ |
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); |
+SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,sqlite3_uint64,void(*)(void*)); |
SQLITE_API void sqlite3_result_double(sqlite3_context*, double); |
SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); |
SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); |
@@ -3888,6 +4510,8 @@ SQLITE_API void sqlite3_result_int(sqlite3_context*, int); |
SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); |
SQLITE_API void sqlite3_result_null(sqlite3_context*); |
SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); |
+SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64, |
+ void(*)(void*), unsigned char encoding); |
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); |
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); |
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
@@ -4045,6 +4669,11 @@ SQLITE_API int sqlite3_key( |
sqlite3 *db, /* Database to be rekeyed */ |
const void *pKey, int nKey /* The key */ |
); |
+SQLITE_API int sqlite3_key_v2( |
+ sqlite3 *db, /* Database to be rekeyed */ |
+ const char *zDbName, /* Name of the database */ |
+ const void *pKey, int nKey /* The key */ |
+); |
/* |
** Change the key on an open database. If the current database is not |
@@ -4058,6 +4687,11 @@ SQLITE_API int sqlite3_rekey( |
sqlite3 *db, /* Database to be rekeyed */ |
const void *pKey, int nKey /* The new key */ |
); |
+SQLITE_API int sqlite3_rekey_v2( |
+ sqlite3 *db, /* Database to be rekeyed */ |
+ const char *zDbName, /* Name of the database */ |
+ const void *pKey, int nKey /* The new key */ |
+); |
/* |
** Specify the activation key for a SEE database. Unless |
@@ -4107,6 +4741,13 @@ SQLITE_API int sqlite3_sleep(int); |
** is a NULL pointer, then SQLite performs a search for an appropriate |
** temporary file directory. |
** |
+** Applications are strongly discouraged from using this global variable. |
+** It is required to set a temporary folder on Windows Runtime (WinRT). |
+** But for all other platforms, it is highly recommended that applications |
+** neither read nor write this variable. This global variable is a relic |
+** that exists for backwards compatibility of legacy applications and should |
+** be avoided in new projects. |
+** |
** It is not safe to read or modify this variable in more than one |
** thread at a time. It is not safe to read or modify this variable |
** if a [database connection] is being used at the same time in a separate |
@@ -4125,10 +4766,67 @@ SQLITE_API int sqlite3_sleep(int); |
** Hence, if this variable is modified directly, either it should be |
** made NULL or made to point to memory obtained from [sqlite3_malloc] |
** or else the use of the [temp_store_directory pragma] should be avoided. |
+** Except when requested by the [temp_store_directory pragma], SQLite |
+** does not free the memory that sqlite3_temp_directory points to. If |
+** the application wants that memory to be freed, it must do |
+** so itself, taking care to only do so after all [database connection] |
+** objects have been destroyed. |
+** |
+** <b>Note to Windows Runtime users:</b> The temporary directory must be set |
+** prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various |
+** features that require the use of temporary files may fail. Here is an |
+** example of how to do this using C++ with the Windows Runtime: |
+** |
+** <blockquote><pre> |
+** LPCWSTR zPath = Windows::Storage::ApplicationData::Current-> |
+** TemporaryFolder->Path->Data(); |
+** char zPathBuf[MAX_PATH + 1]; |
+** memset(zPathBuf, 0, sizeof(zPathBuf)); |
+** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf), |
+** NULL, NULL); |
+** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf); |
+** </pre></blockquote> |
*/ |
SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; |
/* |
+** CAPI3REF: Name Of The Folder Holding Database Files |
+** |
+** ^(If this global variable is made to point to a string which is |
+** the name of a folder (a.k.a. directory), then all database files |
+** specified with a relative pathname and created or accessed by |
+** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed |
+** to be relative to that directory.)^ ^If this variable is a NULL |
+** pointer, then SQLite assumes that all database files specified |
+** with a relative pathname are relative to the current directory |
+** for the process. Only the windows VFS makes use of this global |
+** variable; it is ignored by the unix VFS. |
+** |
+** Changing the value of this variable while a database connection is |
+** open can result in a corrupt database. |
+** |
+** It is not safe to read or modify this variable in more than one |
+** thread at a time. It is not safe to read or modify this variable |
+** if a [database connection] is being used at the same time in a separate |
+** thread. |
+** It is intended that this variable be set once |
+** as part of process initialization and before any SQLite interface |
+** routines have been called and that this variable remain unchanged |
+** thereafter. |
+** |
+** ^The [data_store_directory pragma] may modify this variable and cause |
+** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, |
+** the [data_store_directory pragma] always assumes that any string |
+** that this variable points to is held in memory obtained from |
+** [sqlite3_malloc] and the pragma may attempt to free that memory |
+** using [sqlite3_free]. |
+** Hence, if this variable is modified directly, either it should be |
+** made NULL or made to point to memory obtained from [sqlite3_malloc] |
+** or else the use of the [data_store_directory pragma] should be avoided. |
+*/ |
+SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory; |
+ |
+/* |
** CAPI3REF: Test For Auto-Commit Mode |
** KEYWORDS: {autocommit mode} |
** |
@@ -4164,6 +4862,31 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*); |
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); |
/* |
+** CAPI3REF: Return The Filename For A Database Connection |
+** |
+** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename |
+** associated with database N of connection D. ^The main database file |
+** has the name "main". If there is no attached database N on the database |
+** connection D, or if database N is a temporary or in-memory database, then |
+** a NULL pointer is returned. |
+** |
+** ^The filename returned by this function is the output of the |
+** xFullPathname method of the [VFS]. ^In other words, the filename |
+** will be an absolute pathname, even if the filename used |
+** to open the database originally was a URI or relative pathname. |
+*/ |
+SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); |
+ |
+/* |
+** CAPI3REF: Determine if a database is read-only |
+** |
+** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N |
+** of connection D is read-only, 0 if it is read/write, or -1 if N is not |
+** the name of a database on connection D. |
+*/ |
+SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); |
+ |
+/* |
** CAPI3REF: Find the next prepared statement |
** |
** ^This interface returns a pointer to the next [prepared statement] after |
@@ -4198,13 +4921,15 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); |
** on the same [database connection] D, or NULL for |
** the first call for each function on D. |
** |
+** The commit and rollback hook callbacks are not reentrant. |
** The callback implementation must not do anything that will modify |
** the database connection that invoked the callback. Any actions |
** to modify the database connection must be deferred until after the |
** completion of the [sqlite3_step()] call that triggered the commit |
** or rollback hook in the first place. |
-** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
-** database connections for the meaning of "modify" in this paragraph. |
+** Note that running any other SQL statements, including SELECT statements, |
+** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify |
+** the database connections for the meaning of "modify" in this paragraph. |
** |
** ^Registering a NULL function disables the callback. |
** |
@@ -4230,12 +4955,13 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
** |
** ^The sqlite3_update_hook() interface registers a callback function |
** with the [database connection] identified by the first argument |
-** to be invoked whenever a row is updated, inserted or deleted. |
+** to be invoked whenever a row is updated, inserted or deleted in |
+** a rowid table. |
** ^Any callback set by a previous call to this function |
** for the same database connection is overridden. |
** |
** ^The second argument is a pointer to the function to invoke when a |
-** row is updated, inserted or deleted. |
+** row is updated, inserted or deleted in a rowid table. |
** ^The first argument to the callback is a copy of the third argument |
** to sqlite3_update_hook(). |
** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], |
@@ -4248,6 +4974,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
** |
** ^(The update hook is not invoked when internal system tables are |
** modified (i.e. sqlite_master and sqlite_sequence).)^ |
+** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified. |
** |
** ^In the current implementation, the update hook |
** is not invoked when duplication rows are deleted because of an |
@@ -4279,7 +5006,6 @@ SQLITE_API void *sqlite3_update_hook( |
/* |
** CAPI3REF: Enable Or Disable Shared Pager Cache |
-** KEYWORDS: {shared cache} |
** |
** ^(This routine enables or disables the sharing of the database cache |
** and schema data structures between [database connection | connections] |
@@ -4302,6 +5028,9 @@ SQLITE_API void *sqlite3_update_hook( |
** future releases of SQLite. Applications that care about shared |
** cache setting should set it explicitly. |
** |
+** This interface is threadsafe on processors where writing a |
+** 32-bit integer is atomic. |
+** |
** See Also: [SQLite Shared-Cache Mode] |
*/ |
SQLITE_API int sqlite3_enable_shared_cache(int); |
@@ -4317,10 +5046,25 @@ SQLITE_API int sqlite3_enable_shared_cache(int); |
** which might be more or less than the amount requested. |
** ^The sqlite3_release_memory() routine is a no-op returning zero |
** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. |
+** |
+** See also: [sqlite3_db_release_memory()] |
*/ |
SQLITE_API int sqlite3_release_memory(int); |
/* |
+** CAPI3REF: Free Memory Used By A Database Connection |
+** |
+** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap |
+** memory as possible from database connection D. Unlike the |
+** [sqlite3_release_memory()] interface, this interface is in effect even |
+** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is |
+** omitted. |
+** |
+** See also: [sqlite3_release_memory()] |
+*/ |
+SQLITE_API int sqlite3_db_release_memory(sqlite3*); |
+ |
+/* |
** CAPI3REF: Impose A Limit On Heap Size |
** |
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the |
@@ -4334,7 +5078,8 @@ SQLITE_API int sqlite3_release_memory(int); |
** is advisory only. |
** |
** ^The return value from sqlite3_soft_heap_limit64() is the size of |
-** the soft heap limit prior to the call. ^If the argument N is negative |
+** the soft heap limit prior to the call, or negative in the case of an |
+** error. ^If the argument N is negative |
** then no change is made to the soft heap limit. Hence, the current |
** size of the soft heap limit can be determined by invoking |
** sqlite3_soft_heap_limit64() with a negative argument. |
@@ -4350,7 +5095,7 @@ SQLITE_API int sqlite3_release_memory(int); |
** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and |
** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. |
** <li> An alternative page cache implementation is specified using |
-** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...). |
+** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...). |
** <li> The page cache allocates from its own memory pool supplied |
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than |
** from the heap. |
@@ -4463,11 +5208,20 @@ SQLITE_API int sqlite3_table_column_metadata( |
** ^This interface loads an SQLite extension library from the named file. |
** |
** ^The sqlite3_load_extension() interface attempts to load an |
-** SQLite extension library contained in the file zFile. |
+** [SQLite extension] library contained in the file zFile. If |
+** the file cannot be loaded directly, attempts are made to load |
+** with various operating-system specific extensions added. |
+** So for example, if "samplelib" cannot be loaded, then names like |
+** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might |
+** be tried also. |
** |
** ^The entry point is zProc. |
-** ^zProc may be 0, in which case the name of the entry point |
-** defaults to "sqlite3_extension_init". |
+** ^(zProc may be 0, in which case SQLite will try to come up with an |
+** entry point name on its own. It first tries "sqlite3_extension_init". |
+** If that does not work, it constructs a name "sqlite3_X_init" where the |
+** X is consists of the lower-case equivalent of all ASCII alphabetic |
+** characters in the filename from the last "/" to the first following |
+** "." and omitting any initial "lib".)^ |
** ^The sqlite3_load_extension() interface returns |
** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. |
** ^If an error occurs and pzErrMsg is not 0, then the |
@@ -4493,11 +5247,11 @@ SQLITE_API int sqlite3_load_extension( |
** CAPI3REF: Enable Or Disable Extension Loading |
** |
** ^So as not to open security holes in older applications that are |
-** unprepared to deal with extension loading, and as a means of disabling |
-** extension loading while evaluating user-entered SQL, the following API |
+** unprepared to deal with [extension loading], and as a means of disabling |
+** [extension loading] while evaluating user-entered SQL, the following API |
** is provided to turn the [sqlite3_load_extension()] mechanism on and off. |
** |
-** ^Extension loading is off by default. See ticket #1863. |
+** ^Extension loading is off by default. |
** ^Call the sqlite3_enable_load_extension() routine with onoff==1 |
** to turn extension loading on and call it with onoff==0 to turn |
** it back off again. |
@@ -4509,7 +5263,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
** |
** ^This interface causes the xEntryPoint() function to be invoked for |
** each new [database connection] that is created. The idea here is that |
-** xEntryPoint() is the entry point for a statically linked SQLite extension |
+** xEntryPoint() is the entry point for a statically linked [SQLite extension] |
** that is to be automatically loaded into all new database connections. |
** |
** ^(Even though the function prototype shows that xEntryPoint() takes |
@@ -4537,11 +5291,24 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
** on the list of automatic extensions is a harmless no-op. ^No entry point |
** will be called more than once for each database connection that is opened. |
** |
-** See also: [sqlite3_reset_auto_extension()]. |
+** See also: [sqlite3_reset_auto_extension()] |
+** and [sqlite3_cancel_auto_extension()] |
*/ |
SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); |
/* |
+** CAPI3REF: Cancel Automatic Extension Loading |
+** |
+** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the |
+** initialization routine X that was registered using a prior call to |
+** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] |
+** routine returns 1 if initialization routine X was successfully |
+** unregistered and it returns 0 if X was not on the list of initialization |
+** routines. |
+*/ |
+SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); |
+ |
+/* |
** CAPI3REF: Reset Automatic Extension Loading |
** |
** ^This interface disables all automatic extensions previously |
@@ -4610,6 +5377,11 @@ struct sqlite3_module { |
void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), |
void **ppArg); |
int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); |
+ /* The methods above are in version 1 of the sqlite_module object. Those |
+ ** below are for version 2 and greater. */ |
+ int (*xSavepoint)(sqlite3_vtab *pVTab, int); |
+ int (*xRelease)(sqlite3_vtab *pVTab, int); |
+ int (*xRollbackTo)(sqlite3_vtab *pVTab, int); |
}; |
/* |
@@ -4660,10 +5432,22 @@ struct sqlite3_module { |
** the correct order to satisfy the ORDER BY clause so that no separate |
** sorting step is required. |
** |
-** ^The estimatedCost value is an estimate of the cost of doing the |
-** particular lookup. A full scan of a table with N entries should have |
-** a cost of N. A binary search of a table of N entries should have a |
-** cost of approximately log(N). |
+** ^The estimatedCost value is an estimate of the cost of a particular |
+** strategy. A cost of N indicates that the cost of the strategy is similar |
+** to a linear scan of an SQLite table with N rows. A cost of log(N) |
+** indicates that the expense of the operation is similar to that of a |
+** binary search on a unique indexed field of an SQLite table with N rows. |
+** |
+** ^The estimatedRows value is an estimate of the number of rows that |
+** will be returned by the strategy. |
+** |
+** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info |
+** structure for SQLite version 3.8.2. If a virtual table extension is |
+** used with an SQLite version earlier than 3.8.2, the results of attempting |
+** to read or write the estimatedRows field are undefined (but are likely |
+** to included crashing the application). The estimatedRows field should |
+** therefore only be used if [sqlite3_libversion_number()] returns a |
+** value greater than or equal to 3008002. |
*/ |
struct sqlite3_index_info { |
/* Inputs */ |
@@ -4688,7 +5472,9 @@ struct sqlite3_index_info { |
char *idxStr; /* String, possibly obtained from sqlite3_malloc */ |
int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ |
int orderByConsumed; /* True if output is already ordered */ |
- double estimatedCost; /* Estimated cost of using this index */ |
+ double estimatedCost; /* Estimated cost of using this index */ |
+ /* Fields below are only available in SQLite 3.8.2 and later */ |
+ sqlite3_int64 estimatedRows; /* Estimated number of rows returned */ |
}; |
/* |
@@ -4892,6 +5678,9 @@ typedef struct sqlite3_blob sqlite3_blob; |
** interface. Use the [UPDATE] SQL command to change the size of a |
** blob. |
** |
+** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID] |
+** table. Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables. |
+** |
** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces |
** and the built-in [zeroblob] SQL function can be used, if desired, |
** to create an empty, zero-filled blob in which to read or write using |
@@ -5086,17 +5875,16 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); |
** implementations are available in the SQLite core: |
** |
** <ul> |
-** <li> SQLITE_MUTEX_OS2 |
-** <li> SQLITE_MUTEX_PTHREAD |
+** <li> SQLITE_MUTEX_PTHREADS |
** <li> SQLITE_MUTEX_W32 |
** <li> SQLITE_MUTEX_NOOP |
** </ul>)^ |
** |
** ^The SQLITE_MUTEX_NOOP implementation is a set of routines |
** that does no real locking and is appropriate for use in |
-** a single-threaded application. ^The SQLITE_MUTEX_OS2, |
-** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations |
-** are appropriate for use on OS/2, Unix, and Windows. |
+** a single-threaded application. ^The SQLITE_MUTEX_PTHREADS and |
+** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix |
+** and Windows. |
** |
** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor |
** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
@@ -5117,10 +5905,12 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); |
** <li> SQLITE_MUTEX_RECURSIVE |
** <li> SQLITE_MUTEX_STATIC_MASTER |
** <li> SQLITE_MUTEX_STATIC_MEM |
-** <li> SQLITE_MUTEX_STATIC_MEM2 |
+** <li> SQLITE_MUTEX_STATIC_OPEN |
** <li> SQLITE_MUTEX_STATIC_PRNG |
** <li> SQLITE_MUTEX_STATIC_LRU |
-** <li> SQLITE_MUTEX_STATIC_LRU2 |
+** <li> SQLITE_MUTEX_STATIC_PMEM |
+** <li> SQLITE_MUTEX_STATIC_APP1 |
+** <li> SQLITE_MUTEX_STATIC_APP2 |
** </ul>)^ |
** |
** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) |
@@ -5285,14 +6075,14 @@ struct sqlite3_mutex_methods { |
** ^These routines should return true if the mutex in their argument |
** is held or not held, respectively, by the calling thread. |
** |
-** ^The implementation is not required to provided versions of these |
+** ^The implementation is not required to provide versions of these |
** routines that actually work. If the implementation does not provide working |
** versions of these routines, it should at least provide stubs that always |
** return true so that one does not get spurious assertion failures. |
** |
** ^If the argument to sqlite3_mutex_held() is a NULL pointer then |
** the routine should return 1. This seems counter-intuitive since |
-** clearly the mutex cannot be held if it does not exist. But the |
+** clearly the mutex cannot be held if it does not exist. But |
** the reason the mutex does not exist is because the build is not |
** using mutexes. And we do not want the assert() containing the |
** call to sqlite3_mutex_held() to fail, so a non-zero return is |
@@ -5324,6 +6114,9 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); |
#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ |
#define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ |
#define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ |
+#define SQLITE_MUTEX_STATIC_APP1 8 /* For use by application */ |
+#define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */ |
+#define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */ |
/* |
** CAPI3REF: Retrieve the mutex for a database connection |
@@ -5413,9 +6206,15 @@ SQLITE_API int sqlite3_test_control(int op, ...); |
#define SQLITE_TESTCTRL_RESERVE 14 |
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
#define SQLITE_TESTCTRL_ISKEYWORD 16 |
-#define SQLITE_TESTCTRL_PGHDRSZ 17 |
-#define SQLITE_TESTCTRL_SCRATCHMALLOC 18 |
-#define SQLITE_TESTCTRL_LAST 18 |
+#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 |
+#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 |
+#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */ |
+#define SQLITE_TESTCTRL_NEVER_CORRUPT 20 |
+#define SQLITE_TESTCTRL_VDBE_COVERAGE 21 |
+#define SQLITE_TESTCTRL_BYTEORDER 22 |
+#define SQLITE_TESTCTRL_ISINIT 23 |
+#define SQLITE_TESTCTRL_SORTER_MMAP 24 |
+#define SQLITE_TESTCTRL_LAST 24 |
/* |
** CAPI3REF: SQLite Runtime Status |
@@ -5424,7 +6223,7 @@ SQLITE_API int sqlite3_test_control(int op, ...); |
** about the performance of SQLite, and optionally to reset various |
** highwater marks. ^The first argument is an integer code for |
** the specific parameter to measure. ^(Recognized integer codes |
-** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^ |
+** are of the form [status parameters | SQLITE_STATUS_...].)^ |
** ^The current value of the parameter is returned into *pCurrent. |
** ^The highest recorded value is returned in *pHighwater. ^If the |
** resetFlag is true, then the highest record value is reset after |
@@ -5451,12 +6250,13 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF |
/* |
** CAPI3REF: Status Parameters |
+** KEYWORDS: {status parameters} |
** |
** These integer constants designate various run-time status parameters |
** that can be returned by [sqlite3_status()]. |
** |
** <dl> |
-** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt> |
+** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt> |
** <dd>This parameter is the current amount of memory checked out |
** using [sqlite3_malloc()], either directly or indirectly. The |
** figure includes calls made to [sqlite3_malloc()] by the application |
@@ -5466,23 +6266,24 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF |
** this parameter. The amount returned is the sum of the allocation |
** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt> |
+** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt> |
** <dd>This parameter records the largest memory allocation request |
** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their |
** internal equivalents). Only the value returned in the |
** *pHighwater parameter to [sqlite3_status()] is of interest. |
** The value written into the *pCurrent parameter is undefined.</dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
+** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
** <dd>This parameter records the number of separate memory allocations |
** currently checked out.</dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
+** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
** <dd>This parameter returns the number of pages used out of the |
** [pagecache memory allocator] that was configured using |
** [SQLITE_CONFIG_PAGECACHE]. The |
** value returned is in pages, not in bytes.</dd>)^ |
** |
+** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] |
** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> |
** <dd>This parameter returns the number of bytes of page cache |
** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] |
@@ -5492,13 +6293,13 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF |
** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because |
** no space was left in the page cache.</dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> |
+** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> |
** <dd>This parameter records the largest memory allocation request |
** handed to [pagecache memory allocator]. Only the value returned in the |
** *pHighwater parameter to [sqlite3_status()] is of interest. |
** The value written into the *pCurrent parameter is undefined.</dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt> |
+** [[SQLITE_STATUS_SCRATCH_USED]] ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt> |
** <dd>This parameter returns the number of allocations used out of the |
** [scratch memory allocator] configured using |
** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not |
@@ -5506,7 +6307,7 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF |
** outstanding at time, this parameter also reports the number of threads |
** using scratch memory at the same time.</dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> |
+** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> |
** <dd>This parameter returns the number of bytes of scratch memory |
** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH] |
** buffer and where forced to overflow to [sqlite3_malloc()]. The values |
@@ -5516,13 +6317,13 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF |
** slots were available. |
** </dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt> |
+** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt> |
** <dd>This parameter records the largest memory allocation request |
** handed to [scratch memory allocator]. Only the value returned in the |
** *pHighwater parameter to [sqlite3_status()] is of interest. |
** The value written into the *pCurrent parameter is undefined.</dd>)^ |
** |
-** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt> |
+** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt> |
** <dd>This parameter records the deepest parser stack. It is only |
** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^ |
** </dl> |
@@ -5547,9 +6348,9 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF |
** about a single [database connection]. ^The first argument is the |
** database connection object to be interrogated. ^The second argument |
** is an integer constant, taken from the set of |
-** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros, that |
+** [SQLITE_DBSTATUS options], that |
** determines the parameter to interrogate. The set of |
-** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros is likely |
+** [SQLITE_DBSTATUS options] is likely |
** to grow in future releases of SQLite. |
** |
** ^The current value of the requested parameter is written into *pCur |
@@ -5566,6 +6367,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r |
/* |
** CAPI3REF: Status Parameters for database connections |
+** KEYWORDS: {SQLITE_DBSTATUS options} |
** |
** These constants are the available integer "verbs" that can be passed as |
** the second argument to the [sqlite3_db_status()] interface. |
@@ -5577,15 +6379,16 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r |
** if a discontinued or unsupported verb is invoked. |
** |
** <dl> |
-** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
+** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
** <dd>This parameter returns the number of lookaside memory slots currently |
** checked out.</dd>)^ |
** |
-** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
+** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
** <dd>This parameter returns the number malloc attempts that were |
** satisfied using lookaside memory. Only the high-water value is meaningful; |
** the current value is always zero.)^ |
** |
+** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] |
** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
** <dd>This parameter returns the number malloc attempts that might have |
** been satisfied using lookaside memory but failed due to the amount of |
@@ -5593,6 +6396,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r |
** Only the high-water value is meaningful; |
** the current value is always zero.)^ |
** |
+** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] |
** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> |
** <dd>This parameter returns the number malloc attempts that might have |
** been satisfied using lookaside memory but failed due to all lookaside |
@@ -5600,13 +6404,13 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r |
** Only the high-water value is meaningful; |
** the current value is always zero.)^ |
** |
-** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
-** <dd>This parameter returns the approximate number of of bytes of heap |
+** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
+** <dd>This parameter returns the approximate number of bytes of heap |
** memory used by all pager caches associated with the database connection.)^ |
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
** |
-** ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt> |
-** <dd>This parameter returns the approximate number of of bytes of heap |
+** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt> |
+** <dd>This parameter returns the approximate number of bytes of heap |
** memory used to store the schema for all databases associated |
** with the connection - main, temp, and any [ATTACH]-ed databases.)^ |
** ^The full amount of memory used by the schemas is reported, even if the |
@@ -5614,12 +6418,41 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r |
** [shared cache mode] being enabled. |
** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. |
** |
-** ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt> |
-** <dd>This parameter returns the approximate number of of bytes of heap |
+** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt> |
+** <dd>This parameter returns the approximate number of bytes of heap |
** and lookaside memory used by all prepared statements associated with |
** the database connection.)^ |
** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
** </dd> |
+** |
+** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt> |
+** <dd>This parameter returns the number of pager cache hits that have |
+** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT |
+** is always 0. |
+** </dd> |
+** |
+** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt> |
+** <dd>This parameter returns the number of pager cache misses that have |
+** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS |
+** is always 0. |
+** </dd> |
+** |
+** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt> |
+** <dd>This parameter returns the number of dirty cache entries that have |
+** been written to disk. Specifically, the number of pages written to the |
+** wal file in wal mode databases, or the number of pages written to the |
+** database file in rollback mode databases. Any pages written as part of |
+** transaction rollback or database recovery operations are not included. |
+** If an IO or other error occurs while writing a page to disk, the effect |
+** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The |
+** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0. |
+** </dd> |
+** |
+** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt> |
+** <dd>This parameter returns zero for the current value if and only if |
+** all foreign key constraints (deferred or immediate) have been |
+** resolved.)^ ^The highwater mark is always 0. |
+** </dd> |
** </dl> |
*/ |
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
@@ -5629,14 +6462,18 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r |
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
-#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ |
+#define SQLITE_DBSTATUS_CACHE_HIT 7 |
+#define SQLITE_DBSTATUS_CACHE_MISS 8 |
+#define SQLITE_DBSTATUS_CACHE_WRITE 9 |
+#define SQLITE_DBSTATUS_DEFERRED_FKS 10 |
+#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */ |
/* |
** CAPI3REF: Prepared Statement Status |
** |
** ^(Each prepared statement maintains various |
-** [SQLITE_STMTSTATUS_SORT | counters] that measure the number |
+** [SQLITE_STMTSTATUS counters] that measure the number |
** of times it has performed specific operations.)^ These counters can |
** be used to monitor the performance characteristics of the prepared |
** statements. For example, if the number of table steps greatly exceeds |
@@ -5647,7 +6484,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r |
** ^(This interface is used to retrieve and reset counter values from |
** a [prepared statement]. The first argument is the prepared statement |
** object to be interrogated. The second argument |
-** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter] |
+** is an integer code for a specific [SQLITE_STMTSTATUS counter] |
** to be interrogated.)^ |
** ^The current value of the requested counter is returned. |
** ^If the resetFlg is true, then the counter is reset to zero after this |
@@ -5659,35 +6496,45 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); |
/* |
** CAPI3REF: Status Parameters for prepared statements |
+** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} |
** |
** These preprocessor macros define integer codes that name counter |
** values associated with the [sqlite3_stmt_status()] interface. |
** The meanings of the various counters are as follows: |
** |
** <dl> |
-** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt> |
+** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt> |
** <dd>^This is the number of times that SQLite has stepped forward in |
** a table as part of a full table scan. Large numbers for this counter |
** may indicate opportunities for performance improvement through |
** careful use of indices.</dd> |
** |
-** <dt>SQLITE_STMTSTATUS_SORT</dt> |
+** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt> |
** <dd>^This is the number of sort operations that have occurred. |
** A non-zero value in this counter may indicate an opportunity to |
** improvement performance through careful use of indices.</dd> |
** |
-** <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt> |
+** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt> |
** <dd>^This is the number of rows inserted into transient indices that |
** were created automatically in order to help joins run faster. |
** A non-zero value in this counter may indicate an opportunity to |
** improvement performance by adding permanent indices that do not |
** need to be reinitialized each time the statement is run.</dd> |
** |
+** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt> |
+** <dd>^This is the number of virtual machine operations executed |
+** by the prepared statement if that number is less than or equal |
+** to 2147483647. The number of virtual machine operations can be |
+** used as a proxy for the total work done by the prepared statement. |
+** If the number of virtual machine operations exceeds 2147483647 |
+** then the value returned by this statement status code is undefined. |
+** </dd> |
** </dl> |
*/ |
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
#define SQLITE_STMTSTATUS_SORT 2 |
#define SQLITE_STMTSTATUS_AUTOINDEX 3 |
+#define SQLITE_STMTSTATUS_VM_STEP 4 |
/* |
** CAPI3REF: Custom Page Cache Object |
@@ -5698,17 +6545,33 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); |
** sqlite3_pcache object except by holding and passing pointers |
** to the object. |
** |
-** See [sqlite3_pcache_methods] for additional information. |
+** See [sqlite3_pcache_methods2] for additional information. |
*/ |
typedef struct sqlite3_pcache sqlite3_pcache; |
/* |
+** CAPI3REF: Custom Page Cache Object |
+** |
+** The sqlite3_pcache_page object represents a single page in the |
+** page cache. The page cache will allocate instances of this |
+** object. Various methods of the page cache use pointers to instances |
+** of this object as parameters or as their return value. |
+** |
+** See [sqlite3_pcache_methods2] for additional information. |
+*/ |
+typedef struct sqlite3_pcache_page sqlite3_pcache_page; |
+struct sqlite3_pcache_page { |
+ void *pBuf; /* The content of the page */ |
+ void *pExtra; /* Extra information associated with the page */ |
+}; |
+ |
+/* |
** CAPI3REF: Application Defined Page Cache. |
** KEYWORDS: {page cache} |
** |
-** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can |
+** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can |
** register an alternative page cache implementation by passing in an |
-** instance of the sqlite3_pcache_methods structure.)^ |
+** instance of the sqlite3_pcache_methods2 structure.)^ |
** In many applications, most of the heap memory allocated by |
** SQLite is used for the page cache. |
** By implementing a |
@@ -5722,21 +6585,23 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** extreme measure that is only needed by the most demanding applications. |
** The built-in page cache is recommended for most uses. |
** |
-** ^(The contents of the sqlite3_pcache_methods structure are copied to an |
+** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an |
** internal buffer by SQLite within the call to [sqlite3_config]. Hence |
** the application may discard the parameter after the call to |
** [sqlite3_config()] returns.)^ |
** |
+** [[the xInit() page cache method]] |
** ^(The xInit() method is called once for each effective |
** call to [sqlite3_initialize()])^ |
** (usually only once during the lifetime of the process). ^(The xInit() |
-** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ |
+** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ |
** The intent of the xInit() method is to set up global data structures |
** required by the custom page cache implementation. |
** ^(If the xInit() method is NULL, then the |
** built-in default page cache is used instead of the application defined |
** page cache.)^ |
** |
+** [[the xShutdown() page cache method]] |
** ^The xShutdown() method is called by [sqlite3_shutdown()]. |
** It can be used to clean up |
** any outstanding resources before process shutdown, if required. |
@@ -5751,21 +6616,20 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** ^SQLite will never invoke xInit() more than once without an intervening |
** call to xShutdown(). |
** |
+** [[the xCreate() page cache methods]] |
** ^SQLite invokes the xCreate() method to construct a new cache instance. |
** SQLite will typically create one cache instance for each open database file, |
** though this is not guaranteed. ^The |
** first parameter, szPage, is the size in bytes of the pages that must |
-** be allocated by the cache. ^szPage will not be a power of two. ^szPage |
-** will the page size of the database file that is to be cached plus an |
-** increment (here called "R") of less than 250. SQLite will use the |
-** extra R bytes on each page to store metadata about the underlying |
-** database page on disk. The value of R depends |
+** be allocated by the cache. ^szPage will always a power of two. ^The |
+** second parameter szExtra is a number of bytes of extra storage |
+** associated with each page cache entry. ^The szExtra parameter will |
+** a number less than 250. SQLite will use the |
+** extra szExtra bytes on each page to store metadata about the underlying |
+** database page on disk. The value passed into szExtra depends |
** on the SQLite version, the target platform, and how SQLite was compiled. |
-** ^(R is constant for a particular build of SQLite. Except, there are two |
-** distinct values of R when SQLite is compiled with the proprietary |
-** ZIPVFS extension.)^ ^The second argument to |
-** xCreate(), bPurgeable, is true if the cache being created will |
-** be used to cache database pages of a file stored on disk, or |
+** ^The third argument to xCreate(), bPurgeable, is true if the cache being |
+** created will be used to cache database pages of a file stored on disk, or |
** false if it is used for an in-memory database. The cache implementation |
** does not have to do anything special based with the value of bPurgeable; |
** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will |
@@ -5775,6 +6639,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** ^Hence, a cache created with bPurgeable false will |
** never contain any unpinned pages. |
** |
+** [[the xCachesize() page cache method]] |
** ^(The xCachesize() method may be called at any time by SQLite to set the |
** suggested maximum cache-size (number of pages stored by) the cache |
** instance passed as the first argument. This is the value configured using |
@@ -5782,15 +6647,22 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** parameter, the implementation is not required to do anything with this |
** value; it is advisory only. |
** |
+** [[the xPagecount() page cache methods]] |
** The xPagecount() method must return the number of pages currently |
** stored in the cache, both pinned and unpinned. |
** |
+** [[the xFetch() page cache methods]] |
** The xFetch() method locates a page in the cache and returns a pointer to |
-** the page, or a NULL pointer. |
-** A "page", in this context, means a buffer of szPage bytes aligned at an |
-** 8-byte boundary. The page to be fetched is determined by the key. ^The |
-** mimimum key value is 1. After it has been retrieved using xFetch, the page |
-** is considered to be "pinned". |
+** an sqlite3_pcache_page object associated with that page, or a NULL pointer. |
+** The pBuf element of the returned sqlite3_pcache_page object will be a |
+** pointer to a buffer of szPage bytes used to store the content of a |
+** single database page. The pExtra element of sqlite3_pcache_page will be |
+** a pointer to the szExtra bytes of extra storage that SQLite has requested |
+** for each entry in the page cache. |
+** |
+** The page to be fetched is determined by the key. ^The minimum key value |
+** is 1. After it has been retrieved using xFetch, the page is considered |
+** to be "pinned". |
** |
** If the requested page is already in the page cache, then the page cache |
** implementation must return a pointer to the page buffer with its content |
@@ -5799,7 +6671,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** parameter to help it determined what action to take: |
** |
** <table border=1 width=85% align=center> |
-** <tr><th> createFlag <th> Behaviour when page is not already in cache |
+** <tr><th> createFlag <th> Behavior when page is not already in cache |
** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
** Otherwise return NULL. |
@@ -5813,6 +6685,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** attempt to unpin one or more cache pages by spilling the content of |
** pinned pages to disk and synching the operating system disk cache. |
** |
+** [[the xUnpin() page cache method]] |
** ^xUnpin() is called by SQLite with a pointer to a currently pinned page |
** as its second argument. If the third parameter, discard, is non-zero, |
** then the page must be evicted from the cache. |
@@ -5825,6 +6698,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** call to xUnpin() unpins the page regardless of the number of prior calls |
** to xFetch(). |
** |
+** [[the xRekey() page cache methods]] |
** The xRekey() method is used to change the key value associated with the |
** page passed as the second argument. If the cache |
** previously contains an entry associated with newKey, it must be |
@@ -5837,11 +6711,41 @@ typedef struct sqlite3_pcache sqlite3_pcache; |
** of these pages are pinned, they are implicitly unpinned, meaning that |
** they can be safely discarded. |
** |
+** [[the xDestroy() page cache method]] |
** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
** All resources associated with the specified cache should be freed. ^After |
** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
-** handle invalid, and will not use it with any other sqlite3_pcache_methods |
+** handle invalid, and will not use it with any other sqlite3_pcache_methods2 |
** functions. |
+** |
+** [[the xShrink() page cache method]] |
+** ^SQLite invokes the xShrink() method when it wants the page cache to |
+** free up as much of heap memory as possible. The page cache implementation |
+** is not obligated to free any memory, but well-behaved implementations should |
+** do their best. |
+*/ |
+typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2; |
+struct sqlite3_pcache_methods2 { |
+ int iVersion; |
+ void *pArg; |
+ int (*xInit)(void*); |
+ void (*xShutdown)(void*); |
+ sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable); |
+ void (*xCachesize)(sqlite3_pcache*, int nCachesize); |
+ int (*xPagecount)(sqlite3_pcache*); |
+ sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); |
+ void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard); |
+ void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, |
+ unsigned oldKey, unsigned newKey); |
+ void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); |
+ void (*xDestroy)(sqlite3_pcache*); |
+ void (*xShrink)(sqlite3_pcache*); |
+}; |
+ |
+/* |
+** This is the obsolete pcache_methods object that has now been replaced |
+** by sqlite3_pcache_methods2. This object is not used by SQLite. It is |
+** retained in the header file for backwards compatibility only. |
*/ |
typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; |
struct sqlite3_pcache_methods { |
@@ -5858,6 +6762,7 @@ struct sqlite3_pcache_methods { |
void (*xDestroy)(sqlite3_pcache*); |
}; |
+ |
/* |
** CAPI3REF: Online Backup Object |
** |
@@ -5899,7 +6804,7 @@ typedef struct sqlite3_backup sqlite3_backup; |
** There should be exactly one call to sqlite3_backup_finish() for each |
** successful call to sqlite3_backup_init(). |
** |
-** <b>sqlite3_backup_init()</b> |
+** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b> |
** |
** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the |
** [database connection] associated with the destination database |
@@ -5926,7 +6831,7 @@ typedef struct sqlite3_backup sqlite3_backup; |
** sqlite3_backup_finish() functions to perform the specified backup |
** operation. |
** |
-** <b>sqlite3_backup_step()</b> |
+** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b> |
** |
** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
** the source and destination databases specified by [sqlite3_backup] object B. |
@@ -5983,7 +6888,7 @@ typedef struct sqlite3_backup sqlite3_backup; |
** by the backup operation, then the backup database is automatically |
** updated at the same time. |
** |
-** <b>sqlite3_backup_finish()</b> |
+** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b> |
** |
** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the |
** application wishes to abandon the backup operation, the application |
@@ -6006,7 +6911,8 @@ typedef struct sqlite3_backup sqlite3_backup; |
** is not a permanent error and does not affect the return value of |
** sqlite3_backup_finish(). |
** |
-** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b> |
+** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] |
+** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b> |
** |
** ^Each call to sqlite3_backup_step() sets two values inside |
** the [sqlite3_backup] object: the number of pages still to be backed |
@@ -6186,17 +7092,33 @@ SQLITE_API int sqlite3_unlock_notify( |
/* |
** CAPI3REF: String Comparison |
** |
-** ^The [sqlite3_strnicmp()] API allows applications and extensions to |
-** compare the contents of two buffers containing UTF-8 strings in a |
-** case-independent fashion, using the same definition of case independence |
-** that SQLite uses internally when comparing identifiers. |
+** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications |
+** and extensions to compare the contents of two buffers containing UTF-8 |
+** strings in a case-independent fashion, using the same definition of "case |
+** independence" that SQLite uses internally when comparing identifiers. |
*/ |
+SQLITE_API int sqlite3_stricmp(const char *, const char *); |
SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); |
/* |
+** CAPI3REF: String Globbing |
+* |
+** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches |
+** the glob pattern P, and it returns non-zero if string X does not match |
+** the glob pattern P. ^The definition of glob pattern matching used in |
+** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the |
+** SQL dialect used by SQLite. ^The sqlite3_strglob(P,X) function is case |
+** sensitive. |
+** |
+** Note that this routine returns zero on a match and non-zero if the strings |
+** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. |
+*/ |
+SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr); |
+ |
+/* |
** CAPI3REF: Error Logging Interface |
** |
-** ^The [sqlite3_log()] interface writes a message into the error log |
+** ^The [sqlite3_log()] interface writes a message into the [error log] |
** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. |
** ^If logging is enabled, the zFormat string and subsequent arguments are |
** used with [sqlite3_snprintf()] to generate the final output string. |
@@ -6276,6 +7198,9 @@ SQLITE_API void *sqlite3_wal_hook( |
** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
** from SQL. |
** |
+** ^Checkpoints initiated by this mechanism are |
+** [sqlite3_wal_checkpoint_v2|PASSIVE]. |
+** |
** ^Every new [database connection] defaults to having the auto-checkpoint |
** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] |
** pages. The use of this interface |
@@ -6292,6 +7217,10 @@ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
** empty string, then a checkpoint is run on all databases of |
** connection D. ^If the database connection D is not in |
** [WAL | write-ahead log mode] then this interface is a harmless no-op. |
+** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a |
+** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint. |
+** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL |
+** or RESET checkpoint. |
** |
** ^The [wal_checkpoint pragma] can be used to invoke this interface |
** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the |
@@ -6314,10 +7243,12 @@ SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); |
** Checkpoint as many frames as possible without waiting for any database |
** readers or writers to finish. Sync the db file if all frames in the log |
** are checkpointed. This mode is the same as calling |
-** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. |
+** sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback] |
+** is never invoked. |
** |
** <dt>SQLITE_CHECKPOINT_FULL<dd> |
-** This mode blocks (calls the busy-handler callback) until there is no |
+** This mode blocks (it invokes the |
+** [sqlite3_busy_handler|busy-handler callback]) until there is no |
** database writer and all readers are reading from the most recent database |
** snapshot. It then checkpoints all frames in the log file and syncs the |
** database file. This call blocks database writers while it is running, |
@@ -6325,7 +7256,8 @@ SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb); |
** |
** <dt>SQLITE_CHECKPOINT_RESTART<dd> |
** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after |
-** checkpointing the log file it blocks (calls the busy-handler callback) |
+** checkpointing the log file it blocks (calls the |
+** [sqlite3_busy_handler|busy-handler callback]) |
** until all readers are reading from the database file only. This ensures |
** that the next client to write to the database file restarts the log file |
** from the beginning. This call blocks database writers while it is running, |
@@ -6392,6 +7324,94 @@ SQLITE_API int sqlite3_wal_checkpoint_v2( |
#define SQLITE_CHECKPOINT_FULL 1 |
#define SQLITE_CHECKPOINT_RESTART 2 |
+/* |
+** CAPI3REF: Virtual Table Interface Configuration |
+** |
+** This function may be called by either the [xConnect] or [xCreate] method |
+** of a [virtual table] implementation to configure |
+** various facets of the virtual table interface. |
+** |
+** If this interface is invoked outside the context of an xConnect or |
+** xCreate virtual table method then the behavior is undefined. |
+** |
+** At present, there is only one option that may be configured using |
+** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options |
+** may be added in the future. |
+*/ |
+SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); |
+ |
+/* |
+** CAPI3REF: Virtual Table Configuration Options |
+** |
+** These macros define the various options to the |
+** [sqlite3_vtab_config()] interface that [virtual table] implementations |
+** can use to customize and optimize their behavior. |
+** |
+** <dl> |
+** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT |
+** <dd>Calls of the form |
+** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, |
+** where X is an integer. If X is zero, then the [virtual table] whose |
+** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not |
+** support constraints. In this configuration (which is the default) if |
+** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire |
+** statement is rolled back as if [ON CONFLICT | OR ABORT] had been |
+** specified as part of the users SQL statement, regardless of the actual |
+** ON CONFLICT mode specified. |
+** |
+** If X is non-zero, then the virtual table implementation guarantees |
+** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before |
+** any modifications to internal or persistent data structures have been made. |
+** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite |
+** is able to roll back a statement or database transaction, and abandon |
+** or continue processing the current SQL statement as appropriate. |
+** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns |
+** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode |
+** had been ABORT. |
+** |
+** Virtual table implementations that are required to handle OR REPLACE |
+** must do so within the [xUpdate] method. If a call to the |
+** [sqlite3_vtab_on_conflict()] function indicates that the current ON |
+** CONFLICT policy is REPLACE, the virtual table implementation should |
+** silently replace the appropriate rows within the xUpdate callback and |
+** return SQLITE_OK. Or, if this is not possible, it may return |
+** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT |
+** constraint handling. |
+** </dl> |
+*/ |
+#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 |
+ |
+/* |
+** CAPI3REF: Determine The Virtual Table Conflict Policy |
+** |
+** This function may only be called from within a call to the [xUpdate] method |
+** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The |
+** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], |
+** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode |
+** of the SQL statement that triggered the call to the [xUpdate] method of the |
+** [virtual table]. |
+*/ |
+SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *); |
+ |
+/* |
+** CAPI3REF: Conflict resolution modes |
+** KEYWORDS: {conflict resolution mode} |
+** |
+** These constants are returned by [sqlite3_vtab_on_conflict()] to |
+** inform a [virtual table] implementation what the [ON CONFLICT] mode |
+** is for the SQL statement being evaluated. |
+** |
+** Note that the [SQLITE_IGNORE] constant is also used as a potential |
+** return value from the [sqlite3_set_authorizer()] callback and that |
+** [SQLITE_ABORT] is also a [result code]. |
+*/ |
+#define SQLITE_ROLLBACK 1 |
+/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */ |
+#define SQLITE_FAIL 3 |
+/* #define SQLITE_ABORT 4 // Also an error code */ |
+#define SQLITE_REPLACE 5 |
+ |
+ |
/* Begin recover.patch for Chromium */ |
/* |
@@ -6415,7 +7435,7 @@ int recoverVtableInit(sqlite3 *db); |
#ifdef __cplusplus |
} /* End of the 'extern "C"' block */ |
#endif |
-#endif |
+#endif /* _SQLITE3_H_ */ |
/* |
** 2010 August 30 |
@@ -6439,6 +7459,16 @@ extern "C" { |
#endif |
typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; |
+typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info; |
+ |
+/* The double-precision datatype used by RTree depends on the |
+** SQLITE_RTREE_INT_ONLY compile-time option. |
+*/ |
+#ifdef SQLITE_RTREE_INT_ONLY |
+ typedef sqlite3_int64 sqlite3_rtree_dbl; |
+#else |
+ typedef double sqlite3_rtree_dbl; |
+#endif |
/* |
** Register a geometry callback named zGeom that can be used as part of an |
@@ -6449,7 +7479,7 @@ typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; |
SQLITE_API int sqlite3_rtree_geometry_callback( |
sqlite3 *db, |
const char *zGeom, |
- int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes), |
+ int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*), |
void *pContext |
); |
@@ -6461,11 +7491,60 @@ SQLITE_API int sqlite3_rtree_geometry_callback( |
struct sqlite3_rtree_geometry { |
void *pContext; /* Copy of pContext passed to s_r_g_c() */ |
int nParam; /* Size of array aParam[] */ |
- double *aParam; /* Parameters passed to SQL geom function */ |
+ sqlite3_rtree_dbl *aParam; /* Parameters passed to SQL geom function */ |
void *pUser; /* Callback implementation user data */ |
void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */ |
}; |
+/* |
+** Register a 2nd-generation geometry callback named zScore that can be |
+** used as part of an R-Tree geometry query as follows: |
+** |
+** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...) |
+*/ |
+SQLITE_API int sqlite3_rtree_query_callback( |
+ sqlite3 *db, |
+ const char *zQueryFunc, |
+ int (*xQueryFunc)(sqlite3_rtree_query_info*), |
+ void *pContext, |
+ void (*xDestructor)(void*) |
+); |
+ |
+ |
+/* |
+** A pointer to a structure of the following type is passed as the |
+** argument to scored geometry callback registered using |
+** sqlite3_rtree_query_callback(). |
+** |
+** Note that the first 5 fields of this structure are identical to |
+** sqlite3_rtree_geometry. This structure is a subclass of |
+** sqlite3_rtree_geometry. |
+*/ |
+struct sqlite3_rtree_query_info { |
+ void *pContext; /* pContext from when function registered */ |
+ int nParam; /* Number of function parameters */ |
+ sqlite3_rtree_dbl *aParam; /* value of function parameters */ |
+ void *pUser; /* callback can use this, if desired */ |
+ void (*xDelUser)(void*); /* function to free pUser */ |
+ sqlite3_rtree_dbl *aCoord; /* Coordinates of node or entry to check */ |
+ unsigned int *anQueue; /* Number of pending entries in the queue */ |
+ int nCoord; /* Number of coordinates */ |
+ int iLevel; /* Level of current node or entry */ |
+ int mxLevel; /* The largest iLevel value in the tree */ |
+ sqlite3_int64 iRowid; /* Rowid for current entry */ |
+ sqlite3_rtree_dbl rParentScore; /* Score of parent node */ |
+ int eParentWithin; /* Visibility of parent node */ |
+ int eWithin; /* OUT: Visiblity */ |
+ sqlite3_rtree_dbl rScore; /* OUT: Write the score here */ |
+}; |
+ |
+/* |
+** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin. |
+*/ |
+#define NOT_WITHIN 0 /* Object completely outside of query region */ |
+#define PARTLY_WITHIN 1 /* Object partially overlaps query region */ |
+#define FULLY_WITHIN 2 /* Object fully contained within query region */ |
+ |
#ifdef __cplusplus |
} /* end of the 'extern "C"' block */ |