diff options
Diffstat (limited to 'ext/sqlite3/libsqlite/sqlite3.h')
| -rw-r--r-- | ext/sqlite3/libsqlite/sqlite3.h | 1112 | 
1 files changed, 883 insertions, 229 deletions
diff --git a/ext/sqlite3/libsqlite/sqlite3.h b/ext/sqlite3/libsqlite/sqlite3.h index ed9edbd202..6cf5977b1a 100644 --- a/ext/sqlite3/libsqlite/sqlite3.h +++ b/ext/sqlite3/libsqlite/sqlite3.h @@ -107,9 +107,9 @@ extern "C" {  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],  ** [sqlite_version()] and [sqlite_source_id()].  */ -#define SQLITE_VERSION        "3.7.7.1" -#define SQLITE_VERSION_NUMBER 3007007 -#define SQLITE_SOURCE_ID      "2011-06-28 17:39:05 af0d91adf497f5f36ec3813f04235a6e195a605f" +#define SQLITE_VERSION        "3.8.3.1" +#define SQLITE_VERSION_NUMBER 3008003 +#define SQLITE_SOURCE_ID      "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e"  /*  ** 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 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 but 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. @@ -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. @@ -371,7 +390,7 @@ SQLITE_API int sqlite3_exec(  ** KEYWORDS: {result code} {result codes}  **  ** 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.  ** @@ -406,6 +425,8 @@ 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 */ @@ -426,7 +447,7 @@ SQLITE_API int sqlite3_exec(  ** [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 +** One may expect the number of extended result codes will increase  ** over time.  Software that uses extended result codes should expect  ** to see new result codes in future releases of SQLite.  ** @@ -455,12 +476,36 @@ SQLITE_API int sqlite3_exec(  #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))  /*  ** CAPI3REF: Flags For File Open Operations @@ -476,6 +521,7 @@ SQLITE_API int sqlite3_exec(  #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 */ @@ -495,7 +541,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. @@ -509,7 +555,12 @@ 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.  */  #define SQLITE_IOCAP_ATOMIC                 0x00000001  #define SQLITE_IOCAP_ATOMIC512              0x00000002 @@ -523,6 +574,7 @@ 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  /*  ** CAPI3REF: File Locking Levels @@ -694,6 +746,9 @@ 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 */  }; @@ -711,7 +766,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 @@ -719,6 +775,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  @@ -727,30 +784,188 @@ 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. +** +** </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  /*  ** CAPI3REF: Mutex Handle @@ -805,7 +1020,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;  ** 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, @@ -1178,16 +1393,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 @@ -1201,7 +1410,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 @@ -1342,7 +1551,7 @@ struct sqlite3_mem_methods {  ** <dd> ^This option specifies a static memory buffer that SQLite can use for  ** 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 @@ -1373,8 +1582,8 @@ 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>  **  ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>  ** <dd> ^(This option takes a single argument which is a pointer to an @@ -1411,19 +1620,21 @@ struct sqlite3_mem_methods {  ** verb to [sqlite3_db_config()] can be used to change the lookaside  ** configuration on individual connections.)^ </dd>  ** -** [[SQLITE_CONFIG_PCACHE]] <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>  ** -** [[SQLITE_CONFIG_GETPCACHE]] <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>  **  ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt> -** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a +** <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 @@ -1441,17 +1652,73 @@ struct sqlite3_mem_methods {  ** 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 +** <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 +** 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 +** 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 +** 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_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 */ @@ -1467,10 +1734,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 @@ -1547,19 +1820,21 @@ 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.  ^As of SQLite version 3.7.7, this routines -** records the last insert rowid of both ordinary tables and [virtual tables]. -** ^If no successful [INSERT]s -** have ever occurred on that database connection, zero is returned. +** ^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 @@ -1955,7 +2230,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 @@ -2068,12 +2343,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()] @@ -2125,11 +2400,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.  */ @@ -2289,6 +2566,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 @@ -2304,6 +2582,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 @@ -2329,9 +2610,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 @@ -2474,18 +2756,20 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);  **     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" or -**     "rwc". Attempting to set it to any other value is an error)^.  +**   <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_prepare_v2(). ^If the mode option is set to  +**     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 sqlite3_open_v2() 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 as the third  -**     parameter. +**     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 @@ -2493,7 +2777,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);  **     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 behaviour requested by setting +**     a URI filename, its value overrides any behavior requested by setting  **     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.  ** </ul>  ** @@ -2544,6 +2828,12 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);  ** 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) */ @@ -2563,21 +2853,45 @@ SQLITE_API int sqlite3_open_v2(  /*  ** CAPI3REF: Obtain Values For URI Parameters  ** -** This is a utility routine, useful to VFS implementations, that checks +** 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 the query parameter. -** -** The zFilename argument is the filename pointer passed into the xOpen() -** method of a VFS implementation.  The zParam argument is the name of the -** query parameter we seek.  This routine returns the value of the zParam -** parameter if it exists.  If the parameter does not exist, this routine -** returns a NULL pointer. -** -** If the zFilename argument to this function is not a pointer that SQLite -** passed into the xOpen VFS method, then the behavior of this routine -** is undefined and probably undesirable. +** 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);  /* @@ -2599,6 +2913,11 @@ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *  ** 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. @@ -2617,6 +2936,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 @@ -2773,7 +3093,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 @@ -2803,7 +3124,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> @@ -2824,8 +3146,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>  */ @@ -2899,6 +3220,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}  ** @@ -2988,12 +3328,25 @@ 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. +** 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() 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 sqlite3_bind_blob(), sqlite3_bind_text(), and  ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or @@ -3327,6 +3680,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()]  */ @@ -3426,7 +3785,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 @@ -3449,19 +3808,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>)^ @@ -3517,7 +3876,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 @@ -3626,15 +3985,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()].)^ @@ -3720,10 +4088,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  ** @@ -3739,7 +4117,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  /* @@ -3819,14 +4198,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. @@ -3869,41 +4251,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. @@ -3924,7 +4314,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) @@ -3977,11 +4367,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 @@ -4006,7 +4396,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 @@ -4203,6 +4598,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 @@ -4216,6 +4616,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  @@ -4283,10 +4688,62 @@ 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. +** +** <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}  ** @@ -4322,6 +4779,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 @@ -4356,13 +4838,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.  ** @@ -4388,12 +4872,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], @@ -4406,6 +4891,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 @@ -4437,7 +4923,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] @@ -4460,6 +4945,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); @@ -4475,10 +4963,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 @@ -4492,7 +4995,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. @@ -4508,7 +5012,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. @@ -4621,11 +5125,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 @@ -4651,11 +5164,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. @@ -4667,7 +5180,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 @@ -4695,11 +5208,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 @@ -4823,10 +5349,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 */ @@ -4851,7 +5389,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 */  };  /* @@ -5055,6 +5595,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 @@ -5249,17 +5792,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 @@ -5448,7 +5990,7 @@ 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. @@ -5576,10 +6118,11 @@ 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_LOCALTIME_FAULT         19 -#define SQLITE_TESTCTRL_LAST                    19 +#define SQLITE_TESTCTRL_SCRATCHMALLOC           17 +#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18 +#define SQLITE_TESTCTRL_EXPLAIN_STMT            19 +#define SQLITE_TESTCTRL_NEVER_CORRUPT           20 +#define SQLITE_TESTCTRL_LAST                    20  /*  ** CAPI3REF: SQLite Runtime Status @@ -5789,6 +6332,35 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r  ** 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 @@ -5798,7 +6370,11 @@ 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 */  /* @@ -5853,11 +6429,20 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);  ** 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 @@ -5868,17 +6453,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  @@ -5892,7 +6493,7 @@ 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.)^ @@ -5901,7 +6502,7 @@ typedef struct sqlite3_pcache sqlite3_pcache;  ** ^(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  @@ -5928,17 +6529,15 @@ typedef struct sqlite3_pcache sqlite3_pcache;  ** 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 @@ -5962,11 +6561,16 @@ typedef struct sqlite3_pcache sqlite3_pcache;  **   ** [[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 -** minimum 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 @@ -5975,7 +6579,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. @@ -6019,8 +6623,37 @@ typedef struct sqlite3_pcache sqlite3_pcache;  ** ^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 { @@ -6037,6 +6670,7 @@ struct sqlite3_pcache_methods {    void (*xDestroy)(sqlite3_pcache*);  }; +  /*  ** CAPI3REF: Online Backup Object  ** @@ -6366,17 +7000,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. @@ -6671,7 +7321,7 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);  #ifdef __cplusplus  }  /* End of the 'extern "C"' block */  #endif -#endif +#endif /* _SQLITE3_H_ */  /*  ** 2010 August 30 @@ -6705,7 +7355,11 @@ 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), +#ifdef SQLITE_RTREE_INT_ONLY +  int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes), +#else +  int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes), +#endif    void *pContext  );  | 
