extralite-bundle 2.13 → 2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -146,9 +146,12 @@ extern "C" {
146
146
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
147
  ** [sqlite_version()] and [sqlite_source_id()].
148
148
  */
149
- #define SQLITE_VERSION "3.50.4"
150
- #define SQLITE_VERSION_NUMBER 3050004
151
- #define SQLITE_SOURCE_ID "2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45e20a3"
149
+ #define SQLITE_VERSION "3.53.3"
150
+ #define SQLITE_VERSION_NUMBER 3053003
151
+ #define SQLITE_SOURCE_ID "2026-06-26 20:14:12 d4c0e51e4aeb96955b99185ab9cde75c339e2c29c3f3f12428d364a10d782c62"
152
+ #define SQLITE_SCM_BRANCH "branch-3.53"
153
+ #define SQLITE_SCM_TAGS "release version-3.53.3"
154
+ #define SQLITE_SCM_DATETIME "2026-06-26T20:14:12.354Z"
152
155
 
153
156
  /*
154
157
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -168,9 +171,9 @@ extern "C" {
168
171
  ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
169
172
  ** </pre></blockquote>)^
170
173
  **
171
- ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
172
- ** macro. ^The sqlite3_libversion() function returns a pointer to the
173
- ** to the sqlite3_version[] string constant. The sqlite3_libversion()
174
+ ** ^The sqlite3_version[] string constant contains the text of the
175
+ ** [SQLITE_VERSION] macro. ^The sqlite3_libversion() function returns a
176
+ ** pointer to the sqlite3_version[] string constant. The sqlite3_libversion()
174
177
  ** function is provided for use in DLLs since DLL users usually do not have
175
178
  ** direct access to string constants within the DLL. ^The
176
179
  ** sqlite3_libversion_number() function returns an integer equal to
@@ -370,7 +373,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
370
373
  ** without having to use a lot of C code.
371
374
  **
372
375
  ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
373
- ** semicolon-separate SQL statements passed into its 2nd argument,
376
+ ** semicolon-separated SQL statements passed into its 2nd argument,
374
377
  ** in the context of the [database connection] passed in as its 1st
375
378
  ** argument. ^If the callback function of the 3rd argument to
376
379
  ** sqlite3_exec() is not NULL, then it is invoked for each result row
@@ -403,7 +406,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
403
406
  ** result row is NULL then the corresponding string pointer for the
404
407
  ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
405
408
  ** sqlite3_exec() callback is an array of pointers to strings where each
406
- ** entry represents the name of corresponding result column as obtained
409
+ ** entry represents the name of a corresponding result column as obtained
407
410
  ** from [sqlite3_column_name()].
408
411
  **
409
412
  ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
@@ -497,6 +500,9 @@ SQLITE_API int sqlite3_exec(
497
500
  #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
498
501
  #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
499
502
  #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
503
+ #define SQLITE_ERROR_RESERVESIZE (SQLITE_ERROR | (4<<8))
504
+ #define SQLITE_ERROR_KEY (SQLITE_ERROR | (5<<8))
505
+ #define SQLITE_ERROR_UNABLE (SQLITE_ERROR | (6<<8))
500
506
  #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
501
507
  #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
502
508
  #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
@@ -531,6 +537,8 @@ SQLITE_API int sqlite3_exec(
531
537
  #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
532
538
  #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
533
539
  #define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
540
+ #define SQLITE_IOERR_BADKEY (SQLITE_IOERR | (35<<8))
541
+ #define SQLITE_IOERR_CODEC (SQLITE_IOERR | (36<<8))
534
542
  #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
535
543
  #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
536
544
  #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
@@ -570,7 +578,7 @@ SQLITE_API int sqlite3_exec(
570
578
  #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
571
579
  #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
572
580
  #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
573
- #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
581
+ #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal only */
574
582
 
575
583
  /*
576
584
  ** CAPI3REF: Flags For File Open Operations
@@ -589,7 +597,7 @@ SQLITE_API int sqlite3_exec(
589
597
  ** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into
590
598
  ** [sqlite3_open_v2()] does *not* cause the underlying database file
591
599
  ** to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into
592
- ** [sqlite3_open_v2()] has historically be a no-op and might become an
600
+ ** [sqlite3_open_v2()] has historically been a no-op and might become an
593
601
  ** error in future versions of SQLite.
594
602
  */
595
603
  #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
@@ -683,7 +691,7 @@ SQLITE_API int sqlite3_exec(
683
691
  ** SQLite uses one of these integer values as the second
684
692
  ** argument to calls it makes to the xLock() and xUnlock() methods
685
693
  ** of an [sqlite3_io_methods] object. These values are ordered from
686
- ** lest restrictive to most restrictive.
694
+ ** least restrictive to most restrictive.
687
695
  **
688
696
  ** The argument to xLock() is always SHARED or higher. The argument to
689
697
  ** xUnlock is either SHARED or NONE.
@@ -924,7 +932,7 @@ struct sqlite3_io_methods {
924
932
  ** connection. See also [SQLITE_FCNTL_FILE_POINTER].
925
933
  **
926
934
  ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
927
- ** No longer in use.
935
+ ** The SQLITE_FCNTL_SYNC_OMITTED file-control is no longer used.
928
936
  **
929
937
  ** <li>[[SQLITE_FCNTL_SYNC]]
930
938
  ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
@@ -999,7 +1007,7 @@ struct sqlite3_io_methods {
999
1007
  **
1000
1008
  ** <li>[[SQLITE_FCNTL_VFSNAME]]
1001
1009
  ** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
1002
- ** all [VFSes] in the VFS stack. The names are of all VFS shims and the
1010
+ ** all [VFSes] in the VFS stack. The names of all VFS shims and the
1003
1011
  ** final bottom-level VFS are written into memory obtained from
1004
1012
  ** [sqlite3_malloc()] and the result is stored in the char* variable
1005
1013
  ** that the fourth parameter of [sqlite3_file_control()] points to.
@@ -1013,7 +1021,7 @@ struct sqlite3_io_methods {
1013
1021
  ** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
1014
1022
  ** [VFSes] currently in use. ^(The argument X in
1015
1023
  ** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
1016
- ** of type "[sqlite3_vfs] **". This opcodes will set *X
1024
+ ** of type "[sqlite3_vfs] **". This opcode will set *X
1017
1025
  ** to a pointer to the top-level VFS.)^
1018
1026
  ** ^When there are multiple VFS shims in the stack, this opcode finds the
1019
1027
  ** upper-most shim only.
@@ -1203,7 +1211,7 @@ struct sqlite3_io_methods {
1203
1211
  ** <li>[[SQLITE_FCNTL_EXTERNAL_READER]]
1204
1212
  ** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect
1205
1213
  ** whether or not there is a database client in another process with a wal-mode
1206
- ** transaction open on the database or not. It is only available on unix.The
1214
+ ** transaction open on the database or not. It is only available on unix. The
1207
1215
  ** (void*) argument passed with this file-control should be a pointer to a
1208
1216
  ** value of type (int). The integer value is set to 1 if the database is a wal
1209
1217
  ** mode database and there exists at least one client in another process that
@@ -1221,6 +1229,15 @@ struct sqlite3_io_methods {
1221
1229
  ** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control
1222
1230
  ** purges the contents of the in-memory page cache. If there is an open
1223
1231
  ** transaction, or if the db is a temp-db, this opcode is a no-op, not an error.
1232
+ **
1233
+ ** <li>[[SQLITE_FCNTL_FILESTAT]]
1234
+ ** The [SQLITE_FCNTL_FILESTAT] opcode returns low-level diagnostic information
1235
+ ** about the [sqlite3_file] objects used access the database and journal files
1236
+ ** for the given schema. The fourth parameter to [sqlite3_file_control()]
1237
+ ** should be an initialized [sqlite3_str] pointer. JSON text describing
1238
+ ** various aspects of the sqlite3_file object is appended to the sqlite3_str.
1239
+ ** The SQLITE_FCNTL_FILESTAT opcode is usually a no-op, unless compile-time
1240
+ ** options are used to enable it.
1224
1241
  ** </ul>
1225
1242
  */
1226
1243
  #define SQLITE_FCNTL_LOCKSTATE 1
@@ -1266,12 +1283,19 @@ struct sqlite3_io_methods {
1266
1283
  #define SQLITE_FCNTL_RESET_CACHE 42
1267
1284
  #define SQLITE_FCNTL_NULL_IO 43
1268
1285
  #define SQLITE_FCNTL_BLOCK_ON_CONNECT 44
1286
+ #define SQLITE_FCNTL_FILESTAT 45
1269
1287
 
1270
1288
  /* deprecated names */
1271
1289
  #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1272
1290
  #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1273
1291
  #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
1274
1292
 
1293
+ /* reserved file-control numbers:
1294
+ ** 101
1295
+ ** 102
1296
+ ** 103
1297
+ */
1298
+
1275
1299
 
1276
1300
  /*
1277
1301
  ** CAPI3REF: Mutex Handle
@@ -1472,7 +1496,7 @@ typedef const char *sqlite3_filename;
1472
1496
  ** greater and the function pointer is not NULL) and will fall back
1473
1497
  ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
1474
1498
  **
1475
- ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
1499
+ ** ^The xSetSystemCall(), xGetSystemCall(), and xNextSystemCall() interfaces
1476
1500
  ** are not used by the SQLite core. These optional interfaces are provided
1477
1501
  ** by some VFSes to facilitate testing of the VFS code. By overriding
1478
1502
  ** system calls with functions under its control, a test program can
@@ -1628,7 +1652,7 @@ struct sqlite3_vfs {
1628
1652
  ** SQLite interfaces so that an application usually does not need to
1629
1653
  ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
1630
1654
  ** calls sqlite3_initialize() so the SQLite library will be automatically
1631
- ** initialized when [sqlite3_open()] is called if it has not be initialized
1655
+ ** initialized when [sqlite3_open()] is called if it has not been initialized
1632
1656
  ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
1633
1657
  ** compile-time option, then the automatic calls to sqlite3_initialize()
1634
1658
  ** are omitted and the application must call sqlite3_initialize() directly
@@ -1693,7 +1717,8 @@ SQLITE_API int sqlite3_os_end(void);
1693
1717
  ** are called "anytime configuration options".
1694
1718
  ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1695
1719
  ** [sqlite3_shutdown()] with a first argument that is not an anytime
1696
- ** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
1720
+ ** configuration option, then the sqlite3_config() call will
1721
+ ** return SQLITE_MISUSE.
1697
1722
  ** Note, however, that ^sqlite3_config() can be called as part of the
1698
1723
  ** implementation of an application-defined [sqlite3_os_init()].
1699
1724
  **
@@ -1885,21 +1910,21 @@ struct sqlite3_mem_methods {
1885
1910
  ** The [sqlite3_mem_methods]
1886
1911
  ** structure is filled with the currently defined memory allocation routines.)^
1887
1912
  ** This option can be used to overload the default memory allocation
1888
- ** routines with a wrapper that simulations memory allocation failure or
1913
+ ** routines with a wrapper that simulates memory allocation failure or
1889
1914
  ** tracks memory usage, for example. </dd>
1890
1915
  **
1891
1916
  ** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>
1892
- ** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of
1917
+ ** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes a single argument of
1893
1918
  ** type int, interpreted as a boolean, which if true provides a hint to
1894
1919
  ** SQLite that it should avoid large memory allocations if possible.
1895
1920
  ** SQLite will run faster if it is free to make large memory allocations,
1896
- ** but some application might prefer to run slower in exchange for
1921
+ ** but some applications might prefer to run slower in exchange for
1897
1922
  ** guarantees about memory fragmentation that are possible if large
1898
1923
  ** allocations are avoided. This hint is normally off.
1899
1924
  ** </dd>
1900
1925
  **
1901
1926
  ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1902
- ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
1927
+ ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes a single argument of type int,
1903
1928
  ** interpreted as a boolean, which enables or disables the collection of
1904
1929
  ** memory allocation statistics. ^(When memory allocation statistics are
1905
1930
  ** disabled, the following SQLite interfaces become non-operational:
@@ -1944,7 +1969,7 @@ struct sqlite3_mem_methods {
1944
1969
  ** ^If pMem is NULL and N is non-zero, then each database connection
1945
1970
  ** does an initial bulk allocation for page cache memory
1946
1971
  ** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
1947
- ** of -1024*N bytes if N is negative, . ^If additional
1972
+ ** of -1024*N bytes if N is negative. ^If additional
1948
1973
  ** page cache memory is needed beyond what is provided by the initial
1949
1974
  ** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
1950
1975
  ** additional cache line. </dd>
@@ -1973,7 +1998,7 @@ struct sqlite3_mem_methods {
1973
1998
  ** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
1974
1999
  ** pointer to an instance of the [sqlite3_mutex_methods] structure.
1975
2000
  ** The argument specifies alternative low-level mutex routines to be used
1976
- ** in place the mutex routines built into SQLite.)^ ^SQLite makes a copy of
2001
+ ** in place of the mutex routines built into SQLite.)^ ^SQLite makes a copy of
1977
2002
  ** the content of the [sqlite3_mutex_methods] structure before the call to
1978
2003
  ** [sqlite3_config()] returns. ^If SQLite is compiled with
1979
2004
  ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
@@ -2015,7 +2040,7 @@ struct sqlite3_mem_methods {
2015
2040
  **
2016
2041
  ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
2017
2042
  ** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
2018
- ** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of
2043
+ ** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies off
2019
2044
  ** the current page cache implementation into that object.)^ </dd>
2020
2045
  **
2021
2046
  ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
@@ -2032,7 +2057,7 @@ struct sqlite3_mem_methods {
2032
2057
  ** the logger function is a copy of the first parameter to the corresponding
2033
2058
  ** [sqlite3_log()] call and is intended to be a [result code] or an
2034
2059
  ** [extended result code]. ^The third parameter passed to the logger is
2035
- ** log message after formatting via [sqlite3_snprintf()].
2060
+ ** a log message after formatting via [sqlite3_snprintf()].
2036
2061
  ** The SQLite logging interface is not reentrant; the logger function
2037
2062
  ** supplied by the application must not invoke any SQLite interface.
2038
2063
  ** In a multi-threaded application, the application-defined logger
@@ -2223,7 +2248,7 @@ struct sqlite3_mem_methods {
2223
2248
  ** These constants are the available integer configuration options that
2224
2249
  ** can be passed as the second parameter to the [sqlite3_db_config()] interface.
2225
2250
  **
2226
- ** The [sqlite3_db_config()] interface is a var-args functions. It takes a
2251
+ ** The [sqlite3_db_config()] interface is a var-args function. It takes a
2227
2252
  ** variable number of parameters, though always at least two. The number of
2228
2253
  ** parameters passed into sqlite3_db_config() depends on which of these
2229
2254
  ** constants is given as the second parameter. This documentation page
@@ -2259,9 +2284,10 @@ struct sqlite3_mem_methods {
2259
2284
  ** is less than 8. The "sz" argument should be a multiple of 8 less than
2260
2285
  ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2261
2286
  ** it does.
2262
- ** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2263
- ** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2264
- ** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2287
+ ** <li><p>The third argument ("cnt") is the number of slots.
2288
+ ** Lookaside is disabled if "cnt"is less than 1.
2289
+ * The "cnt" value will be reduced, if necessary, so
2290
+ ** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2265
2291
  ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2266
2292
  ** than 1,000,000.
2267
2293
  ** </ol>
@@ -2335,17 +2361,20 @@ struct sqlite3_mem_methods {
2335
2361
  **
2336
2362
  ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2337
2363
  ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2338
- ** <dd> ^This option is used to enable or disable the
2339
- ** [fts3_tokenizer()] function which is part of the
2340
- ** [FTS3] full-text search engine extension.
2341
- ** There must be two additional arguments.
2342
- ** The first argument is an integer which is 0 to disable fts3_tokenizer() or
2343
- ** positive to enable fts3_tokenizer() or negative to leave the setting
2344
- ** unchanged.
2345
- ** The second parameter is a pointer to an integer into which
2346
- ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
2347
- ** following this call. The second parameter may be a NULL pointer, in
2348
- ** which case the new setting is not reported back. </dd>
2364
+ ** <dd> ^This option is used to enable or disable using the
2365
+ ** [fts3_tokenizer()] function - part of the [FTS3] full-text search engine
2366
+ ** extension - without using bound parameters as the parameters. Doing so
2367
+ ** is disabled by default. There must be two additional arguments. The first
2368
+ ** argument is an integer. If it is passed 0, then using fts3_tokenizer()
2369
+ ** without bound parameters is disabled. If it is passed a positive value,
2370
+ ** then calling fts3_tokenizer without bound parameters is enabled. If it
2371
+ ** is passed a negative value, this setting is not modified - this can be
2372
+ ** used to query for the current setting. The second parameter is a pointer
2373
+ ** to an integer into which is written 0 or 1 to indicate the current value
2374
+ ** of this setting (after it is modified, if applicable). The second
2375
+ ** parameter may be a NULL pointer, in which case the value of the setting
2376
+ ** is not reported back. Refer to [FTS3] documentation for further details.
2377
+ ** </dd>
2349
2378
  **
2350
2379
  ** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]]
2351
2380
  ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
@@ -2357,8 +2386,8 @@ struct sqlite3_mem_methods {
2357
2386
  ** When the first argument to this interface is 1, then only the C-API is
2358
2387
  ** enabled and the SQL function remains disabled. If the first argument to
2359
2388
  ** this interface is 0, then both the C-API and the SQL function are disabled.
2360
- ** If the first argument is -1, then no changes are made to state of either the
2361
- ** C-API or the SQL function.
2389
+ ** If the first argument is -1, then no changes are made to the state of either
2390
+ ** the C-API or the SQL function.
2362
2391
  ** The second parameter is a pointer to an integer into which
2363
2392
  ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
2364
2393
  ** is disabled or enabled following this call. The second parameter may
@@ -2476,7 +2505,7 @@ struct sqlite3_mem_methods {
2476
2505
  ** [[SQLITE_DBCONFIG_LEGACY_ALTER_TABLE]]
2477
2506
  ** <dt>SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</dt>
2478
2507
  ** <dd>The SQLITE_DBCONFIG_LEGACY_ALTER_TABLE option activates or deactivates
2479
- ** the legacy behavior of the [ALTER TABLE RENAME] command such it
2508
+ ** the legacy behavior of the [ALTER TABLE RENAME] command such that it
2480
2509
  ** behaves as it did prior to [version 3.24.0] (2018-06-04). See the
2481
2510
  ** "Compatibility Notice" on the [ALTER TABLE RENAME documentation] for
2482
2511
  ** additional information. This feature can also be turned on and off
@@ -2525,7 +2554,7 @@ struct sqlite3_mem_methods {
2525
2554
  ** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</dt>
2526
2555
  ** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates
2527
2556
  ** the legacy file format flag. When activated, this flag causes all newly
2528
- ** created database file to have a schema format version number (the 4-byte
2557
+ ** created database files to have a schema format version number (the 4-byte
2529
2558
  ** integer found at offset 44 into the database header) of 1. This in turn
2530
2559
  ** means that the resulting database file will be readable and writable by
2531
2560
  ** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting,
@@ -2546,13 +2575,16 @@ struct sqlite3_mem_methods {
2546
2575
  ** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]]
2547
2576
  ** <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</dt>
2548
2577
  ** <dd>The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in
2549
- ** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2550
- ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2551
- ** statistics. For statistics to be collected, the flag must be set on
2552
- ** the database handle both when the SQL statement is prepared and when it
2553
- ** is stepped. The flag is set (collection of statistics is enabled)
2554
- ** by default. <p>This option takes two arguments: an integer and a pointer to
2555
- ** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2578
+ ** [SQLITE_ENABLE_STMT_SCANSTATUS] builds. In this case, it sets or clears
2579
+ ** a flag that enables collection of run-time performance statistics
2580
+ ** used by [sqlite3_stmt_scanstatus_v2()] and the [nexec and ncycle]
2581
+ ** columns of the [bytecode virtual table].
2582
+ ** For statistics to be collected, the flag must be set on
2583
+ ** the database handle both when the SQL statement is
2584
+ ** [sqlite3_prepare|prepared] and when it is [sqlite3_step|stepped].
2585
+ ** The flag is set (collection of statistics is enabled) by default.
2586
+ ** <p>This option takes two arguments: an integer and a pointer to
2587
+ ** an integer. The first argument is 1, 0, or -1 to enable, disable, or
2556
2588
  ** leave unchanged the statement scanstatus option. If the second argument
2557
2589
  ** is not NULL, then the value of the statement scanstatus setting after
2558
2590
  ** processing the first argument is written into the integer that the second
@@ -2595,8 +2627,8 @@ struct sqlite3_mem_methods {
2595
2627
  ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
2596
2628
  ** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
2597
2629
  ** This capability is enabled by default. Applications can disable or
2598
- ** reenable this capability using the current DBCONFIG option. If the
2599
- ** the this capability is disabled, the [ATTACH] command will still work,
2630
+ ** reenable this capability using the current DBCONFIG option. If
2631
+ ** this capability is disabled, the [ATTACH] command will still work,
2600
2632
  ** but the database will be opened read-only. If this option is disabled,
2601
2633
  ** then the ability to create a new database using [ATTACH] is also disabled,
2602
2634
  ** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
@@ -2624,16 +2656,34 @@ struct sqlite3_mem_methods {
2624
2656
  ** comments are allowed in SQL text after processing the first argument.
2625
2657
  ** </dd>
2626
2658
  **
2659
+ ** [[SQLITE_DBCONFIG_FP_DIGITS]]
2660
+ ** <dt>SQLITE_DBCONFIG_FP_DIGITS</dt>
2661
+ ** <dd>The SQLITE_DBCONFIG_FP_DIGITS setting is a small integer that determines
2662
+ ** the number of significant digits that SQLite will attempt to preserve when
2663
+ ** converting floating point numbers (IEEE 754 "doubles") into text. The
2664
+ ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2665
+ ** prior versions.<p>
2666
+ ** This option takes two arguments which are an integer and a pointer
2667
+ ** to an integer. The first argument is a small integer, between 3 and 23, or
2668
+ ** zero. The FP_DIGITS setting is changed to that small integer, or left
2669
+ ** unaltered if the first argument is zero or out of range. The second argument
2670
+ ** is a pointer to an integer. If the pointer is not NULL, then the value of
2671
+ ** the FP_DIGITS setting, after possibly being modified by the first
2672
+ ** arguments, is written into the integer to which the second argument points.
2673
+ ** </dd>
2674
+ **
2627
2675
  ** </dl>
2628
2676
  **
2629
2677
  ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2630
2678
  **
2631
2679
  ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2632
2680
  ** overall call to [sqlite3_db_config()] has a total of four parameters.
2633
- ** The first argument (the third parameter to sqlite3_db_config()) is a integer.
2634
- ** The second argument is a pointer to an integer. If the first argument is 1,
2635
- ** then the option becomes enabled. If the first integer argument is 0, then the
2636
- ** option is disabled. If the first argument is -1, then the option setting
2681
+ ** The first argument (the third parameter to sqlite3_db_config()) is
2682
+ ** an integer.
2683
+ ** The second argument is a pointer to an integer. If the first argument is 1,
2684
+ ** then the option becomes enabled. If the first integer argument is 0,
2685
+ ** then the option is disabled.
2686
+ ** If the first argument is -1, then the option setting
2637
2687
  ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2638
2688
  ** If the second argument is not NULL, then a value of 0 or 1 is written into
2639
2689
  ** the integer to which the second argument points, depending on whether the
@@ -2641,9 +2691,10 @@ struct sqlite3_mem_methods {
2641
2691
  ** the first argument.
2642
2692
  **
2643
2693
  ** <p>While most SQLITE_DBCONFIG options use the argument format
2644
- ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2645
- ** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2646
- ** documentation of those exceptional options for details.
2694
+ ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME],
2695
+ ** [SQLITE_DBCONFIG_LOOKASIDE], and [SQLITE_DBCONFIG_FP_DIGITS] options
2696
+ ** are different. See the documentation of those exceptional options for
2697
+ ** details.
2647
2698
  */
2648
2699
  #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2649
2700
  #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -2668,7 +2719,8 @@ struct sqlite3_mem_methods {
2668
2719
  #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2669
2720
  #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2670
2721
  #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2671
- #define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
2722
+ #define SQLITE_DBCONFIG_FP_DIGITS 1023 /* int int* */
2723
+ #define SQLITE_DBCONFIG_MAX 1023 /* Largest DBCONFIG */
2672
2724
 
2673
2725
  /*
2674
2726
  ** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -2920,7 +2972,7 @@ SQLITE_API int sqlite3_is_interrupted(sqlite3*);
2920
2972
  ** ^These routines return 0 if the statement is incomplete. ^If a
2921
2973
  ** memory allocation fails, then SQLITE_NOMEM is returned.
2922
2974
  **
2923
- ** ^These routines do not parse the SQL statements thus
2975
+ ** ^These routines do not parse the SQL statements and thus
2924
2976
  ** will not detect syntactically incorrect SQL.
2925
2977
  **
2926
2978
  ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
@@ -3037,7 +3089,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
3037
3089
  ** indefinitely if possible. The results of passing any other negative value
3038
3090
  ** are undefined.
3039
3091
  **
3040
- ** Internally, each SQLite database handle store two timeout values - the
3092
+ ** Internally, each SQLite database handle stores two timeout values - the
3041
3093
  ** busy-timeout (used for rollback mode databases, or if the VFS does not
3042
3094
  ** support blocking locks) and the setlk-timeout (used for blocking locks
3043
3095
  ** on wal-mode databases). The sqlite3_busy_timeout() method sets both
@@ -3067,7 +3119,7 @@ SQLITE_API int sqlite3_setlk_timeout(sqlite3*, int ms, int flags);
3067
3119
  ** This is a legacy interface that is preserved for backwards compatibility.
3068
3120
  ** Use of this interface is not recommended.
3069
3121
  **
3070
- ** Definition: A <b>result table</b> is memory data structure created by the
3122
+ ** Definition: A <b>result table</b> is a memory data structure created by the
3071
3123
  ** [sqlite3_get_table()] interface. A result table records the
3072
3124
  ** complete query results from one or more queries.
3073
3125
  **
@@ -3210,7 +3262,7 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
3210
3262
  ** ^Calling sqlite3_free() with a pointer previously returned
3211
3263
  ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
3212
3264
  ** that it might be reused. ^The sqlite3_free() routine is
3213
- ** a no-op if is called with a NULL pointer. Passing a NULL pointer
3265
+ ** a no-op if it is called with a NULL pointer. Passing a NULL pointer
3214
3266
  ** to sqlite3_free() is harmless. After being freed, memory
3215
3267
  ** should neither be read nor written. Even reading previously freed
3216
3268
  ** memory might result in a segmentation fault or other severe error.
@@ -3228,13 +3280,13 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
3228
3280
  ** sqlite3_free(X).
3229
3281
  ** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation
3230
3282
  ** of at least N bytes in size or NULL if insufficient memory is available.
3231
- ** ^If M is the size of the prior allocation, then min(N,M) bytes
3232
- ** of the prior allocation are copied into the beginning of buffer returned
3283
+ ** ^If M is the size of the prior allocation, then min(N,M) bytes of the
3284
+ ** prior allocation are copied into the beginning of the buffer returned
3233
3285
  ** by sqlite3_realloc(X,N) and the prior allocation is freed.
3234
3286
  ** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the
3235
3287
  ** prior allocation is not freed.
3236
3288
  **
3237
- ** ^The sqlite3_realloc64(X,N) interfaces works the same as
3289
+ ** ^The sqlite3_realloc64(X,N) interface works the same as
3238
3290
  ** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
3239
3291
  ** of a 32-bit signed integer.
3240
3292
  **
@@ -3284,7 +3336,7 @@ SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
3284
3336
  ** was last reset. ^The values returned by [sqlite3_memory_used()] and
3285
3337
  ** [sqlite3_memory_highwater()] include any overhead
3286
3338
  ** added by SQLite in its implementation of [sqlite3_malloc()],
3287
- ** but not overhead added by the any underlying system library
3339
+ ** but not overhead added by any underlying system library
3288
3340
  ** routines that [sqlite3_malloc()] may call.
3289
3341
  **
3290
3342
  ** ^The memory high-water mark is reset to the current value of
@@ -3736,7 +3788,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3736
3788
  ** there is no harm in trying.)
3737
3789
  **
3738
3790
  ** ^(<dt>[SQLITE_OPEN_SHAREDCACHE]</dt>
3739
- ** <dd>The database is opened [shared cache] enabled, overriding
3791
+ ** <dd>The database is opened with [shared cache] enabled, overriding
3740
3792
  ** the default shared cache setting provided by
3741
3793
  ** [sqlite3_enable_shared_cache()].)^
3742
3794
  ** The [use of shared cache mode is discouraged] and hence shared cache
@@ -3744,7 +3796,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3744
3796
  ** this option is a no-op.
3745
3797
  **
3746
3798
  ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt>
3747
- ** <dd>The database is opened [shared cache] disabled, overriding
3799
+ ** <dd>The database is opened with [shared cache] disabled, overriding
3748
3800
  ** the default shared cache setting provided by
3749
3801
  ** [sqlite3_enable_shared_cache()].)^
3750
3802
  **
@@ -4150,6 +4202,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
4150
4202
  ** <li> sqlite3_errmsg()
4151
4203
  ** <li> sqlite3_errmsg16()
4152
4204
  ** <li> sqlite3_error_offset()
4205
+ ** <li> sqlite3_db_handle()
4153
4206
  ** </ul>
4154
4207
  **
4155
4208
  ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -4162,7 +4215,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
4162
4215
  ** subsequent calls to other SQLite interface functions.)^
4163
4216
  **
4164
4217
  ** ^The sqlite3_errstr(E) interface returns the English-language text
4165
- ** that describes the [result code] E, as UTF-8, or NULL if E is not an
4218
+ ** that describes the [result code] E, as UTF-8, or NULL if E is not a
4166
4219
  ** result code for which a text error message is available.
4167
4220
  ** ^(Memory to hold the error message string is managed internally
4168
4221
  ** and must not be freed by the application)^.
@@ -4170,7 +4223,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
4170
4223
  ** ^If the most recent error references a specific token in the input
4171
4224
  ** SQL, the sqlite3_error_offset() interface returns the byte offset
4172
4225
  ** of the start of that token. ^The byte offset returned by
4173
- ** sqlite3_error_offset() assumes that the input SQL is UTF8.
4226
+ ** sqlite3_error_offset() assumes that the input SQL is UTF-8.
4174
4227
  ** ^If the most recent error does not reference a specific token in the input
4175
4228
  ** SQL, then the sqlite3_error_offset() function returns -1.
4176
4229
  **
@@ -4195,6 +4248,34 @@ SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
4195
4248
  SQLITE_API const char *sqlite3_errstr(int);
4196
4249
  SQLITE_API int sqlite3_error_offset(sqlite3 *db);
4197
4250
 
4251
+ /*
4252
+ ** CAPI3REF: Set Error Code And Message
4253
+ ** METHOD: sqlite3
4254
+ **
4255
+ ** Set the error code of the database handle passed as the first argument
4256
+ ** to errcode, and the error message to a copy of nul-terminated string
4257
+ ** zErrMsg. If zErrMsg is passed NULL, then the error message is set to
4258
+ ** the default message associated with the supplied error code. Subsequent
4259
+ ** calls to [sqlite3_errcode()] and [sqlite3_errmsg()] and similar will
4260
+ ** return the values set by this routine in place of what was previously
4261
+ ** set by SQLite itself.
4262
+ **
4263
+ ** This function returns SQLITE_OK if the error code and error message are
4264
+ ** successfully set, SQLITE_NOMEM if an OOM occurs, and SQLITE_MISUSE if
4265
+ ** the database handle is NULL or invalid.
4266
+ **
4267
+ ** The error code and message set by this routine remains in effect until
4268
+ ** they are changed, either by another call to this routine or until they are
4269
+ ** changed to by SQLite itself to reflect the result of some subsquent
4270
+ ** API call.
4271
+ **
4272
+ ** This function is intended for use by SQLite extensions or wrappers. The
4273
+ ** idea is that an extension or wrapper can use this routine to set error
4274
+ ** messages and error codes and thus behave more like a core SQLite
4275
+ ** feature from the point of view of an application.
4276
+ */
4277
+ SQLITE_API int sqlite3_set_errmsg(sqlite3 *db, int errcode, const char *zErrMsg);
4278
+
4198
4279
  /*
4199
4280
  ** CAPI3REF: Prepared Statement Object
4200
4281
  ** KEYWORDS: {prepared statement} {prepared statements}
@@ -4269,8 +4350,8 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4269
4350
  **
4270
4351
  ** These constants define various performance limits
4271
4352
  ** that can be lowered at run-time using [sqlite3_limit()].
4272
- ** The synopsis of the meanings of the various limits is shown below.
4273
- ** Additional information is available at [limits | Limits in SQLite].
4353
+ ** A concise description of these limits follows, and additional information
4354
+ ** is available at [limits | Limits in SQLite].
4274
4355
  **
4275
4356
  ** <dl>
4276
4357
  ** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>
@@ -4285,7 +4366,12 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4285
4366
  ** or in an ORDER BY or GROUP BY clause.</dd>)^
4286
4367
  **
4287
4368
  ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
4288
- ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
4369
+ ** <dd>The maximum depth of the parse tree on any expression and
4370
+ ** the maximum nesting depth for subqueries and VIEWs</dd>)^
4371
+ **
4372
+ ** [[SQLITE_LIMIT_PARSER_DEPTH]] ^(<dt>SQLITE_LIMIT_PARSER_DEPTH</dt>
4373
+ ** <dd>The maximum depth of the LALR(1) parser stack used to analyze
4374
+ ** input SQL statements.</dd>)^
4289
4375
  **
4290
4376
  ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4291
4377
  ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
@@ -4312,7 +4398,8 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4312
4398
  ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
4313
4399
  **
4314
4400
  ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
4315
- ** <dd>The maximum depth of recursion for triggers.</dd>)^
4401
+ ** <dd>The maximum depth of recursion for triggers, and the maximum
4402
+ ** nesting depth for separate triggers.</dd>)^
4316
4403
  **
4317
4404
  ** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
4318
4405
  ** <dd>The maximum number of auxiliary worker threads that a single
@@ -4331,11 +4418,12 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4331
4418
  #define SQLITE_LIMIT_VARIABLE_NUMBER 9
4332
4419
  #define SQLITE_LIMIT_TRIGGER_DEPTH 10
4333
4420
  #define SQLITE_LIMIT_WORKER_THREADS 11
4421
+ #define SQLITE_LIMIT_PARSER_DEPTH 12
4334
4422
 
4335
4423
  /*
4336
4424
  ** CAPI3REF: Prepare Flags
4337
4425
  **
4338
- ** These constants define various flags that can be passed into
4426
+ ** These constants define various flags that can be passed into the
4339
4427
  ** "prepFlags" parameter of the [sqlite3_prepare_v3()] and
4340
4428
  ** [sqlite3_prepare16_v3()] interfaces.
4341
4429
  **
@@ -4375,12 +4463,29 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4375
4463
  ** fails, the sqlite3_prepare_v3() call returns the same error indications
4376
4464
  ** with or without this flag; it just omits the call to [sqlite3_log()] that
4377
4465
  ** logs the error.
4466
+ **
4467
+ ** [[SQLITE_PREPARE_FROM_DDL]] <dt>SQLITE_PREPARE_FROM_DDL</dt>
4468
+ ** <dd>The SQLITE_PREPARE_FROM_DDL flag causes the SQL compiler to enforce
4469
+ ** security constraints that would otherwise only be enforced when parsing
4470
+ ** the database schema. In other words, the SQLITE_PREPARE_FROM_DDL flag
4471
+ ** causes the SQL compiler to treat the SQL statement being prepared as if
4472
+ ** it had come from an attacker. When SQLITE_PREPARE_FROM_DDL is used and
4473
+ ** [SQLITE_DBCONFIG_TRUSTED_SCHEMA] is off, SQL functions may only be called
4474
+ ** if they are tagged with [SQLITE_INNOCUOUS] and virtual tables may only
4475
+ ** be used if they are tagged with [SQLITE_VTAB_INNOCUOUS]. Best practice
4476
+ ** is to use the SQLITE_PREPARE_FROM_DDL option when preparing any SQL that
4477
+ ** is derived from parts of the database schema. In particular, virtual
4478
+ ** table implementations that run SQL statements that are derived from
4479
+ ** arguments to their CREATE VIRTUAL TABLE statement should always use
4480
+ ** [sqlite3_prepare_v3()] and set the SQLITE_PREPARE_FROM_DDL flag to
4481
+ ** prevent bypass of the [SQLITE_DBCONFIG_TRUSTED_SCHEMA] security checks.
4378
4482
  ** </dl>
4379
4483
  */
4380
4484
  #define SQLITE_PREPARE_PERSISTENT 0x01
4381
4485
  #define SQLITE_PREPARE_NORMALIZE 0x02
4382
4486
  #define SQLITE_PREPARE_NO_VTAB 0x04
4383
4487
  #define SQLITE_PREPARE_DONT_LOG 0x10
4488
+ #define SQLITE_PREPARE_FROM_DDL 0x20
4384
4489
 
4385
4490
  /*
4386
4491
  ** CAPI3REF: Compiling An SQL Statement
@@ -4394,8 +4499,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4394
4499
  **
4395
4500
  ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4396
4501
  ** [sqlite3_prepare()] interface is legacy and should be avoided.
4397
- ** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
4398
- ** for special purposes.
4502
+ ** [sqlite3_prepare_v3()] has an extra
4503
+ ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes
4504
+ ** needed for special purpose or to pass along security restrictions.
4399
4505
  **
4400
4506
  ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4401
4507
  ** does all parsing using UTF-8. The UTF-16 interfaces are provided
@@ -4422,7 +4528,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4422
4528
  ** there is a small performance advantage to passing an nByte parameter that
4423
4529
  ** is the number of bytes in the input string <i>including</i>
4424
4530
  ** the nul-terminator.
4425
- ** Note that nByte measure the length of the input in bytes, not
4531
+ ** Note that nByte measures the length of the input in bytes, not
4426
4532
  ** characters, even for the UTF-16 interfaces.
4427
4533
  **
4428
4534
  ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
@@ -4556,7 +4662,7 @@ SQLITE_API int sqlite3_prepare16_v3(
4556
4662
  **
4557
4663
  ** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
4558
4664
  ** is available to hold the result, or if the result would exceed the
4559
- ** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
4665
+ ** maximum string length determined by the [SQLITE_LIMIT_LENGTH].
4560
4666
  **
4561
4667
  ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
4562
4668
  ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
@@ -4744,7 +4850,7 @@ typedef struct sqlite3_value sqlite3_value;
4744
4850
  **
4745
4851
  ** The context in which an SQL function executes is stored in an
4746
4852
  ** sqlite3_context object. ^A pointer to an sqlite3_context object
4747
- ** is always first parameter to [application-defined SQL functions].
4853
+ ** is always the first parameter to [application-defined SQL functions].
4748
4854
  ** The application-defined SQL function implementation will pass this
4749
4855
  ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
4750
4856
  ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
@@ -4800,8 +4906,8 @@ typedef struct sqlite3_context sqlite3_context;
4800
4906
  ** it should be a pointer to well-formed UTF16 text.
4801
4907
  ** ^If the third parameter to sqlite3_bind_text64() is not NULL, then
4802
4908
  ** it should be a pointer to a well-formed unicode string that is
4803
- ** either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16
4804
- ** otherwise.
4909
+ ** either UTF8 if the sixth parameter is SQLITE_UTF8 or SQLITE_UTF8_ZT,
4910
+ ** or UTF16 otherwise.
4805
4911
  **
4806
4912
  ** [[byte-order determination rules]] ^The byte-order of
4807
4913
  ** UTF16 input text is determined by the byte-order mark (BOM, U+FEFF)
@@ -4847,10 +4953,15 @@ typedef struct sqlite3_context sqlite3_context;
4847
4953
  ** object and pointer to it must remain valid until then. ^SQLite will then
4848
4954
  ** manage the lifetime of its private copy.
4849
4955
  **
4850
- ** ^The sixth argument to sqlite3_bind_text64() must be one of
4851
- ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
4852
- ** to specify the encoding of the text in the third parameter. If
4853
- ** the sixth argument to sqlite3_bind_text64() is not one of the
4956
+ ** ^The sixth argument (the E argument)
4957
+ ** to sqlite3_bind_text64(S,K,Z,N,D,E) must be one of
4958
+ ** [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
4959
+ ** or [SQLITE_UTF16LE] to specify the encoding of the text in the
4960
+ ** third parameter, Z. The special value [SQLITE_UTF8_ZT] means that the
4961
+ ** string argument is both UTF-8 encoded and is zero-terminated. In other
4962
+ ** words, SQLITE_UTF8_ZT means that the Z array is allocated to hold at
4963
+ ** least N+1 bytes and that the Z&#91;N&#93; byte is zero. If
4964
+ ** the E argument to sqlite3_bind_text64(S,K,Z,N,D,E) is not one of the
4854
4965
  ** allowed values shown above, or if the text encoding is different
4855
4966
  ** from the encoding specified by the sixth parameter, then the behavior
4856
4967
  ** is undefined.
@@ -4868,9 +4979,11 @@ typedef struct sqlite3_context sqlite3_context;
4868
4979
  ** associated with the pointer P of type T. ^D is either a NULL pointer or
4869
4980
  ** a pointer to a destructor function for P. ^SQLite will invoke the
4870
4981
  ** destructor D with a single argument of P when it is finished using
4871
- ** P. The T parameter should be a static string, preferably a string
4872
- ** literal. The sqlite3_bind_pointer() routine is part of the
4873
- ** [pointer passing interface] added for SQLite 3.20.0.
4982
+ ** P, even if the call to sqlite3_bind_pointer() fails. Due to a
4983
+ ** historical design quirk, results are undefined if D is
4984
+ ** SQLITE_TRANSIENT. The T parameter should be a static string,
4985
+ ** preferably a string literal. The sqlite3_bind_pointer() routine is
4986
+ ** part of the [pointer passing interface] added for SQLite 3.20.0.
4874
4987
  **
4875
4988
  ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
4876
4989
  ** for the [prepared statement] or with a prepared statement for which
@@ -5481,7 +5594,7 @@ SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
5481
5594
  **
5482
5595
  ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
5483
5596
  ** ^If the most recent evaluation of the statement encountered no errors
5484
- ** or if the statement is never been evaluated, then sqlite3_finalize() returns
5597
+ ** or if the statement has never been evaluated, then sqlite3_finalize() returns
5485
5598
  ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
5486
5599
  ** sqlite3_finalize(S) returns the appropriate [error code] or
5487
5600
  ** [extended error code].
@@ -5713,8 +5826,54 @@ SQLITE_API int sqlite3_create_window_function(
5713
5826
  /*
5714
5827
  ** CAPI3REF: Text Encodings
5715
5828
  **
5716
- ** These constant define integer codes that represent the various
5829
+ ** These constants define integer codes that represent the various
5717
5830
  ** text encodings supported by SQLite.
5831
+ **
5832
+ ** <dl>
5833
+ ** [[SQLITE_UTF8]] <dt>SQLITE_UTF8</dt><dd>Text is encoding as UTF-8</dd>
5834
+ **
5835
+ ** [[SQLITE_UTF16LE]] <dt>SQLITE_UTF16LE</dt><dd>Text is encoding as UTF-16
5836
+ ** with each code point being expressed "little endian" - the least significant
5837
+ ** byte first. This is the usual encoding, for example on Windows.</dd>
5838
+ **
5839
+ ** [[SQLITE_UTF16BE]] <dt>SQLITE_UTF16BE</dt><dd>Text is encoding as UTF-16
5840
+ ** with each code point being expressed "big endian" - the most significant
5841
+ ** byte first. This encoding is less common, but is still sometimes seen,
5842
+ ** specially on older systems.
5843
+ **
5844
+ ** [[SQLITE_UTF16]] <dt>SQLITE_UTF16</dt><dd>Text is encoding as UTF-16
5845
+ ** with each code point being expressed either little endian or as big
5846
+ ** endian, according to the native endianness of the host computer.
5847
+ **
5848
+ ** [[SQLITE_ANY]] <dt>SQLITE_ANY</dt><dd>This encoding value may only be used
5849
+ ** to declare the preferred text for [application-defined SQL functions]
5850
+ ** created using [sqlite3_create_function()] and similar. If the preferred
5851
+ ** encoding (the 4th parameter to sqlite3_create_function() - the eTextRep
5852
+ ** parameter) is SQLITE_ANY, that indicates that the function does not have
5853
+ ** a preference regarding the text encoding of its parameters and can take
5854
+ ** any text encoding that the SQLite core find convenient to supply. This
5855
+ ** option is deprecated. Please do not use it in new applications.
5856
+ **
5857
+ ** [[SQLITE_UTF16_ALIGNED]] <dt>SQLITE_UTF16_ALIGNED</dt><dd>This encoding
5858
+ ** value may be used as the 3rd parameter (the eTextRep parameter) to
5859
+ ** [sqlite3_create_collation()] and similar. This encoding value means
5860
+ ** that the application-defined collating sequence created expects its
5861
+ ** input strings to be in UTF16 in native byte order, and that the start
5862
+ ** of the strings must be aligned to a 2-byte boundary.
5863
+ **
5864
+ ** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
5865
+ ** used to specify the text encoding to strings input to
5866
+ ** [sqlite3_result_text64()] and [sqlite3_bind_text64()].
5867
+ ** The SQLITE_UTF8_ZT encoding means that the input string (call it "z")
5868
+ ** is UTF-8 encoded and that it is zero-terminated. If the length parameter
5869
+ ** (call it "n") is non-negative, this encoding option means that the caller
5870
+ ** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
5871
+ ** byte has a value of zero.
5872
+ ** This option gives the same output as SQLITE_UTF8, but can be more efficient
5873
+ ** by avoiding the need to make a copy of the input string, in some cases.
5874
+ ** However, if z is allocated to hold fewer than n+1 bytes or if the
5875
+ ** z&#91;n&#93; byte is not zero, undefined behavior may result.
5876
+ ** </dl>
5718
5877
  */
5719
5878
  #define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
5720
5879
  #define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
@@ -5722,6 +5881,7 @@ SQLITE_API int sqlite3_create_window_function(
5722
5881
  #define SQLITE_UTF16 4 /* Use native byte order */
5723
5882
  #define SQLITE_ANY 5 /* Deprecated */
5724
5883
  #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
5884
+ #define SQLITE_UTF8_ZT 16 /* Zero-terminated UTF8 */
5725
5885
 
5726
5886
  /*
5727
5887
  ** CAPI3REF: Function Flags
@@ -5805,7 +5965,7 @@ SQLITE_API int sqlite3_create_window_function(
5805
5965
  ** result.
5806
5966
  ** Every function that invokes [sqlite3_result_subtype()] should have this
5807
5967
  ** property. If it does not, then the call to [sqlite3_result_subtype()]
5808
- ** might become a no-op if the function is used as term in an
5968
+ ** might become a no-op if the function is used as a term in an
5809
5969
  ** [expression index]. On the other hand, SQL functions that never invoke
5810
5970
  ** [sqlite3_result_subtype()] should avoid setting this property, as the
5811
5971
  ** purpose of this property is to disable certain optimizations that are
@@ -5932,7 +6092,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
5932
6092
  ** sqlite3_value_nochange(X) interface returns true if and only if
5933
6093
  ** the column corresponding to X is unchanged by the UPDATE operation
5934
6094
  ** that the xUpdate method call was invoked to implement and if
5935
- ** and the prior [xColumn] method call that was invoked to extracted
6095
+ ** the prior [xColumn] method call that was invoked to extract
5936
6096
  ** the value for that column returned without setting a result (probably
5937
6097
  ** because it queried [sqlite3_vtab_nochange()] and found that the column
5938
6098
  ** was unchanging). ^Within an [xUpdate] method, any value for which
@@ -5956,26 +6116,22 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
5956
6116
  ** the SQL function that supplied the [sqlite3_value*] parameters.
5957
6117
  **
5958
6118
  ** As long as the input parameter is correct, these routines can only
5959
- ** fail if an out-of-memory error occurs during a format conversion.
5960
- ** Only the following subset of interfaces are subject to out-of-memory
5961
- ** errors:
5962
- **
5963
- ** <ul>
5964
- ** <li> sqlite3_value_blob()
5965
- ** <li> sqlite3_value_text()
5966
- ** <li> sqlite3_value_text16()
5967
- ** <li> sqlite3_value_text16le()
5968
- ** <li> sqlite3_value_text16be()
5969
- ** <li> sqlite3_value_bytes()
5970
- ** <li> sqlite3_value_bytes16()
5971
- ** </ul>
5972
- **
6119
+ ** fail if an out-of-memory error occurs while trying to do a
6120
+ ** UTF8&rarr;UTF16 or UTF16&rarr;UTF8 conversion.
5973
6121
  ** If an out-of-memory error occurs, then the return value from these
5974
6122
  ** routines is the same as if the column had contained an SQL NULL value.
5975
- ** Valid SQL NULL returns can be distinguished from out-of-memory errors
5976
- ** by invoking the [sqlite3_errcode()] immediately after the suspect
6123
+ ** If the input sqlite3_value was not obtained from [sqlite3_value_dup()],
6124
+ ** then valid SQL NULL returns can also be distinguished from
6125
+ ** out-of-memory errors after extracting the value
6126
+ ** by invoking the [sqlite3_errcode()] immediately after the suspicious
5977
6127
  ** return value is obtained and before any
5978
6128
  ** other SQLite interface is called on the same [database connection].
6129
+ ** If the input sqlite3_value was obtained from sqlite3_value_dup() then
6130
+ ** it is disconnected from the database connection and so sqlite3_errcode()
6131
+ ** will not work.
6132
+ ** In that case, the only way to distinguish an out-of-memory
6133
+ ** condition from a true SQL NULL is to invoke sqlite3_value_type() on the
6134
+ ** input to see if it is NULL prior to trying to extract the value.
5979
6135
  */
5980
6136
  SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
5981
6137
  SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -6002,7 +6158,8 @@ SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
6002
6158
  ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
6003
6159
  ** returns something other than SQLITE_TEXT, then the return value from
6004
6160
  ** sqlite3_value_encoding(X) is meaningless. ^Calls to
6005
- ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)],
6161
+ ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)],
6162
+ ** [sqlite3_value_text16be(X)],
6006
6163
  ** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
6007
6164
  ** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
6008
6165
  ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
@@ -6133,17 +6290,17 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
6133
6290
  ** query execution, under some circumstances the associated auxiliary data
6134
6291
  ** might be preserved. An example of where this might be useful is in a
6135
6292
  ** regular-expression matching function. The compiled version of the regular
6136
- ** expression can be stored as auxiliary data associated with the pattern string.
6137
- ** Then as long as the pattern string remains the same,
6293
+ ** expression can be stored as auxiliary data associated with the pattern
6294
+ ** string. Then as long as the pattern string remains the same,
6138
6295
  ** the compiled regular expression can be reused on multiple
6139
6296
  ** invocations of the same function.
6140
6297
  **
6141
- ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
6142
- ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
6143
- ** value to the application-defined function. ^N is zero for the left-most
6144
- ** function argument. ^If there is no auxiliary data
6145
- ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
6146
- ** returns a NULL pointer.
6298
+ ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary
6299
+ ** data associated by the sqlite3_set_auxdata(C,N,P,X) function with the
6300
+ ** Nth argument value to the application-defined function. ^N is zero
6301
+ ** for the left-most function argument. ^If there is no auxiliary data
6302
+ ** associated with the function argument, the sqlite3_get_auxdata(C,N)
6303
+ ** interface returns a NULL pointer.
6147
6304
  **
6148
6305
  ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6149
6306
  ** N-th argument of the application-defined function. ^Subsequent
@@ -6205,6 +6362,7 @@ SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(voi
6205
6362
  ** or a NULL pointer if there were no prior calls to
6206
6363
  ** sqlite3_set_clientdata() with the same values of D and N.
6207
6364
  ** Names are compared using strcmp() and are thus case sensitive.
6365
+ ** It returns 0 on success and SQLITE_NOMEM on allocation failure.
6208
6366
  **
6209
6367
  ** If P and X are both non-NULL, then the destructor X is invoked with
6210
6368
  ** argument P on the first of the following occurrences:
@@ -6226,10 +6384,14 @@ SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(voi
6226
6384
  **
6227
6385
  ** There is no limit (other than available memory) on the number of different
6228
6386
  ** client data pointers (with different names) that can be attached to a
6229
- ** single database connection. However, the implementation is optimized
6230
- ** for the case of having only one or two different client data names.
6231
- ** Applications and wrapper libraries are discouraged from using more than
6232
- ** one client data name each.
6387
+ ** single database connection. However, the current implementation stores
6388
+ ** the content on a linked list. Insert and retrieval performance will
6389
+ ** be proportional to the number of entries. The design use case, and
6390
+ ** the use case for which the implementation is optimized, is
6391
+ ** that an application will store only small number of client data names,
6392
+ ** typically just one or two. This interface is not intended to be a
6393
+ ** generalized key/value store for thousands or millions of keys. It
6394
+ ** will work for that, but performance might be disappointing.
6233
6395
  **
6234
6396
  ** There is no way to enumerate the client data pointers
6235
6397
  ** associated with a database connection. The N parameter can be thought
@@ -6337,10 +6499,14 @@ typedef void (*sqlite3_destructor_type)(void*);
6337
6499
  ** set the return value of the application-defined function to be
6338
6500
  ** a text string which is represented as UTF-8, UTF-16 native byte order,
6339
6501
  ** UTF-16 little endian, or UTF-16 big endian, respectively.
6340
- ** ^The sqlite3_result_text64() interface sets the return value of an
6502
+ ** ^The sqlite3_result_text64(C,Z,N,D,E) interface sets the return value of an
6341
6503
  ** application-defined function to be a text string in an encoding
6342
- ** specified by the fifth (and last) parameter, which must be one
6343
- ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
6504
+ ** specified the E parameter, which must be one
6505
+ ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
6506
+ ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
6507
+ ** the result text is both UTF-8 and zero-terminated. In other words,
6508
+ ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that
6509
+ ** the Z&#91;N&#93; is zero.
6344
6510
  ** ^SQLite takes the text result from the application from
6345
6511
  ** the 2nd parameter of the sqlite3_result_text* interfaces.
6346
6512
  ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
@@ -6427,7 +6593,7 @@ SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
6427
6593
  SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
6428
6594
  SQLITE_API void sqlite3_result_null(sqlite3_context*);
6429
6595
  SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
6430
- SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
6596
+ SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char *z, sqlite3_uint64 n,
6431
6597
  void(*)(void*), unsigned char encoding);
6432
6598
  SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
6433
6599
  SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
@@ -7366,7 +7532,7 @@ SQLITE_API int sqlite3_table_column_metadata(
7366
7532
  ** ^The sqlite3_load_extension() interface attempts to load an
7367
7533
  ** [SQLite extension] library contained in the file zFile. If
7368
7534
  ** the file cannot be loaded directly, attempts are made to load
7369
- ** with various operating-system specific extensions added.
7535
+ ** with various operating-system specific filename extensions added.
7370
7536
  ** So for example, if "samplelib" cannot be loaded, then names like
7371
7537
  ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
7372
7538
  ** be tried also.
@@ -7374,10 +7540,10 @@ SQLITE_API int sqlite3_table_column_metadata(
7374
7540
  ** ^The entry point is zProc.
7375
7541
  ** ^(zProc may be 0, in which case SQLite will try to come up with an
7376
7542
  ** entry point name on its own. It first tries "sqlite3_extension_init".
7377
- ** If that does not work, it constructs a name "sqlite3_X_init" where
7378
- ** X consists of the lower-case equivalent of all ASCII alphabetic
7379
- ** characters in the filename from the last "/" to the first following
7380
- ** "." and omitting any initial "lib".)^
7543
+ ** If that does not work, it tries names of the form "sqlite3_X_init"
7544
+ ** where X consists of the lower-case equivalent of all ASCII alphabetic
7545
+ ** characters or all ASCII alphanumeric characters in the filename from
7546
+ ** the last "/" to the first following "." and omitting any initial "lib".)^
7381
7547
  ** ^The sqlite3_load_extension() interface returns
7382
7548
  ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
7383
7549
  ** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7451,7 +7617,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
7451
7617
  ** <blockquote><pre>
7452
7618
  ** &nbsp; int xEntryPoint(
7453
7619
  ** &nbsp; sqlite3 *db,
7454
- ** &nbsp; const char **pzErrMsg,
7620
+ ** &nbsp; char **pzErrMsg,
7455
7621
  ** &nbsp; const struct sqlite3_api_routines *pThunk
7456
7622
  ** &nbsp; );
7457
7623
  ** </pre></blockquote>)^
@@ -8201,13 +8367,6 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
8201
8367
  ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
8202
8368
  ** and Windows.
8203
8369
  **
8204
- ** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
8205
- ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
8206
- ** implementation is included with the library. In this case the
8207
- ** application must supply a custom mutex implementation using the
8208
- ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
8209
- ** before calling sqlite3_initialize() or any other public sqlite3_
8210
- ** function that calls sqlite3_initialize().
8211
8370
  **
8212
8371
  ** ^The sqlite3_mutex_alloc() routine allocates a new
8213
8372
  ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
@@ -8562,6 +8721,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8562
8721
  #define SQLITE_TESTCTRL_TUNE 32
8563
8722
  #define SQLITE_TESTCTRL_LOGEST 33
8564
8723
  #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
8724
+ #define SQLITE_TESTCTRL_ATOF 34
8565
8725
  #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8566
8726
 
8567
8727
  /*
@@ -8670,17 +8830,22 @@ SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);
8670
8830
  ** pass the returned value to [sqlite3_free()] to avoid a memory leak.
8671
8831
  ** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
8672
8832
  ** errors were encountered during construction of the string. ^The
8673
- ** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
8833
+ ** [sqlite3_str_finish(X)] interface might also return a NULL pointer if the
8674
8834
  ** string in [sqlite3_str] object X is zero bytes long.
8835
+ **
8836
+ ** ^The [sqlite3_str_free(X)] interface destroys both the sqlite3_str object
8837
+ ** X and the string content it contains. Calling sqlite3_str_free(X) is
8838
+ ** the equivalent of calling [sqlite3_free](sqlite3_str_finish(X)).
8675
8839
  */
8676
8840
  SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
8841
+ SQLITE_API void sqlite3_str_free(sqlite3_str*);
8677
8842
 
8678
8843
  /*
8679
8844
  ** CAPI3REF: Add Content To A Dynamic String
8680
8845
  ** METHOD: sqlite3_str
8681
8846
  **
8682
- ** These interfaces add content to an sqlite3_str object previously obtained
8683
- ** from [sqlite3_str_new()].
8847
+ ** These interfaces add or remove content to an sqlite3_str object
8848
+ ** previously obtained from [sqlite3_str_new()].
8684
8849
  **
8685
8850
  ** ^The [sqlite3_str_appendf(X,F,...)] and
8686
8851
  ** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
@@ -8703,6 +8868,10 @@ SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
8703
8868
  ** ^The [sqlite3_str_reset(X)] method resets the string under construction
8704
8869
  ** inside [sqlite3_str] object X back to zero bytes in length.
8705
8870
  **
8871
+ ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
8872
+ ** under construction to be N bytes or less. This routine is a no-op if
8873
+ ** N is negative or if the string is already N bytes or smaller in size.
8874
+ **
8706
8875
  ** These methods do not return a result code. ^If an error occurs, that fact
8707
8876
  ** is recorded in the [sqlite3_str] object and can be recovered by a
8708
8877
  ** subsequent call to [sqlite3_str_errcode(X)].
@@ -8713,6 +8882,7 @@ SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
8713
8882
  SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
8714
8883
  SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
8715
8884
  SQLITE_API void sqlite3_str_reset(sqlite3_str*);
8885
+ SQLITE_API void sqlite3_str_truncate(sqlite3_str*,int N);
8716
8886
 
8717
8887
  /*
8718
8888
  ** CAPI3REF: Status Of A Dynamic String
@@ -8881,9 +9051,18 @@ SQLITE_API int sqlite3_status64(
8881
9051
  ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
8882
9052
  ** non-zero [error code] on failure.
8883
9053
  **
9054
+ ** ^The sqlite3_db_status64(D,O,C,H,R) routine works exactly the same
9055
+ ** way as sqlite3_db_status(D,O,C,H,R) routine except that the C and H
9056
+ ** parameters are pointer to 64-bit integers (type: sqlite3_int64) instead
9057
+ ** of pointers to 32-bit integers, which allows larger status values
9058
+ ** to be returned. If a status value exceeds 2,147,483,647 then
9059
+ ** sqlite3_db_status() will truncate the value whereas sqlite3_db_status64()
9060
+ ** will return the full value.
9061
+ **
8884
9062
  ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
8885
9063
  */
8886
9064
  SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
9065
+ SQLITE_API int sqlite3_db_status64(sqlite3*,int,sqlite3_int64*,sqlite3_int64*,int);
8887
9066
 
8888
9067
  /*
8889
9068
  ** CAPI3REF: Status Parameters for database connections
@@ -8980,6 +9159,10 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
8980
9159
  ** If an IO or other error occurs while writing a page to disk, the effect
8981
9160
  ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
8982
9161
  ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
9162
+ ** <p>
9163
+ ** ^(There is overlap between the quantities measured by this parameter
9164
+ ** (SQLITE_DBSTATUS_CACHE_WRITE) and SQLITE_DBSTATUS_TEMPBUF_SPILL.
9165
+ ** Resetting one will reduce the other.)^
8983
9166
  ** </dd>
8984
9167
  **
8985
9168
  ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>
@@ -8995,6 +9178,18 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
8995
9178
  ** <dd>This parameter returns zero for the current value if and only if
8996
9179
  ** all foreign key constraints (deferred or immediate) have been
8997
9180
  ** resolved.)^ ^The highwater mark is always 0.
9181
+ **
9182
+ ** [[SQLITE_DBSTATUS_TEMPBUF_SPILL] ^(<dt>SQLITE_DBSTATUS_TEMPBUF_SPILL</dt>
9183
+ ** <dd>^(This parameter returns the number of bytes written to temporary
9184
+ ** files on disk that could have been kept in memory had sufficient memory
9185
+ ** been available. This value includes writes to intermediate tables that
9186
+ ** are part of complex queries, external sorts that spill to disk, and
9187
+ ** writes to TEMP tables.)^
9188
+ ** ^The highwater mark is always 0.
9189
+ ** <p>
9190
+ ** ^(There is overlap between the quantities measured by this parameter
9191
+ ** (SQLITE_DBSTATUS_TEMPBUF_SPILL) and SQLITE_DBSTATUS_CACHE_WRITE.
9192
+ ** Resetting one will reduce the other.)^
8998
9193
  ** </dd>
8999
9194
  ** </dl>
9000
9195
  */
@@ -9011,7 +9206,8 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
9011
9206
  #define SQLITE_DBSTATUS_DEFERRED_FKS 10
9012
9207
  #define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
9013
9208
  #define SQLITE_DBSTATUS_CACHE_SPILL 12
9014
- #define SQLITE_DBSTATUS_MAX 12 /* Largest defined DBSTATUS */
9209
+ #define SQLITE_DBSTATUS_TEMPBUF_SPILL 13
9210
+ #define SQLITE_DBSTATUS_MAX 13 /* Largest defined DBSTATUS */
9015
9211
 
9016
9212
 
9017
9213
  /*
@@ -9776,7 +9972,7 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
9776
9972
  ** is the number of pages currently in the write-ahead log file,
9777
9973
  ** including those that were just committed.
9778
9974
  **
9779
- ** The callback function should normally return [SQLITE_OK]. ^If an error
9975
+ ** ^The callback function should normally return [SQLITE_OK]. ^If an error
9780
9976
  ** code is returned, that error will propagate back up through the
9781
9977
  ** SQLite code base to cause the statement that provoked the callback
9782
9978
  ** to report an error, though the commit will have still occurred. If the
@@ -9784,13 +9980,26 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
9784
9980
  ** that does not correspond to any valid SQLite error code, the results
9785
9981
  ** are undefined.
9786
9982
  **
9787
- ** A single database handle may have at most a single write-ahead log callback
9788
- ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
9789
- ** previously registered write-ahead log callback. ^The return value is
9790
- ** a copy of the third parameter from the previous call, if any, or 0.
9791
- ** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the
9792
- ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
9793
- ** overwrite any prior [sqlite3_wal_hook()] settings.
9983
+ ** ^A single database handle may have at most a single write-ahead log
9984
+ ** callback registered at one time. ^Calling [sqlite3_wal_hook()]
9985
+ ** replaces the default behavior or previously registered write-ahead
9986
+ ** log callback.
9987
+ **
9988
+ ** ^The return value is a copy of the third parameter from the
9989
+ ** previous call, if any, or 0.
9990
+ **
9991
+ ** ^The [sqlite3_wal_autocheckpoint()] interface and the
9992
+ ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and
9993
+ ** will overwrite any prior [sqlite3_wal_hook()] settings.
9994
+ **
9995
+ ** ^If a write-ahead log callback is set using this function then
9996
+ ** [sqlite3_wal_checkpoint_v2()] or [PRAGMA wal_checkpoint]
9997
+ ** should be invoked periodically to keep the write-ahead log file
9998
+ ** from growing without bound.
9999
+ **
10000
+ ** ^Passing a NULL pointer for the callback disables automatic
10001
+ ** checkpointing entirely. To re-enable the default behavior, call
10002
+ ** sqlite3_wal_autocheckpoint(db,1000) or use [PRAGMA wal_checkpoint].
9794
10003
  */
9795
10004
  SQLITE_API void *sqlite3_wal_hook(
9796
10005
  sqlite3*,
@@ -9807,7 +10016,7 @@ SQLITE_API void *sqlite3_wal_hook(
9807
10016
  ** to automatically [checkpoint]
9808
10017
  ** after committing a transaction if there are N or
9809
10018
  ** more frames in the [write-ahead log] file. ^Passing zero or
9810
- ** a negative value as the nFrame parameter disables automatic
10019
+ ** a negative value as the N parameter disables automatic
9811
10020
  ** checkpoints entirely.
9812
10021
  **
9813
10022
  ** ^The callback registered by this function replaces any existing callback
@@ -9823,9 +10032,10 @@ SQLITE_API void *sqlite3_wal_hook(
9823
10032
  **
9824
10033
  ** ^Every new [database connection] defaults to having the auto-checkpoint
9825
10034
  ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
9826
- ** pages. The use of this interface
9827
- ** is only necessary if the default setting is found to be suboptimal
9828
- ** for a particular application.
10035
+ ** pages.
10036
+ **
10037
+ ** ^The use of this interface is only necessary if the default setting
10038
+ ** is found to be suboptimal for a particular application.
9829
10039
  */
9830
10040
  SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
9831
10041
 
@@ -9890,6 +10100,11 @@ SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
9890
10100
  ** ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
9891
10101
  ** addition that it also truncates the log file to zero bytes just prior
9892
10102
  ** to a successful return.
10103
+ **
10104
+ ** <dt>SQLITE_CHECKPOINT_NOOP<dd>
10105
+ ** ^This mode always checkpoints zero frames. The only reason to invoke
10106
+ ** a NOOP checkpoint is to access the values returned by
10107
+ ** sqlite3_wal_checkpoint_v2() via output parameters *pnLog and *pnCkpt.
9893
10108
  ** </dl>
9894
10109
  **
9895
10110
  ** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
@@ -9960,6 +10175,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
9960
10175
  ** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
9961
10176
  ** meaning of each of these checkpoint modes.
9962
10177
  */
10178
+ #define SQLITE_CHECKPOINT_NOOP -1 /* Do no work at all */
9963
10179
  #define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
9964
10180
  #define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
9965
10181
  #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */
@@ -10197,7 +10413,8 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10197
10413
  ** <tr>
10198
10414
  ** <td valign="top">sqlite3_vtab_distinct() return value
10199
10415
  ** <td valign="top">Rows are returned in aOrderBy order
10200
- ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
10416
+ ** <td valign="top">Rows with the same value in all aOrderBy columns are
10417
+ ** adjacent
10201
10418
  ** <td valign="top">Duplicates over all colUsed columns may be omitted
10202
10419
  ** <tr><td>0<td>yes<td>yes<td>no
10203
10420
  ** <tr><td>1<td>no<td>yes<td>no
@@ -10206,8 +10423,8 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10206
10423
  ** </table>
10207
10424
  **
10208
10425
  ** ^For the purposes of comparing virtual table output values to see if the
10209
- ** values are the same value for sorting purposes, two NULL values are considered
10210
- ** to be the same. In other words, the comparison operator is "IS"
10426
+ ** values are the same value for sorting purposes, two NULL values are
10427
+ ** considered to be the same. In other words, the comparison operator is "IS"
10211
10428
  ** (or "IS NOT DISTINCT FROM") and not "==".
10212
10429
  **
10213
10430
  ** If a virtual table implementation is unable to meet the requirements
@@ -10328,7 +10545,7 @@ SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
10328
10545
  ** &nbsp; ){
10329
10546
  ** &nbsp; // do something with pVal
10330
10547
  ** &nbsp; }
10331
- ** &nbsp; if( rc!=SQLITE_OK ){
10548
+ ** &nbsp; if( rc!=SQLITE_DONE ){
10332
10549
  ** &nbsp; // an error has occurred
10333
10550
  ** &nbsp; }
10334
10551
  ** </pre></blockquote>)^
@@ -10500,9 +10717,9 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10500
10717
  ** a variable pointed to by the "pOut" parameter.
10501
10718
  **
10502
10719
  ** The "flags" parameter must be passed a mask of flags. At present only
10503
- ** one flag is defined - SQLITE_SCANSTAT_COMPLEX. If SQLITE_SCANSTAT_COMPLEX
10720
+ ** one flag is defined - [SQLITE_SCANSTAT_COMPLEX]. If SQLITE_SCANSTAT_COMPLEX
10504
10721
  ** is specified, then status information is available for all elements
10505
- ** of a query plan that are reported by "EXPLAIN QUERY PLAN" output. If
10722
+ ** of a query plan that are reported by "[EXPLAIN QUERY PLAN]" output. If
10506
10723
  ** SQLITE_SCANSTAT_COMPLEX is not specified, then only query plan elements
10507
10724
  ** that correspond to query loops (the "SCAN..." and "SEARCH..." elements of
10508
10725
  ** the EXPLAIN QUERY PLAN output) are available. Invoking API
@@ -10516,7 +10733,8 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10516
10733
  ** elements used to implement the statement - a non-zero value is returned and
10517
10734
  ** the variable that pOut points to is unchanged.
10518
10735
  **
10519
- ** See also: [sqlite3_stmt_scanstatus_reset()]
10736
+ ** See also: [sqlite3_stmt_scanstatus_reset()] and the
10737
+ ** [nexec and ncycle] columns of the [bytecode virtual table].
10520
10738
  */
10521
10739
  SQLITE_API int sqlite3_stmt_scanstatus(
10522
10740
  sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
@@ -10787,7 +11005,7 @@ typedef struct sqlite3_snapshot {
10787
11005
  ** The [sqlite3_snapshot_get()] interface is only available when the
10788
11006
  ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
10789
11007
  */
10790
- SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
11008
+ SQLITE_API int sqlite3_snapshot_get(
10791
11009
  sqlite3 *db,
10792
11010
  const char *zSchema,
10793
11011
  sqlite3_snapshot **ppSnapshot
@@ -10836,7 +11054,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
10836
11054
  ** The [sqlite3_snapshot_open()] interface is only available when the
10837
11055
  ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
10838
11056
  */
10839
- SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
11057
+ SQLITE_API int sqlite3_snapshot_open(
10840
11058
  sqlite3 *db,
10841
11059
  const char *zSchema,
10842
11060
  sqlite3_snapshot *pSnapshot
@@ -10853,7 +11071,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
10853
11071
  ** The [sqlite3_snapshot_free()] interface is only available when the
10854
11072
  ** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
10855
11073
  */
10856
- SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
11074
+ SQLITE_API void sqlite3_snapshot_free(sqlite3_snapshot*);
10857
11075
 
10858
11076
  /*
10859
11077
  ** CAPI3REF: Compare the ages of two snapshot handles.
@@ -10880,7 +11098,7 @@ SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
10880
11098
  ** This interface is only available if SQLite is compiled with the
10881
11099
  ** [SQLITE_ENABLE_SNAPSHOT] option.
10882
11100
  */
10883
- SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
11101
+ SQLITE_API int sqlite3_snapshot_cmp(
10884
11102
  sqlite3_snapshot *p1,
10885
11103
  sqlite3_snapshot *p2
10886
11104
  );
@@ -10908,7 +11126,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
10908
11126
  ** This interface is only available if SQLite is compiled with the
10909
11127
  ** [SQLITE_ENABLE_SNAPSHOT] option.
10910
11128
  */
10911
- SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
11129
+ SQLITE_API int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
10912
11130
 
10913
11131
  /*
10914
11132
  ** CAPI3REF: Serialize a database
@@ -10982,12 +11200,13 @@ SQLITE_API unsigned char *sqlite3_serialize(
10982
11200
  **
10983
11201
  ** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the
10984
11202
  ** [database connection] D to disconnect from database S and then
10985
- ** reopen S as an in-memory database based on the serialization contained
10986
- ** in P. The serialized database P is N bytes in size. M is the size of
10987
- ** the buffer P, which might be larger than N. If M is larger than N, and
10988
- ** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is
10989
- ** permitted to add content to the in-memory database as long as the total
10990
- ** size does not exceed M bytes.
11203
+ ** reopen S as an in-memory database based on the serialization
11204
+ ** contained in P. If S is a NULL pointer, the main database is
11205
+ ** used. The serialized database P is N bytes in size. M is the size
11206
+ ** of the buffer P, which might be larger than N. If M is larger than
11207
+ ** N, and the SQLITE_DESERIALIZE_READONLY bit is not set in F, then
11208
+ ** SQLite is permitted to add content to the in-memory database as
11209
+ ** long as the total size does not exceed M bytes.
10991
11210
  **
10992
11211
  ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will
10993
11212
  ** invoke sqlite3_free() on the serialization buffer when the database
@@ -11054,6 +11273,77 @@ SQLITE_API int sqlite3_deserialize(
11054
11273
  #define SQLITE_DESERIALIZE_RESIZEABLE 2 /* Resize using sqlite3_realloc64() */
11055
11274
  #define SQLITE_DESERIALIZE_READONLY 4 /* Database is read-only */
11056
11275
 
11276
+ /*
11277
+ ** CAPI3REF: Bind array values to the CARRAY table-valued function
11278
+ **
11279
+ ** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
11280
+ ** parameter that is the first argument of the [carray() table-valued function].
11281
+ ** The S parameter is a pointer to the [prepared statement] that uses the
11282
+ ** carray() functions. I is the parameter index to be bound. I must be the
11283
+ ** index of the parameter that is the first argument to the carray()
11284
+ ** table-valued function. P is a pointer to the array to be bound, and N
11285
+ ** is the number of elements in the array. The F argument is one of
11286
+ ** constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64],
11287
+ ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
11288
+ ** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
11289
+ **
11290
+ ** If the X argument is not a NULL pointer or one of the special
11291
+ ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11292
+ ** the function X with argument D when it is finished using the data in P.
11293
+ ** The call to X(D) is a destructor for the array P. The destructor X(D)
11294
+ ** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X
11295
+ ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
11296
+ ** that the data static and the destructor is never invoked. If the X
11297
+ ** parameter is the special-case value [SQLITE_TRANSIENT], then
11298
+ ** sqlite3_carray_bind_v2() makes its own private copy of the data prior
11299
+ ** to returning and never invokes the destructor X.
11300
+ **
11301
+ ** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2()
11302
+ ** with a D parameter set to P. In other words,
11303
+ ** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11304
+ ** sqlite3_carray_bind_v2(S,I,P,N,F,X,P).
11305
+ */
11306
+ SQLITE_API int sqlite3_carray_bind_v2(
11307
+ sqlite3_stmt *pStmt, /* Statement to be bound */
11308
+ int i, /* Parameter index */
11309
+ void *aData, /* Pointer to array data */
11310
+ int nData, /* Number of data elements */
11311
+ int mFlags, /* CARRAY flags */
11312
+ void (*xDel)(void*), /* Destructor for aData */
11313
+ void *pDel /* Optional argument to xDel() */
11314
+ );
11315
+ SQLITE_API int sqlite3_carray_bind(
11316
+ sqlite3_stmt *pStmt, /* Statement to be bound */
11317
+ int i, /* Parameter index */
11318
+ void *aData, /* Pointer to array data */
11319
+ int nData, /* Number of data elements */
11320
+ int mFlags, /* CARRAY flags */
11321
+ void (*xDel)(void*) /* Destructor for aData */
11322
+ );
11323
+
11324
+ /*
11325
+ ** CAPI3REF: Datatypes for the CARRAY table-valued function
11326
+ **
11327
+ ** The fifth argument to the [sqlite3_carray_bind()] interface musts be
11328
+ ** one of the following constants, to specify the datatype of the array
11329
+ ** that is being bound into the [carray table-valued function].
11330
+ */
11331
+ #define SQLITE_CARRAY_INT32 0 /* Data is 32-bit signed integers */
11332
+ #define SQLITE_CARRAY_INT64 1 /* Data is 64-bit signed integers */
11333
+ #define SQLITE_CARRAY_DOUBLE 2 /* Data is doubles */
11334
+ #define SQLITE_CARRAY_TEXT 3 /* Data is char* */
11335
+ #define SQLITE_CARRAY_BLOB 4 /* Data is struct iovec */
11336
+
11337
+ /*
11338
+ ** Versions of the above #defines that omit the initial SQLITE_, for
11339
+ ** legacy compatibility.
11340
+ */
11341
+ #define CARRAY_INT32 0 /* Data is 32-bit signed integers */
11342
+ #define CARRAY_INT64 1 /* Data is 64-bit signed integers */
11343
+ #define CARRAY_DOUBLE 2 /* Data is doubles */
11344
+ #define CARRAY_TEXT 3 /* Data is char* */
11345
+ #define CARRAY_BLOB 4 /* Data is struct iovec */
11346
+
11057
11347
  /*
11058
11348
  ** Undo the hack that converts floating point types to integer for
11059
11349
  ** builds on processors without floating point support.
@@ -12313,14 +12603,32 @@ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);
12313
12603
  ** update the "main" database attached to handle db with the changes found in
12314
12604
  ** the changeset passed via the second and third arguments.
12315
12605
  **
12606
+ ** All changes made by these functions are enclosed in a savepoint transaction.
12607
+ ** If any other error (aside from a constraint failure when attempting to
12608
+ ** write to the target database) occurs, then the savepoint transaction is
12609
+ ** rolled back, restoring the target database to its original state, and an
12610
+ ** SQLite error code returned. Additionally, starting with version 3.51.0,
12611
+ ** an error code and error message that may be accessed using the
12612
+ ** [sqlite3_errcode()] and [sqlite3_errmsg()] APIs are left in the database
12613
+ ** handle.
12614
+ **
12316
12615
  ** The fourth argument (xFilter) passed to these functions is the "filter
12317
- ** callback". If it is not NULL, then for each table affected by at least one
12318
- ** change in the changeset, the filter callback is invoked with
12319
- ** the table name as the second argument, and a copy of the context pointer
12320
- ** passed as the sixth argument as the first. If the "filter callback"
12321
- ** returns zero, then no attempt is made to apply any changes to the table.
12322
- ** Otherwise, if the return value is non-zero or the xFilter argument to
12323
- ** is NULL, all changes related to the table are attempted.
12616
+ ** callback". This may be passed NULL, in which case all changes in the
12617
+ ** changeset are applied to the database. For sqlite3changeset_apply() and
12618
+ ** sqlite3_changeset_apply_v2(), if it is not NULL, then it is invoked once
12619
+ ** for each table affected by at least one change in the changeset. In this
12620
+ ** case the table name is passed as the second argument, and a copy of
12621
+ ** the context pointer passed as the sixth argument to apply() or apply_v2()
12622
+ ** as the first. If the "filter callback" returns zero, then no attempt is
12623
+ ** made to apply any changes to the table. Otherwise, if the return value is
12624
+ ** non-zero, all changes related to the table are attempted.
12625
+ **
12626
+ ** For sqlite3_changeset_apply_v3(), the xFilter callback is invoked once
12627
+ ** per change. The second argument in this case is an sqlite3_changeset_iter
12628
+ ** that may be queried using the usual APIs for the details of the current
12629
+ ** change. If the "filter callback" returns zero in this case, then no attempt
12630
+ ** is made to apply the current change. If it returns non-zero, the change
12631
+ ** is applied.
12324
12632
  **
12325
12633
  ** For each table that is not excluded by the filter callback, this function
12326
12634
  ** tests that the target database contains a compatible table. A table is
@@ -12341,11 +12649,11 @@ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);
12341
12649
  ** one such warning is issued for each table in the changeset.
12342
12650
  **
12343
12651
  ** For each change for which there is a compatible table, an attempt is made
12344
- ** to modify the table contents according to the UPDATE, INSERT or DELETE
12345
- ** change. If a change cannot be applied cleanly, the conflict handler
12346
- ** function passed as the fifth argument to sqlite3changeset_apply() may be
12347
- ** invoked. A description of exactly when the conflict handler is invoked for
12348
- ** each type of change is below.
12652
+ ** to modify the table contents according to each UPDATE, INSERT or DELETE
12653
+ ** change that is not excluded by a filter callback. If a change cannot be
12654
+ ** applied cleanly, the conflict handler function passed as the fifth argument
12655
+ ** to sqlite3changeset_apply() may be invoked. A description of exactly when
12656
+ ** the conflict handler is invoked for each type of change is below.
12349
12657
  **
12350
12658
  ** Unlike the xFilter argument, xConflict may not be passed NULL. The results
12351
12659
  ** of passing anything other than a valid function pointer as the xConflict
@@ -12441,12 +12749,6 @@ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);
12441
12749
  ** This can be used to further customize the application's conflict
12442
12750
  ** resolution strategy.
12443
12751
  **
12444
- ** All changes made by these functions are enclosed in a savepoint transaction.
12445
- ** If any other error (aside from a constraint failure when attempting to
12446
- ** write to the target database) occurs, then the savepoint transaction is
12447
- ** rolled back, restoring the target database to its original state, and an
12448
- ** SQLite error code returned.
12449
- **
12450
12752
  ** If the output parameters (ppRebase) and (pnRebase) are non-NULL and
12451
12753
  ** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2()
12452
12754
  ** may set (*ppRebase) to point to a "rebase" that may be used with the
@@ -12496,6 +12798,23 @@ SQLITE_API int sqlite3changeset_apply_v2(
12496
12798
  void **ppRebase, int *pnRebase, /* OUT: Rebase data */
12497
12799
  int flags /* SESSION_CHANGESETAPPLY_* flags */
12498
12800
  );
12801
+ SQLITE_API int sqlite3changeset_apply_v3(
12802
+ sqlite3 *db, /* Apply change to "main" db of this handle */
12803
+ int nChangeset, /* Size of changeset in bytes */
12804
+ void *pChangeset, /* Changeset blob */
12805
+ int(*xFilter)(
12806
+ void *pCtx, /* Copy of sixth arg to _apply() */
12807
+ sqlite3_changeset_iter *p /* Handle describing change */
12808
+ ),
12809
+ int(*xConflict)(
12810
+ void *pCtx, /* Copy of sixth arg to _apply() */
12811
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12812
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
12813
+ ),
12814
+ void *pCtx, /* First argument passed to xConflict */
12815
+ void **ppRebase, int *pnRebase, /* OUT: Rebase data */
12816
+ int flags /* SESSION_CHANGESETAPPLY_* flags */
12817
+ );
12499
12818
 
12500
12819
  /*
12501
12820
  ** CAPI3REF: Flags for sqlite3changeset_apply_v2
@@ -12536,11 +12855,23 @@ SQLITE_API int sqlite3changeset_apply_v2(
12536
12855
  ** database behave as if they were declared with "ON UPDATE NO ACTION ON
12537
12856
  ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
12538
12857
  ** or SET DEFAULT.
12858
+ **
12859
+ ** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
12860
+ ** Sometimes, a changeset contains two or more update statements such that
12861
+ ** although after applying all updates the database will contain no
12862
+ ** constraint violations, no single update can be applied before the others.
12863
+ ** The simplest example of this is a pair of UPDATEs that have "swapped"
12864
+ ** two column values with a UNIQUE constraint.
12865
+ ** <p>
12866
+ ** Usually, sqlite3changeset_apply() and similar functions work hard to try
12867
+ ** to find a way to apply such a changeset. However, if this flag is set,
12868
+ ** then all such updates are considered CONSTRAINT conflicts.
12539
12869
  */
12540
12870
  #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12541
12871
  #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12542
12872
  #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12543
12873
  #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
12874
+ #define SQLITE_CHANGESETAPPLY_NOUPDATELOOP 0x0010
12544
12875
 
12545
12876
  /*
12546
12877
  ** CAPI3REF: Constants Passed To The Conflict Handler
@@ -12915,6 +13246,23 @@ SQLITE_API int sqlite3changeset_apply_v2_strm(
12915
13246
  void **ppRebase, int *pnRebase,
12916
13247
  int flags
12917
13248
  );
13249
+ SQLITE_API int sqlite3changeset_apply_v3_strm(
13250
+ sqlite3 *db, /* Apply change to "main" db of this handle */
13251
+ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
13252
+ void *pIn, /* First arg for xInput */
13253
+ int(*xFilter)(
13254
+ void *pCtx, /* Copy of sixth arg to _apply() */
13255
+ sqlite3_changeset_iter *p
13256
+ ),
13257
+ int(*xConflict)(
13258
+ void *pCtx, /* Copy of sixth arg to _apply() */
13259
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
13260
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
13261
+ ),
13262
+ void *pCtx, /* First argument passed to xConflict */
13263
+ void **ppRebase, int *pnRebase,
13264
+ int flags
13265
+ );
12918
13266
  SQLITE_API int sqlite3changeset_concat_strm(
12919
13267
  int (*xInputA)(void *pIn, void *pData, int *pnData),
12920
13268
  void *pInA,
@@ -13006,6 +13354,232 @@ SQLITE_API int sqlite3session_config(int op, void *pArg);
13006
13354
  */
13007
13355
  #define SQLITE_SESSION_CONFIG_STRMSIZE 1
13008
13356
 
13357
+ /*
13358
+ ** CAPI3REF: Configure a changegroup object
13359
+ **
13360
+ ** Configure the changegroup object passed as the first argument.
13361
+ ** At present the only valid value for the second parameter is
13362
+ ** [SQLITE_CHANGEGROUP_CONFIG_PATCHSET].
13363
+ */
13364
+ SQLITE_API int sqlite3changegroup_config(sqlite3_changegroup*, int, void *pArg);
13365
+
13366
+ /*
13367
+ ** CAPI3REF: Options for sqlite3changegroup_config().
13368
+ **
13369
+ ** The following values may be passed as the 2nd parameter to
13370
+ ** sqlite3changegroup_config().
13371
+ **
13372
+ ** <dt>SQLITE_CHANGEGROUP_CONFIG_PATCHSET <dd>
13373
+ ** A changegroup object generates either a changeset or patchset. Usually,
13374
+ ** this is determined by whether the first call to sqlite3changegroup_add()
13375
+ ** is passed a changeset or a patchset. Or, if the first changes are added
13376
+ ** to the changegroup object using the sqlite3changegroup_change_xxx()
13377
+ ** APIs, then this option may be used to configure whether the changegroup
13378
+ ** object generates a changeset or patchset.
13379
+ **
13380
+ ** When this option is invoked, parameter pArg must point to a value of
13381
+ ** type int. If the changegroup currently contains zero changes, and the
13382
+ ** value of the int variable is zero or greater than zero, then the
13383
+ ** changegroup is configured to generate a changeset or patchset,
13384
+ ** respectively. It is a no-op, not an error, if the changegroup is not
13385
+ ** configured because it has already started accumulating changes.
13386
+ **
13387
+ ** Before returning, the int variable is set to 0 if the changegroup is
13388
+ ** configured to generate a changeset, or 1 if it is configured to generate
13389
+ ** a patchset.
13390
+ */
13391
+ #define SQLITE_CHANGEGROUP_CONFIG_PATCHSET 1
13392
+
13393
+
13394
+ /*
13395
+ ** CAPI3REF: Begin adding a change to a changegroup
13396
+ **
13397
+ ** This API is used, in concert with other sqlite3changegroup_change_xxx()
13398
+ ** APIs, to add changes to a changegroup object one at a time. To add a
13399
+ ** single change, the caller must:
13400
+ **
13401
+ ** 1. Invoke sqlite3changegroup_change_begin() to indicate the type of
13402
+ ** change (INSERT, UPDATE or DELETE), the affected table and whether
13403
+ ** or not the change should be marked as indirect.
13404
+ **
13405
+ ** 2. Invoke sqlite3changegroup_change_int64() or one of the other four
13406
+ ** value functions - _null(), _double(), _text() or _blob() - one or
13407
+ ** more times to specify old.* and new.* values for the change being
13408
+ ** constructed.
13409
+ **
13410
+ ** 3. Invoke sqlite3changegroup_change_finish() to either finish adding
13411
+ ** the change to the group, or to discard the change altogether.
13412
+ **
13413
+ ** The first argument to this function must be a pointer to the existing
13414
+ ** changegroup object that the change will be added to. The second argument
13415
+ ** must be SQLITE_INSERT, SQLITE_UPDATE or SQLITE_DELETE. The third is the
13416
+ ** name of the table that the change affects, and the fourth is a boolean
13417
+ ** flag specifying whether the change should be marked as "indirect" (if
13418
+ ** bIndirect is non-zero) or not indirect (if bIndirect is zero).
13419
+ **
13420
+ ** Following a successful call to this function, this function may not be
13421
+ ** called again on the same changegroup object until after
13422
+ ** sqlite3changegroup_change_finish() has been called. Doing so is an
13423
+ ** SQLITE_MISUSE error.
13424
+ **
13425
+ ** The changegroup object passed as the first argument must be already
13426
+ ** configured with schema data for the specified table. It may be configured
13427
+ ** either by calling sqlite3changegroup_schema() with a database that contains
13428
+ ** the table, or sqlite3changegroup_add() with a changeset that contains the
13429
+ ** table. If the changegroup object has not been configured with a schema for
13430
+ ** the specified table when this function is called, SQLITE_ERROR is returned.
13431
+ **
13432
+ ** If successful, SQLITE_OK is returned. Otherwise, if an error occurs, an
13433
+ ** SQLite error code is returned. In this case, if argument pzErr is non-NULL,
13434
+ ** then (*pzErr) may be set to point to a buffer containing a utf-8 formated,
13435
+ ** nul-terminated, English language error message. It is the responsibility
13436
+ ** of the caller to eventually free this buffer using sqlite3_free().
13437
+ */
13438
+ SQLITE_API int sqlite3changegroup_change_begin(
13439
+ sqlite3_changegroup*,
13440
+ int eOp,
13441
+ const char *zTab,
13442
+ int bIndirect,
13443
+ char **pzErr
13444
+ );
13445
+
13446
+ /*
13447
+ ** CAPI3REF: Add a 64-bit integer to a changegroup
13448
+ **
13449
+ ** This function may only be called between a successful call to
13450
+ ** sqlite3changegroup_change_begin() and its matching
13451
+ ** sqlite3changegroup_change_finish() call. If it is called at any
13452
+ ** other time, it is an SQLITE_MISUSE error. Calling this function
13453
+ ** specifies a 64-bit integer value to be used in the change currently being
13454
+ ** added to the changegroup object passed as the first argument.
13455
+ **
13456
+ ** The second parameter, bNew, specifies whether the value is to be part of
13457
+ ** the new.* (if bNew is non-zero) or old.* (if bNew is zero) record of
13458
+ ** the change under construction. If this does not match the type of change
13459
+ ** specified by the preceding call to sqlite3changegroup_change_begin() (i.e.
13460
+ ** an old.* value for an SQLITE_INSERT change, or a new.* value for an
13461
+ ** SQLITE_DELETE), then SQLITE_ERROR is returned.
13462
+ **
13463
+ ** The third parameter specifies the column of the old.* or new.* record that
13464
+ ** the value will be a part of. If the specified table has an explicit primary
13465
+ ** key, then this is the index of the table column, numbered from 0 in the order
13466
+ ** specified within the CREATE TABLE statement. Or, if the table uses an
13467
+ ** implicit rowid key, then the column 0 is the rowid and the explicit columns
13468
+ ** are numbered starting from 1. If the iCol parameter is less than 0 or greater
13469
+ ** than the index of the last column in the table, SQLITE_RANGE is returned.
13470
+ **
13471
+ ** The fourth parameter is the integer value to use as part of the old.* or
13472
+ ** new.* record.
13473
+ **
13474
+ ** If this call is successful, SQLITE_OK is returned. Otherwise, if an
13475
+ ** error occurs, an SQLite error code is returned.
13476
+ */
13477
+ SQLITE_API int sqlite3changegroup_change_int64(
13478
+ sqlite3_changegroup*,
13479
+ int bNew,
13480
+ int iCol,
13481
+ sqlite3_int64 iVal
13482
+ );
13483
+
13484
+ /*
13485
+ ** CAPI3REF: Add a NULL to a changegroup
13486
+ **
13487
+ ** This function is similar to sqlite3changegroup_change_int64(). Except that
13488
+ ** it configures the change currently under construction with a NULL value
13489
+ ** instead of a 64-bit integer.
13490
+ */
13491
+ SQLITE_API int sqlite3changegroup_change_null(sqlite3_changegroup*, int, int);
13492
+
13493
+ /*
13494
+ ** CAPI3REF: Add an double to a changegroup
13495
+ **
13496
+ ** This function is similar to sqlite3changegroup_change_int64(). Except that
13497
+ ** it configures the change currently being constructed with a real value
13498
+ ** instead of a 64-bit integer.
13499
+ */
13500
+ SQLITE_API int sqlite3changegroup_change_double(sqlite3_changegroup*, int, int, double);
13501
+
13502
+ /*
13503
+ ** CAPI3REF: Add a text value to a changegroup
13504
+ **
13505
+ ** This function is similar to sqlite3changegroup_change_int64(). It configures
13506
+ ** the currently accumulated change with a text value instead of a 64-bit
13507
+ ** integer. Parameter pVal points to a buffer containing the text encoded using
13508
+ ** utf-8. Parameter nVal may either be the size of the text value in bytes, or
13509
+ ** else a negative value, in which case the buffer pVal points to is assumed to
13510
+ ** be nul-terminated.
13511
+ */
13512
+ SQLITE_API int sqlite3changegroup_change_text(
13513
+ sqlite3_changegroup*, int, int, const char *pVal, int nVal
13514
+ );
13515
+
13516
+ /*
13517
+ ** CAPI3REF: Add a blob to a changegroup
13518
+ **
13519
+ ** This function is similar to sqlite3changegroup_change_int64(). It configures
13520
+ ** the currently accumulated change with a blob value instead of a 64-bit
13521
+ ** integer. Parameter pVal points to a buffer containing the blob. Parameter
13522
+ ** nVal is the size of the blob in bytes.
13523
+ */
13524
+ SQLITE_API int sqlite3changegroup_change_blob(
13525
+ sqlite3_changegroup*, int, int, const void *pVal, int nVal
13526
+ );
13527
+
13528
+ /*
13529
+ ** CAPI3REF: Finish adding one-at-at-time changes to a changegroup
13530
+ **
13531
+ ** This function may only be called following a successful call to
13532
+ ** sqlite3changegroup_change_begin(). Otherwise, it is an SQLITE_MISUSE error.
13533
+ **
13534
+ ** If parameter bDiscard is non-zero, then the current change is simply
13535
+ ** discarded. In this case this function is always successful and SQLITE_OK
13536
+ ** returned.
13537
+ **
13538
+ ** If parameter bDiscard is zero, then an attempt is made to add the current
13539
+ ** change to the changegroup. Assuming the changegroup is configured to
13540
+ ** produce a changeset (not a patchset), this requires that:
13541
+ **
13542
+ ** * If the change is an INSERT or DELETE, then a value must be specified
13543
+ ** for all columns of the new.* or old.* record, respectively.
13544
+ **
13545
+ ** * If the change is an UPDATE record, then values must be provided for
13546
+ ** the PRIMARY KEY columns of the old.* record, but must not be provided
13547
+ ** for PRIMARY KEY columns of the new.* record.
13548
+ **
13549
+ ** * If the change is an UPDATE record, then for each non-PRIMARY KEY
13550
+ ** column in the old.* record for which a value has been provided, a
13551
+ ** value must also be provided for the same column in the new.* record.
13552
+ ** Similarly, for each non-PK column in the old.* record for which
13553
+ ** a value is not provided, a value must not be provided for the same
13554
+ ** column in the new.* record.
13555
+ **
13556
+ ** * All values specified for PRIMARY KEY columns must be non-NULL.
13557
+ **
13558
+ ** Otherwise, it is an error.
13559
+ **
13560
+ ** If the changegroup already contains a change for the same row (identified
13561
+ ** by PRIMARY KEY columns), then the current change is combined with the
13562
+ ** existing change in the same way as for sqlite3changegroup_add().
13563
+ **
13564
+ ** For a patchset, all of the above rules apply except that it doesn't matter
13565
+ ** whether or not values are provided for the non-PK old.* record columns
13566
+ ** for an UPDATE or DELETE change. This means that code used to produce
13567
+ ** a changeset using the sqlite3changegroup_change_xxx() APIs may also
13568
+ ** be used to produce patchsets.
13569
+ **
13570
+ ** If the call is successful, SQLITE_OK is returned. Otherwise, if an error
13571
+ ** occurs, an SQLite error code is returned. If an error is returned and
13572
+ ** parameter pzErr is not NULL, then (*pzErr) may be set to point to a buffer
13573
+ ** containing a nul-terminated, utf-8 encoded, English language error message.
13574
+ ** It is the responsibility of the caller to eventually free any such error
13575
+ ** message buffer using sqlite3_free().
13576
+ */
13577
+ SQLITE_API int sqlite3changegroup_change_finish(
13578
+ sqlite3_changegroup*,
13579
+ int bDiscard,
13580
+ char **pzErr
13581
+ );
13582
+
13009
13583
  /*
13010
13584
  ** Make sure we can call this stuff from C++.
13011
13585
  */