@rocicorp/zero-sqlite3 1.0.8 → 1.0.10

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.
@@ -133,7 +133,7 @@ extern "C" {
133
133
  **
134
134
  ** Since [version 3.6.18] ([dateof:3.6.18]),
135
135
  ** SQLite source code has been stored in the
136
- ** <a href="http://www.fossil-scm.org/">Fossil configuration management
136
+ ** <a href="http://fossil-scm.org/">Fossil configuration management
137
137
  ** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to
138
138
  ** a string which identifies a particular check-in of SQLite
139
139
  ** within its configuration management system. ^The SQLITE_SOURCE_ID
@@ -146,9 +146,9 @@ extern "C" {
146
146
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
147
  ** [sqlite_version()] and [sqlite_source_id()].
148
148
  */
149
- #define SQLITE_VERSION "3.47.0"
150
- #define SQLITE_VERSION_NUMBER 3047000
151
- #define SQLITE_SOURCE_ID "2024-10-21 17:10:05 d2d954d43abe20a3cf10cc12f0f9922ba6b94584e39b1ef1991f1d354058c99a"
149
+ #define SQLITE_VERSION "3.50.0"
150
+ #define SQLITE_VERSION_NUMBER 3050000
151
+ #define SQLITE_SOURCE_ID "2025-05-29 14:59:34 54b8888080d99a8735ce11bb994e253a6406e42d4e34a7a4e5af566cf6841c8b"
152
152
 
153
153
  /*
154
154
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -652,6 +652,13 @@ SQLITE_API int sqlite3_exec(
652
652
  ** filesystem supports doing multiple write operations atomically when those
653
653
  ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
654
654
  ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
655
+ **
656
+ ** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
657
+ ** from the database file in amounts that are not a multiple of the
658
+ ** page size and that do not begin at a page boundary. Without this
659
+ ** property, SQLite is careful to only do full-page reads and write
660
+ ** on aligned pages, with the one exception that it will do a sub-page
661
+ ** read of the first page to access the database header.
655
662
  */
656
663
  #define SQLITE_IOCAP_ATOMIC 0x00000001
657
664
  #define SQLITE_IOCAP_ATOMIC512 0x00000002
@@ -668,6 +675,7 @@ SQLITE_API int sqlite3_exec(
668
675
  #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
669
676
  #define SQLITE_IOCAP_IMMUTABLE 0x00002000
670
677
  #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
678
+ #define SQLITE_IOCAP_SUBPAGE_READ 0x00008000
671
679
 
672
680
  /*
673
681
  ** CAPI3REF: File Locking Levels
@@ -814,6 +822,7 @@ struct sqlite3_file {
814
822
  ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
815
823
  ** <li> [SQLITE_IOCAP_IMMUTABLE]
816
824
  ** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
825
+ ** <li> [SQLITE_IOCAP_SUBPAGE_READ]
817
826
  ** </ul>
818
827
  **
819
828
  ** The SQLITE_IOCAP_ATOMIC property means that all writes of
@@ -1091,6 +1100,11 @@ struct sqlite3_io_methods {
1091
1100
  ** pointed to by the pArg argument. This capability is used during testing
1092
1101
  ** and only needs to be supported when SQLITE_TEST is defined.
1093
1102
  **
1103
+ ** <li>[[SQLITE_FCNTL_NULL_IO]]
1104
+ ** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor
1105
+ ** or file handle for the [sqlite3_file] object such that it will no longer
1106
+ ** read or write to the database file.
1107
+ **
1094
1108
  ** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
1095
1109
  ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
1096
1110
  ** be advantageous to block on the next WAL lock if the lock is not immediately
@@ -1149,6 +1163,12 @@ struct sqlite3_io_methods {
1149
1163
  ** the value that M is to be set to. Before returning, the 32-bit signed
1150
1164
  ** integer is overwritten with the previous value of M.
1151
1165
  **
1166
+ ** <li>[[SQLITE_FCNTL_BLOCK_ON_CONNECT]]
1167
+ ** The [SQLITE_FCNTL_BLOCK_ON_CONNECT] opcode is used to configure the
1168
+ ** VFS to block when taking a SHARED lock to connect to a wal mode database.
1169
+ ** This is used to implement the functionality associated with
1170
+ ** SQLITE_SETLK_BLOCK_ON_CONNECT.
1171
+ **
1152
1172
  ** <li>[[SQLITE_FCNTL_DATA_VERSION]]
1153
1173
  ** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to
1154
1174
  ** a database file. The argument is a pointer to a 32-bit unsigned integer.
@@ -1244,6 +1264,8 @@ struct sqlite3_io_methods {
1244
1264
  #define SQLITE_FCNTL_EXTERNAL_READER 40
1245
1265
  #define SQLITE_FCNTL_CKSM_FILE 41
1246
1266
  #define SQLITE_FCNTL_RESET_CACHE 42
1267
+ #define SQLITE_FCNTL_NULL_IO 43
1268
+ #define SQLITE_FCNTL_BLOCK_ON_CONNECT 44
1247
1269
 
1248
1270
  /* deprecated names */
1249
1271
  #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -1974,13 +1996,16 @@ struct sqlite3_mem_methods {
1974
1996
  **
1975
1997
  ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1976
1998
  ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
1977
- ** the default size of lookaside memory on each [database connection].
1999
+ ** the default size of [lookaside memory] on each [database connection].
1978
2000
  ** The first argument is the
1979
- ** size of each lookaside buffer slot and the second is the number of
1980
- ** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
1981
- ** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1982
- ** option to [sqlite3_db_config()] can be used to change the lookaside
1983
- ** configuration on individual connections.)^ </dd>
2001
+ ** size of each lookaside buffer slot ("sz") and the second is the number of
2002
+ ** slots allocated to each database connection ("cnt").)^
2003
+ ** ^(SQLITE_CONFIG_LOOKASIDE sets the <i>default</i> lookaside size.
2004
+ ** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can
2005
+ ** be used to change the lookaside configuration on individual connections.)^
2006
+ ** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the
2007
+ ** default lookaside configuration at compile-time.
2008
+ ** </dd>
1984
2009
  **
1985
2010
  ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
1986
2011
  ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
@@ -2196,7 +2221,15 @@ struct sqlite3_mem_methods {
2196
2221
  ** CAPI3REF: Database Connection Configuration Options
2197
2222
  **
2198
2223
  ** These constants are the available integer configuration options that
2199
- ** can be passed as the second argument to the [sqlite3_db_config()] interface.
2224
+ ** can be passed as the second parameter to the [sqlite3_db_config()] interface.
2225
+ **
2226
+ ** The [sqlite3_db_config()] interface is a var-args functions. It takes a
2227
+ ** variable number of parameters, though always at least two. The number of
2228
+ ** parameters passed into sqlite3_db_config() depends on which of these
2229
+ ** constants is given as the second parameter. This documentation page
2230
+ ** refers to parameters beyond the second as "arguments". Thus, when this
2231
+ ** page says "the N-th argument" it means "the N-th parameter past the
2232
+ ** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()".
2200
2233
  **
2201
2234
  ** New configuration options may be added in future releases of SQLite.
2202
2235
  ** Existing configuration options might be discontinued. Applications
@@ -2208,31 +2241,57 @@ struct sqlite3_mem_methods {
2208
2241
  ** <dl>
2209
2242
  ** [[SQLITE_DBCONFIG_LOOKASIDE]]
2210
2243
  ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2211
- ** <dd> ^This option takes three additional arguments that determine the
2212
- ** [lookaside memory allocator] configuration for the [database connection].
2213
- ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
2244
+ ** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
2245
+ ** configuration of the [lookaside memory allocator] within a database
2246
+ ** connection.
2247
+ ** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
2248
+ ** in the [DBCONFIG arguments|usual format].
2249
+ ** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
2250
+ ** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
2251
+ ** should have a total of five parameters.
2252
+ ** <ol>
2253
+ ** <li><p>The first argument ("buf") is a
2214
2254
  ** pointer to a memory buffer to use for lookaside memory.
2215
- ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
2216
- ** may be NULL in which case SQLite will allocate the
2217
- ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
2218
- ** size of each lookaside buffer slot. ^The third argument is the number of
2219
- ** slots. The size of the buffer in the first argument must be greater than
2220
- ** or equal to the product of the second and third arguments. The buffer
2221
- ** must be aligned to an 8-byte boundary. ^If the second argument to
2222
- ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2223
- ** rounded down to the next smaller multiple of 8. ^(The lookaside memory
2255
+ ** The first argument may be NULL in which case SQLite will allocate the
2256
+ ** lookaside buffer itself using [sqlite3_malloc()].
2257
+ ** <li><P>The second argument ("sz") is the
2258
+ ** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2259
+ ** is less than 8. The "sz" argument should be a multiple of 8 less than
2260
+ ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2261
+ ** 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"
2265
+ ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2266
+ ** than 1,000,000.
2267
+ ** </ol>
2268
+ ** <p>If the "buf" argument is not NULL, then it must
2269
+ ** point to a memory buffer with a size that is greater than
2270
+ ** or equal to the product of "sz" and "cnt".
2271
+ ** The buffer must be aligned to an 8-byte boundary.
2272
+ ** The lookaside memory
2224
2273
  ** configuration for a database connection can only be changed when that
2225
2274
  ** connection is not currently using lookaside memory, or in other words
2226
- ** when the "current value" returned by
2227
- ** [sqlite3_db_status](D,[SQLITE_DBSTATUS_LOOKASIDE_USED],...) is zero.
2275
+ ** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero.
2228
2276
  ** Any attempt to change the lookaside memory configuration when lookaside
2229
2277
  ** memory is in use leaves the configuration unchanged and returns
2230
- ** [SQLITE_BUSY].)^</dd>
2278
+ ** [SQLITE_BUSY].
2279
+ ** If the "buf" argument is NULL and an attempt
2280
+ ** to allocate memory based on "sz" and "cnt" fails, then
2281
+ ** lookaside is silently disabled.
2282
+ ** <p>
2283
+ ** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the
2284
+ ** default lookaside configuration at initialization. The
2285
+ ** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside
2286
+ ** configuration at compile-time. Typical values for lookaside are 1200 for
2287
+ ** "sz" and 40 to 100 for "cnt".
2288
+ ** </dd>
2231
2289
  **
2232
2290
  ** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
2233
2291
  ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
2234
2292
  ** <dd> ^This option is used to enable or disable the enforcement of
2235
- ** [foreign key constraints]. There should be two additional arguments.
2293
+ ** [foreign key constraints]. This is the same setting that is
2294
+ ** enabled or disabled by the [PRAGMA foreign_keys] statement.
2236
2295
  ** The first argument is an integer which is 0 to disable FK enforcement,
2237
2296
  ** positive to enable FK enforcement or negative to leave FK enforcement
2238
2297
  ** unchanged. The second parameter is a pointer to an integer into which
@@ -2254,13 +2313,13 @@ struct sqlite3_mem_methods {
2254
2313
  ** <p>Originally this option disabled all triggers. ^(However, since
2255
2314
  ** SQLite version 3.35.0, TEMP triggers are still allowed even if
2256
2315
  ** this option is off. So, in other words, this option now only disables
2257
- ** triggers in the main database schema or in the schemas of ATTACH-ed
2316
+ ** triggers in the main database schema or in the schemas of [ATTACH]-ed
2258
2317
  ** databases.)^ </dd>
2259
2318
  **
2260
2319
  ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
2261
2320
  ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
2262
2321
  ** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2263
- ** There should be two additional arguments.
2322
+ ** There must be two additional arguments.
2264
2323
  ** The first argument is an integer which is 0 to disable views,
2265
2324
  ** positive to enable views or negative to leave the setting unchanged.
2266
2325
  ** The second parameter is a pointer to an integer into which
@@ -2279,7 +2338,7 @@ struct sqlite3_mem_methods {
2279
2338
  ** <dd> ^This option is used to enable or disable the
2280
2339
  ** [fts3_tokenizer()] function which is part of the
2281
2340
  ** [FTS3] full-text search engine extension.
2282
- ** There should be two additional arguments.
2341
+ ** There must be two additional arguments.
2283
2342
  ** The first argument is an integer which is 0 to disable fts3_tokenizer() or
2284
2343
  ** positive to enable fts3_tokenizer() or negative to leave the setting
2285
2344
  ** unchanged.
@@ -2294,7 +2353,7 @@ struct sqlite3_mem_methods {
2294
2353
  ** interface independently of the [load_extension()] SQL function.
2295
2354
  ** The [sqlite3_enable_load_extension()] API enables or disables both the
2296
2355
  ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2297
- ** There should be two additional arguments.
2356
+ ** There must be two additional arguments.
2298
2357
  ** When the first argument to this interface is 1, then only the C-API is
2299
2358
  ** enabled and the SQL function remains disabled. If the first argument to
2300
2359
  ** this interface is 0, then both the C-API and the SQL function are disabled.
@@ -2308,23 +2367,30 @@ struct sqlite3_mem_methods {
2308
2367
  **
2309
2368
  ** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2310
2369
  ** <dd> ^This option is used to change the name of the "main" database
2311
- ** schema. ^The sole argument is a pointer to a constant UTF8 string
2312
- ** which will become the new schema name in place of "main". ^SQLite
2313
- ** does not make a copy of the new main schema name string, so the application
2314
- ** must ensure that the argument passed into this DBCONFIG option is unchanged
2315
- ** until after the database connection closes.
2370
+ ** schema. This option does not follow the
2371
+ ** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format].
2372
+ ** This option takes exactly one additional argument so that the
2373
+ ** [sqlite3_db_config()] call has a total of three parameters. The
2374
+ ** extra argument must be a pointer to a constant UTF8 string which
2375
+ ** will become the new schema name in place of "main". ^SQLite does
2376
+ ** not make a copy of the new main schema name string, so the application
2377
+ ** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME
2378
+ ** is unchanged until after the database connection closes.
2316
2379
  ** </dd>
2317
2380
  **
2318
2381
  ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
2319
2382
  ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2320
- ** <dd> Usually, when a database in wal mode is closed or detached from a
2321
- ** database handle, SQLite checks if this will mean that there are now no
2322
- ** connections at all to the database. If so, it performs a checkpoint
2323
- ** operation before closing the connection. This option may be used to
2324
- ** override this behavior. The first parameter passed to this operation
2325
- ** is an integer - positive to disable checkpoints-on-close, or zero (the
2326
- ** default) to enable them, and negative to leave the setting unchanged.
2327
- ** The second parameter is a pointer to an integer
2383
+ ** <dd> Usually, when a database in [WAL mode] is closed or detached from a
2384
+ ** database handle, SQLite checks if if there are other connections to the
2385
+ ** same database, and if there are no other database connection (if the
2386
+ ** connection being closed is the last open connection to the database),
2387
+ ** then SQLite performs a [checkpoint] before closing the connection and
2388
+ ** deletes the WAL file. The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can
2389
+ ** be used to override that behavior. The first argument passed to this
2390
+ ** operation (the third parameter to [sqlite3_db_config()]) is an integer
2391
+ ** which is positive to disable checkpoints-on-close, or zero (the default)
2392
+ ** to enable them, and negative to leave the setting unchanged.
2393
+ ** The second argument (the fourth parameter) is a pointer to an integer
2328
2394
  ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2329
2395
  ** have been disabled - 0 if they are not disabled, 1 if they are.
2330
2396
  ** </dd>
@@ -2485,7 +2551,7 @@ struct sqlite3_mem_methods {
2485
2551
  ** statistics. For statistics to be collected, the flag must be set on
2486
2552
  ** the database handle both when the SQL statement is prepared and when it
2487
2553
  ** is stepped. The flag is set (collection of statistics is enabled)
2488
- ** by default. This option takes two arguments: an integer and a pointer to
2554
+ ** by default. <p>This option takes two arguments: an integer and a pointer to
2489
2555
  ** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2490
2556
  ** leave unchanged the statement scanstatus option. If the second argument
2491
2557
  ** is not NULL, then the value of the statement scanstatus setting after
@@ -2499,7 +2565,7 @@ struct sqlite3_mem_methods {
2499
2565
  ** in which tables and indexes are scanned so that the scans start at the end
2500
2566
  ** and work toward the beginning rather than starting at the beginning and
2501
2567
  ** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2502
- ** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2568
+ ** same as setting [PRAGMA reverse_unordered_selects]. <p>This option takes
2503
2569
  ** two arguments which are an integer and a pointer to an integer. The first
2504
2570
  ** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2505
2571
  ** reverse scan order flag, respectively. If the second argument is not NULL,
@@ -2508,7 +2574,76 @@ struct sqlite3_mem_methods {
2508
2574
  ** first argument.
2509
2575
  ** </dd>
2510
2576
  **
2577
+ ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]]
2578
+ ** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE</dt>
2579
+ ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables
2580
+ ** the ability of the [ATTACH DATABASE] SQL command to create a new database
2581
+ ** file if the database filed named in the ATTACH command does not already
2582
+ ** exist. This ability of ATTACH to create a new database is enabled by
2583
+ ** default. Applications can disable or reenable the ability for ATTACH to
2584
+ ** create new database files using this DBCONFIG option.<p>
2585
+ ** This option takes two arguments which are an integer and a pointer
2586
+ ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2587
+ ** leave unchanged the attach-create flag, respectively. If the second
2588
+ ** argument is not NULL, then 0 or 1 is written into the integer that the
2589
+ ** second argument points to depending on if the attach-create flag is set
2590
+ ** after processing the first argument.
2591
+ ** </dd>
2592
+ **
2593
+ ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]]
2594
+ ** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt>
2595
+ ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
2596
+ ** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
2597
+ ** 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,
2600
+ ** but the database will be opened read-only. If this option is disabled,
2601
+ ** then the ability to create a new database using [ATTACH] is also disabled,
2602
+ ** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
2603
+ ** option.<p>
2604
+ ** This option takes two arguments which are an integer and a pointer
2605
+ ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2606
+ ** leave unchanged the ability to ATTACH another database for writing,
2607
+ ** respectively. If the second argument is not NULL, then 0 or 1 is written
2608
+ ** into the integer to which the second argument points, depending on whether
2609
+ ** the ability to ATTACH a read/write database is enabled or disabled
2610
+ ** after processing the first argument.
2611
+ ** </dd>
2612
+ **
2613
+ ** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]]
2614
+ ** <dt>SQLITE_DBCONFIG_ENABLE_COMMENTS</dt>
2615
+ ** <dd>The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the
2616
+ ** ability to include comments in SQL text. Comments are enabled by default.
2617
+ ** An application can disable or reenable comments in SQL text using this
2618
+ ** DBCONFIG option.<p>
2619
+ ** This option takes two arguments which are an integer and a pointer
2620
+ ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2621
+ ** leave unchanged the ability to use comments in SQL text,
2622
+ ** respectively. If the second argument is not NULL, then 0 or 1 is written
2623
+ ** into the integer that the second argument points to depending on if
2624
+ ** comments are allowed in SQL text after processing the first argument.
2625
+ ** </dd>
2626
+ **
2511
2627
  ** </dl>
2628
+ **
2629
+ ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2630
+ **
2631
+ ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2632
+ ** 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
2637
+ ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2638
+ ** If the second argument is not NULL, then a value of 0 or 1 is written into
2639
+ ** the integer to which the second argument points, depending on whether the
2640
+ ** setting is disabled or enabled after applying any changes specified by
2641
+ ** the first argument.
2642
+ **
2643
+ ** <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.
2512
2647
  */
2513
2648
  #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2514
2649
  #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -2530,7 +2665,10 @@ struct sqlite3_mem_methods {
2530
2665
  #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2531
2666
  #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2532
2667
  #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2533
- #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2668
+ #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2669
+ #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2670
+ #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2671
+ #define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
2534
2672
 
2535
2673
  /*
2536
2674
  ** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -2622,10 +2760,14 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2622
2760
  ** deleted by the most recently completed INSERT, UPDATE or DELETE
2623
2761
  ** statement on the database connection specified by the only parameter.
2624
2762
  ** The two functions are identical except for the type of the return value
2625
- ** and that if the number of rows modified by the most recent INSERT, UPDATE
2763
+ ** and that if the number of rows modified by the most recent INSERT, UPDATE,
2626
2764
  ** or DELETE is greater than the maximum value supported by type "int", then
2627
2765
  ** the return value of sqlite3_changes() is undefined. ^Executing any other
2628
2766
  ** type of SQL statement does not modify the value returned by these functions.
2767
+ ** For the purposes of this interface, a CREATE TABLE AS SELECT statement
2768
+ ** does not count as an INSERT, UPDATE or DELETE statement and hence the rows
2769
+ ** added to the new table by the CREATE TABLE AS SELECT statement are not
2770
+ ** counted.
2629
2771
  **
2630
2772
  ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
2631
2773
  ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
@@ -2880,6 +3022,44 @@ SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
2880
3022
  */
2881
3023
  SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2882
3024
 
3025
+ /*
3026
+ ** CAPI3REF: Set the Setlk Timeout
3027
+ ** METHOD: sqlite3
3028
+ **
3029
+ ** This routine is only useful in SQLITE_ENABLE_SETLK_TIMEOUT builds. If
3030
+ ** the VFS supports blocking locks, it sets the timeout in ms used by
3031
+ ** eligible locks taken on wal mode databases by the specified database
3032
+ ** handle. In non-SQLITE_ENABLE_SETLK_TIMEOUT builds, or if the VFS does
3033
+ ** not support blocking locks, this function is a no-op.
3034
+ **
3035
+ ** Passing 0 to this function disables blocking locks altogether. Passing
3036
+ ** -1 to this function requests that the VFS blocks for a long time -
3037
+ ** indefinitely if possible. The results of passing any other negative value
3038
+ ** are undefined.
3039
+ **
3040
+ ** Internally, each SQLite database handle store two timeout values - the
3041
+ ** busy-timeout (used for rollback mode databases, or if the VFS does not
3042
+ ** support blocking locks) and the setlk-timeout (used for blocking locks
3043
+ ** on wal-mode databases). The sqlite3_busy_timeout() method sets both
3044
+ ** values, this function sets only the setlk-timeout value. Therefore,
3045
+ ** to configure separate busy-timeout and setlk-timeout values for a single
3046
+ ** database handle, call sqlite3_busy_timeout() followed by this function.
3047
+ **
3048
+ ** Whenever the number of connections to a wal mode database falls from
3049
+ ** 1 to 0, the last connection takes an exclusive lock on the database,
3050
+ ** then checkpoints and deletes the wal file. While it is doing this, any
3051
+ ** new connection that tries to read from the database fails with an
3052
+ ** SQLITE_BUSY error. Or, if the SQLITE_SETLK_BLOCK_ON_CONNECT flag is
3053
+ ** passed to this API, the new connection blocks until the exclusive lock
3054
+ ** has been released.
3055
+ */
3056
+ SQLITE_API int sqlite3_setlk_timeout(sqlite3*, int ms, int flags);
3057
+
3058
+ /*
3059
+ ** CAPI3REF: Flags for sqlite3_setlk_timeout()
3060
+ */
3061
+ #define SQLITE_SETLK_BLOCK_ON_CONNECT 0x01
3062
+
2883
3063
  /*
2884
3064
  ** CAPI3REF: Convenience Routines For Running Queries
2885
3065
  ** METHOD: sqlite3
@@ -4185,11 +4365,22 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4185
4365
  ** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
4186
4366
  ** to return an error (error code SQLITE_ERROR) if the statement uses
4187
4367
  ** any virtual tables.
4368
+ **
4369
+ ** [[SQLITE_PREPARE_DONT_LOG]] <dt>SQLITE_PREPARE_DONT_LOG</dt>
4370
+ ** <dd>The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler
4371
+ ** errors from being sent to the error log defined by
4372
+ ** [SQLITE_CONFIG_LOG]. This can be used, for example, to do test
4373
+ ** compiles to see if some SQL syntax is well-formed, without generating
4374
+ ** messages on the global error log when it is not. If the test compile
4375
+ ** fails, the sqlite3_prepare_v3() call returns the same error indications
4376
+ ** with or without this flag; it just omits the call to [sqlite3_log()] that
4377
+ ** logs the error.
4188
4378
  ** </dl>
4189
4379
  */
4190
4380
  #define SQLITE_PREPARE_PERSISTENT 0x01
4191
4381
  #define SQLITE_PREPARE_NORMALIZE 0x02
4192
4382
  #define SQLITE_PREPARE_NO_VTAB 0x04
4383
+ #define SQLITE_PREPARE_DONT_LOG 0x10
4193
4384
 
4194
4385
  /*
4195
4386
  ** CAPI3REF: Compiling An SQL Statement
@@ -4984,7 +5175,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
4984
5175
  ** other than [SQLITE_ROW] before any subsequent invocation of
4985
5176
  ** sqlite3_step(). Failure to reset the prepared statement using
4986
5177
  ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from
4987
- ** sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1],
5178
+ ** sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1]),
4988
5179
  ** sqlite3_step() began
4989
5180
  ** calling [sqlite3_reset()] automatically in this circumstance rather
4990
5181
  ** than returning [SQLITE_MISUSE]. This is not considered a compatibility
@@ -6880,6 +7071,8 @@ SQLITE_API int sqlite3_autovacuum_pages(
6880
7071
  **
6881
7072
  ** ^The second argument is a pointer to the function to invoke when a
6882
7073
  ** row is updated, inserted or deleted in a rowid table.
7074
+ ** ^The update hook is disabled by invoking sqlite3_update_hook()
7075
+ ** with a NULL pointer as the second parameter.
6883
7076
  ** ^The first argument to the callback is a copy of the third argument
6884
7077
  ** to sqlite3_update_hook().
6885
7078
  ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
@@ -10743,8 +10936,9 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_wal_info(
10743
10936
  /*
10744
10937
  ** CAPI3REF: Serialize a database
10745
10938
  **
10746
- ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
10747
- ** that is a serialization of the S database on [database connection] D.
10939
+ ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to
10940
+ ** memory that is a serialization of the S database on
10941
+ ** [database connection] D. If S is a NULL pointer, the main database is used.
10748
10942
  ** If P is not a NULL pointer, then the size of the database in bytes
10749
10943
  ** is written into *P.
10750
10944
  **
@@ -10997,7 +11191,7 @@ SQLITE_API int sqlite3_commit_status(
10997
11191
  #ifdef __cplusplus
10998
11192
  } /* End of the 'extern "C"' block */
10999
11193
  #endif
11000
- #endif /* SQLITE3_H */
11194
+ /* #endif for SQLITE3_H will be added by mksqlite3.tcl */
11001
11195
 
11002
11196
  /******** Begin file sqlite3rtree.h *********/
11003
11197
  /*
@@ -11478,9 +11672,10 @@ SQLITE_API void sqlite3session_table_filter(
11478
11672
  ** is inserted while a session object is enabled, then later deleted while
11479
11673
  ** the same session object is disabled, no INSERT record will appear in the
11480
11674
  ** changeset, even though the delete took place while the session was disabled.
11481
- ** Or, if one field of a row is updated while a session is disabled, and
11482
- ** another field of the same row is updated while the session is enabled, the
11483
- ** resulting changeset will contain an UPDATE change that updates both fields.
11675
+ ** Or, if one field of a row is updated while a session is enabled, and
11676
+ ** then another field of the same row is updated while the session is disabled,
11677
+ ** the resulting changeset will contain an UPDATE change that updates both
11678
+ ** fields.
11484
11679
  */
11485
11680
  SQLITE_API int sqlite3session_changeset(
11486
11681
  sqlite3_session *pSession, /* Session object */
@@ -11578,8 +11773,9 @@ SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession
11578
11773
  ** database zFrom the contents of the two compatible tables would be
11579
11774
  ** identical.
11580
11775
  **
11581
- ** It an error if database zFrom does not exist or does not contain the
11582
- ** required compatible table.
11776
+ ** Unless the call to this function is a no-op as described above, it is an
11777
+ ** error if database zFrom does not exist or does not contain the required
11778
+ ** compatible table.
11583
11779
  **
11584
11780
  ** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite
11585
11781
  ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
@@ -12033,19 +12229,6 @@ SQLITE_API int sqlite3changeset_concat(
12033
12229
  void **ppOut /* OUT: Buffer containing output changeset */
12034
12230
  );
12035
12231
 
12036
-
12037
- /*
12038
- ** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
12039
- */
12040
- SQLITE_API int sqlite3changeset_upgrade(
12041
- sqlite3 *db,
12042
- const char *zDb,
12043
- int nIn, const void *pIn, /* Input changeset */
12044
- int *pnOut, void **ppOut /* OUT: Inverse of input */
12045
- );
12046
-
12047
-
12048
-
12049
12232
  /*
12050
12233
  ** CAPI3REF: Changegroup Handle
12051
12234
  **
@@ -13278,14 +13461,29 @@ struct Fts5PhraseIter {
13278
13461
  ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise,
13279
13462
  ** output variable (*ppToken) is set to point to a buffer containing the
13280
13463
  ** matching document token, and (*pnToken) to the size of that buffer in
13281
- ** bytes. This API is not available if the specified token matches a
13282
- ** prefix query term. In that case both output variables are always set
13283
- ** to 0.
13464
+ ** bytes.
13284
13465
  **
13285
13466
  ** The output text is not a copy of the document text that was tokenized.
13286
13467
  ** It is the output of the tokenizer module. For tokendata=1 tables, this
13287
13468
  ** includes any embedded 0x00 and trailing data.
13288
13469
  **
13470
+ ** This API may be slow in some cases if the token identified by parameters
13471
+ ** iIdx and iToken matched a prefix token in the query. In most cases, the
13472
+ ** first call to this API for each prefix token in the query is forced
13473
+ ** to scan the portion of the full-text index that matches the prefix
13474
+ ** token to collect the extra data required by this API. If the prefix
13475
+ ** token matches a large number of token instances in the document set,
13476
+ ** this may be a performance problem.
13477
+ **
13478
+ ** If the user knows in advance that a query may use this API for a
13479
+ ** prefix token, FTS5 may be configured to collect all required data as part
13480
+ ** of the initial querying of the full-text index, avoiding the second scan
13481
+ ** entirely. This also causes prefix queries that do not use this API to
13482
+ ** run more slowly and use more memory. FTS5 may be configured in this way
13483
+ ** either on a per-table basis using the [FTS5 insttoken | 'insttoken']
13484
+ ** option, or on a per-query basis using the
13485
+ ** [fts5_insttoken | fts5_insttoken()] user function.
13486
+ **
13289
13487
  ** This API can be quite slow if used with an FTS5 table created with the
13290
13488
  ** "detail=none" or "detail=column" option.
13291
13489
  **
@@ -13719,3 +13917,4 @@ struct fts5_api {
13719
13917
  #endif /* _FTS5_H */
13720
13918
 
13721
13919
  /******** End of fts5.h *********/
13920
+ #endif /* SQLITE3_H */
@@ -366,6 +366,8 @@ struct sqlite3_api_routines {
366
366
  /* Version 3.44.0 and later */
367
367
  void *(*get_clientdata)(sqlite3*,const char*);
368
368
  int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
369
+ /* Version 3.50.0 and later */
370
+ int (*setlk_timeout)(sqlite3*,int,int);
369
371
  };
370
372
 
371
373
  /*
@@ -699,6 +701,8 @@ typedef int (*sqlite3_loadext_entry)(
699
701
  /* Version 3.44.0 and later */
700
702
  #define sqlite3_get_clientdata sqlite3_api->get_clientdata
701
703
  #define sqlite3_set_clientdata sqlite3_api->set_clientdata
704
+ /* Version 3.50.0 and later */
705
+ #define sqlite3_setlk_timeout sqlite3_api->setlk_timeout
702
706
  #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
703
707
 
704
708
  #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
package/deps/sqlite3.gyp CHANGED
@@ -1,5 +1,5 @@
1
1
  # ===
2
- # This configuration defines options specific to compiling SQLite3 itself.
2
+ # This configuration defines options specific to compiling SQLite itself.
3
3
  # Compile-time options are loaded by the auto-generated file "defines.gypi".
4
4
  # The --sqlite3 option can be provided to use a custom amalgamation instead.
5
5
  # ===
@@ -2,7 +2,7 @@
2
2
  SQLITE_EXTENSION_INIT1
3
3
 
4
4
  /*
5
- This SQLite3 extension is used only for testing purposes (npm test).
5
+ This SQLite extension is used only for testing purposes (npm test).
6
6
  */
7
7
 
8
8
  static void TestExtensionFunction(sqlite3_context* pCtx, int nVal, sqlite3_value** _) {
package/lib/database.js CHANGED
@@ -61,7 +61,7 @@ function Database(filenameGiven, options) {
61
61
  }
62
62
 
63
63
  // Make sure the specified directory exists
64
- if (!anonymous && !fs.existsSync(path.dirname(filename))) {
64
+ if (!anonymous && !filename.startsWith('file:') && !fs.existsSync(path.dirname(filename))) {
65
65
  throw new TypeError('Cannot open database because the directory does not exist');
66
66
  }
67
67
 
@@ -86,4 +86,16 @@ Database.prototype.defaultSafeIntegers = wrappers.defaultSafeIntegers;
86
86
  Database.prototype.unsafeMode = wrappers.unsafeMode;
87
87
  Database.prototype[util.inspect] = require('./methods/inspect');
88
88
 
89
+ // Export SQLITE_SCANSTAT_* constants from native addon
90
+ const nativeAddon = DEFAULT_ADDON || require('bindings')('better_sqlite3.node');
91
+ Database.SQLITE_SCANSTAT_NLOOP = nativeAddon.SQLITE_SCANSTAT_NLOOP;
92
+ Database.SQLITE_SCANSTAT_NVISIT = nativeAddon.SQLITE_SCANSTAT_NVISIT;
93
+ Database.SQLITE_SCANSTAT_EST = nativeAddon.SQLITE_SCANSTAT_EST;
94
+ Database.SQLITE_SCANSTAT_NAME = nativeAddon.SQLITE_SCANSTAT_NAME;
95
+ Database.SQLITE_SCANSTAT_EXPLAIN = nativeAddon.SQLITE_SCANSTAT_EXPLAIN;
96
+ Database.SQLITE_SCANSTAT_SELECTID = nativeAddon.SQLITE_SCANSTAT_SELECTID;
97
+ Database.SQLITE_SCANSTAT_PARENTID = nativeAddon.SQLITE_SCANSTAT_PARENTID;
98
+ Database.SQLITE_SCANSTAT_NCYCLE = nativeAddon.SQLITE_SCANSTAT_NCYCLE;
99
+ Database.SQLITE_SCANSTAT_COMPLEX = nativeAddon.SQLITE_SCANSTAT_COMPLEX;
100
+
89
101
  module.exports = Database;