@depup/better-sqlite3 12.8.0-depup.27 → 12.9.0-depup.0

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,12 +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.51.3"
150
- #define SQLITE_VERSION_NUMBER 3051003
151
- #define SQLITE_SOURCE_ID "2026-03-13 10:38:09 737ae4a34738ffa0c3ff7f9bb18df914dd1cad163f28fd6b6e114a344fe6d618"
152
- #define SQLITE_SCM_BRANCH "branch-3.51"
153
- #define SQLITE_SCM_TAGS "release version-3.51.3"
154
- #define SQLITE_SCM_DATETIME "2026-03-13T10:38:09.694Z"
149
+ #define SQLITE_VERSION "3.53.0"
150
+ #define SQLITE_VERSION_NUMBER 3053000
151
+ #define SQLITE_SOURCE_ID "2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b"
152
+ #define SQLITE_SCM_BRANCH "trunk"
153
+ #define SQLITE_SCM_TAGS "release major-release version-3.53.0"
154
+ #define SQLITE_SCM_DATETIME "2026-04-09T11:41:38.498Z"
155
155
 
156
156
  /*
157
157
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -578,7 +578,7 @@ SQLITE_API int sqlite3_exec(
578
578
  #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
579
579
  #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
580
580
  #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
581
- #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
581
+ #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal only */
582
582
 
583
583
  /*
584
584
  ** CAPI3REF: Flags For File Open Operations
@@ -1290,6 +1290,12 @@ struct sqlite3_io_methods {
1290
1290
  #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1291
1291
  #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
1292
1292
 
1293
+ /* reserved file-control numbers:
1294
+ ** 101
1295
+ ** 102
1296
+ ** 103
1297
+ */
1298
+
1293
1299
 
1294
1300
  /*
1295
1301
  ** CAPI3REF: Mutex Handle
@@ -1490,7 +1496,7 @@ typedef const char *sqlite3_filename;
1490
1496
  ** greater and the function pointer is not NULL) and will fall back
1491
1497
  ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
1492
1498
  **
1493
- ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
1499
+ ** ^The xSetSystemCall(), xGetSystemCall(), and xNextSystemCall() interfaces
1494
1500
  ** are not used by the SQLite core. These optional interfaces are provided
1495
1501
  ** by some VFSes to facilitate testing of the VFS code. By overriding
1496
1502
  ** system calls with functions under its control, a test program can
@@ -1711,7 +1717,8 @@ SQLITE_API int sqlite3_os_end(void);
1711
1717
  ** are called "anytime configuration options".
1712
1718
  ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1713
1719
  ** [sqlite3_shutdown()] with a first argument that is not an anytime
1714
- ** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
1720
+ ** configuration option, then the sqlite3_config() call will
1721
+ ** return SQLITE_MISUSE.
1715
1722
  ** Note, however, that ^sqlite3_config() can be called as part of the
1716
1723
  ** implementation of an application-defined [sqlite3_os_init()].
1717
1724
  **
@@ -2277,9 +2284,10 @@ struct sqlite3_mem_methods {
2277
2284
  ** is less than 8. The "sz" argument should be a multiple of 8 less than
2278
2285
  ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2279
2286
  ** it does.
2280
- ** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2281
- ** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2282
- ** 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"
2283
2291
  ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2284
2292
  ** than 1,000,000.
2285
2293
  ** </ol>
@@ -2567,12 +2575,15 @@ struct sqlite3_mem_methods {
2567
2575
  ** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]]
2568
2576
  ** <dt>SQLITE_DBCONFIG_STMT_SCANSTATUS</dt>
2569
2577
  ** <dd>The SQLITE_DBCONFIG_STMT_SCANSTATUS option is only useful in
2570
- ** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2571
- ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2572
- ** statistics. For statistics to be collected, the flag must be set on
2573
- ** the database handle both when the SQL statement is prepared and when it
2574
- ** is stepped. The flag is set (collection of statistics is enabled)
2575
- ** by default. <p>This option takes two arguments: an integer and a pointer to
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
2576
2587
  ** an integer. The first argument is 1, 0, or -1 to enable, disable, or
2577
2588
  ** leave unchanged the statement scanstatus option. If the second argument
2578
2589
  ** is not NULL, then the value of the statement scanstatus setting after
@@ -2645,16 +2656,34 @@ struct sqlite3_mem_methods {
2645
2656
  ** comments are allowed in SQL text after processing the first argument.
2646
2657
  ** </dd>
2647
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
+ **
2648
2675
  ** </dl>
2649
2676
  **
2650
2677
  ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2651
2678
  **
2652
2679
  ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2653
2680
  ** overall call to [sqlite3_db_config()] has a total of four parameters.
2654
- ** The first argument (the third parameter to sqlite3_db_config()) is an integer.
2655
- ** The second argument is a pointer to an integer. If the first argument is 1,
2656
- ** then the option becomes enabled. If the first integer argument is 0, then the
2657
- ** 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
2658
2687
  ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2659
2688
  ** If the second argument is not NULL, then a value of 0 or 1 is written into
2660
2689
  ** the integer to which the second argument points, depending on whether the
@@ -2662,9 +2691,10 @@ struct sqlite3_mem_methods {
2662
2691
  ** the first argument.
2663
2692
  **
2664
2693
  ** <p>While most SQLITE_DBCONFIG options use the argument format
2665
- ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2666
- ** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2667
- ** 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.
2668
2698
  */
2669
2699
  #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2670
2700
  #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
@@ -2689,7 +2719,8 @@ struct sqlite3_mem_methods {
2689
2719
  #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2690
2720
  #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2691
2721
  #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2692
- #define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
2722
+ #define SQLITE_DBCONFIG_FP_DIGITS 1023 /* int int* */
2723
+ #define SQLITE_DBCONFIG_MAX 1023 /* Largest DBCONFIG */
2693
2724
 
2694
2725
  /*
2695
2726
  ** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -4171,6 +4202,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
4171
4202
  ** <li> sqlite3_errmsg()
4172
4203
  ** <li> sqlite3_errmsg16()
4173
4204
  ** <li> sqlite3_error_offset()
4205
+ ** <li> sqlite3_db_handle()
4174
4206
  ** </ul>
4175
4207
  **
4176
4208
  ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -4217,7 +4249,7 @@ SQLITE_API const char *sqlite3_errstr(int);
4217
4249
  SQLITE_API int sqlite3_error_offset(sqlite3 *db);
4218
4250
 
4219
4251
  /*
4220
- ** CAPI3REF: Set Error Codes And Message
4252
+ ** CAPI3REF: Set Error Code And Message
4221
4253
  ** METHOD: sqlite3
4222
4254
  **
4223
4255
  ** Set the error code of the database handle passed as the first argument
@@ -4336,6 +4368,10 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4336
4368
  ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
4337
4369
  ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
4338
4370
  **
4371
+ ** [[SQLITE_LIMIT_PARSER_DEPTH]] ^(<dt>SQLITE_LIMIT_PARSER_DEPTH</dt>
4372
+ ** <dd>The maximum depth of the LALR(1) parser stack used to analyze
4373
+ ** input SQL statements.</dd>)^
4374
+ **
4339
4375
  ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4340
4376
  ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
4341
4377
  **
@@ -4380,6 +4416,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4380
4416
  #define SQLITE_LIMIT_VARIABLE_NUMBER 9
4381
4417
  #define SQLITE_LIMIT_TRIGGER_DEPTH 10
4382
4418
  #define SQLITE_LIMIT_WORKER_THREADS 11
4419
+ #define SQLITE_LIMIT_PARSER_DEPTH 12
4383
4420
 
4384
4421
  /*
4385
4422
  ** CAPI3REF: Prepare Flags
@@ -4424,12 +4461,29 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4424
4461
  ** fails, the sqlite3_prepare_v3() call returns the same error indications
4425
4462
  ** with or without this flag; it just omits the call to [sqlite3_log()] that
4426
4463
  ** logs the error.
4464
+ **
4465
+ ** [[SQLITE_PREPARE_FROM_DDL]] <dt>SQLITE_PREPARE_FROM_DDL</dt>
4466
+ ** <dd>The SQLITE_PREPARE_FROM_DDL flag causes the SQL compiler to enforce
4467
+ ** security constraints that would otherwise only be enforced when parsing
4468
+ ** the database schema. In other words, the SQLITE_PREPARE_FROM_DDL flag
4469
+ ** causes the SQL compiler to treat the SQL statement being prepared as if
4470
+ ** it had come from an attacker. When SQLITE_PREPARE_FROM_DDL is used and
4471
+ ** [SQLITE_DBCONFIG_TRUSTED_SCHEMA] is off, SQL functions may only be called
4472
+ ** if they are tagged with [SQLITE_INNOCUOUS] and virtual tables may only
4473
+ ** be used if they are tagged with [SQLITE_VTAB_INNOCUOUS]. Best practice
4474
+ ** is to use the SQLITE_PREPARE_FROM_DDL option when preparing any SQL that
4475
+ ** is derived from parts of the database schema. In particular, virtual
4476
+ ** table implementations that run SQL statements that are derived from
4477
+ ** arguments to their CREATE VIRTUAL TABLE statement should always use
4478
+ ** [sqlite3_prepare_v3()] and set the SQLITE_PREPARE_FROM_DDL flag to
4479
+ ** prevent bypass of the [SQLITE_DBCONFIG_TRUSTED_SCHEMA] security checks.
4427
4480
  ** </dl>
4428
4481
  */
4429
4482
  #define SQLITE_PREPARE_PERSISTENT 0x01
4430
4483
  #define SQLITE_PREPARE_NORMALIZE 0x02
4431
4484
  #define SQLITE_PREPARE_NO_VTAB 0x04
4432
4485
  #define SQLITE_PREPARE_DONT_LOG 0x10
4486
+ #define SQLITE_PREPARE_FROM_DDL 0x20
4433
4487
 
4434
4488
  /*
4435
4489
  ** CAPI3REF: Compiling An SQL Statement
@@ -4443,8 +4497,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4443
4497
  **
4444
4498
  ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4445
4499
  ** [sqlite3_prepare()] interface is legacy and should be avoided.
4446
- ** [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used
4447
- ** for special purposes.
4500
+ ** [sqlite3_prepare_v3()] has an extra
4501
+ ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes
4502
+ ** needed for special purpose or to pass along security restrictions.
4448
4503
  **
4449
4504
  ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4450
4505
  ** does all parsing using UTF-8. The UTF-16 interfaces are provided
@@ -4849,8 +4904,8 @@ typedef struct sqlite3_context sqlite3_context;
4849
4904
  ** it should be a pointer to well-formed UTF16 text.
4850
4905
  ** ^If the third parameter to sqlite3_bind_text64() is not NULL, then
4851
4906
  ** it should be a pointer to a well-formed unicode string that is
4852
- ** either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16
4853
- ** otherwise.
4907
+ ** either UTF8 if the sixth parameter is SQLITE_UTF8 or SQLITE_UTF8_ZT,
4908
+ ** or UTF16 otherwise.
4854
4909
  **
4855
4910
  ** [[byte-order determination rules]] ^The byte-order of
4856
4911
  ** UTF16 input text is determined by the byte-order mark (BOM, U+FEFF)
@@ -4896,10 +4951,15 @@ typedef struct sqlite3_context sqlite3_context;
4896
4951
  ** object and pointer to it must remain valid until then. ^SQLite will then
4897
4952
  ** manage the lifetime of its private copy.
4898
4953
  **
4899
- ** ^The sixth argument to sqlite3_bind_text64() must be one of
4900
- ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
4901
- ** to specify the encoding of the text in the third parameter. If
4902
- ** the sixth argument to sqlite3_bind_text64() is not one of the
4954
+ ** ^The sixth argument (the E argument)
4955
+ ** to sqlite3_bind_text64(S,K,Z,N,D,E) must be one of
4956
+ ** [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
4957
+ ** or [SQLITE_UTF16LE] to specify the encoding of the text in the
4958
+ ** third parameter, Z. The special value [SQLITE_UTF8_ZT] means that the
4959
+ ** string argument is both UTF-8 encoded and is zero-terminated. In other
4960
+ ** words, SQLITE_UTF8_ZT means that the Z array is allocated to hold at
4961
+ ** least N+1 bytes and that the Z&#91;N&#93; byte is zero. If
4962
+ ** the E argument to sqlite3_bind_text64(S,K,Z,N,D,E) is not one of the
4903
4963
  ** allowed values shown above, or if the text encoding is different
4904
4964
  ** from the encoding specified by the sixth parameter, then the behavior
4905
4965
  ** is undefined.
@@ -5766,6 +5826,52 @@ SQLITE_API int sqlite3_create_window_function(
5766
5826
  **
5767
5827
  ** These constants define integer codes that represent the various
5768
5828
  ** text encodings supported by SQLite.
5829
+ **
5830
+ ** <dl>
5831
+ ** [[SQLITE_UTF8]] <dt>SQLITE_UTF8</dt><dd>Text is encoding as UTF-8</dd>
5832
+ **
5833
+ ** [[SQLITE_UTF16LE]] <dt>SQLITE_UTF16LE</dt><dd>Text is encoding as UTF-16
5834
+ ** with each code point being expressed "little endian" - the least significant
5835
+ ** byte first. This is the usual encoding, for example on Windows.</dd>
5836
+ **
5837
+ ** [[SQLITE_UTF16BE]] <dt>SQLITE_UTF16BE</dt><dd>Text is encoding as UTF-16
5838
+ ** with each code point being expressed "big endian" - the most significant
5839
+ ** byte first. This encoding is less common, but is still sometimes seen,
5840
+ ** specially on older systems.
5841
+ **
5842
+ ** [[SQLITE_UTF16]] <dt>SQLITE_UTF16</dt><dd>Text is encoding as UTF-16
5843
+ ** with each code point being expressed either little endian or as big
5844
+ ** endian, according to the native endianness of the host computer.
5845
+ **
5846
+ ** [[SQLITE_ANY]] <dt>SQLITE_ANY</dt><dd>This encoding value may only be used
5847
+ ** to declare the preferred text for [application-defined SQL functions]
5848
+ ** created using [sqlite3_create_function()] and similar. If the preferred
5849
+ ** encoding (the 4th parameter to sqlite3_create_function() - the eTextRep
5850
+ ** parameter) is SQLITE_ANY, that indicates that the function does not have
5851
+ ** a preference regarding the text encoding of its parameters and can take
5852
+ ** any text encoding that the SQLite core find convenient to supply. This
5853
+ ** option is deprecated. Please do not use it in new applications.
5854
+ **
5855
+ ** [[SQLITE_UTF16_ALIGNED]] <dt>SQLITE_UTF16_ALIGNED</dt><dd>This encoding
5856
+ ** value may be used as the 3rd parameter (the eTextRep parameter) to
5857
+ ** [sqlite3_create_collation()] and similar. This encoding value means
5858
+ ** that the application-defined collating sequence created expects its
5859
+ ** input strings to be in UTF16 in native byte order, and that the start
5860
+ ** of the strings must be aligned to a 2-byte boundary.
5861
+ **
5862
+ ** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
5863
+ ** used to specify the text encoding to strings input to
5864
+ ** [sqlite3_result_text64()] and [sqlite3_bind_text64()].
5865
+ ** The SQLITE_UTF8_ZT encoding means that the input string (call it "z")
5866
+ ** is UTF-8 encoded and that it is zero-terminated. If the length parameter
5867
+ ** (call it "n") is non-negative, this encoding option means that the caller
5868
+ ** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
5869
+ ** byte has a value of zero.
5870
+ ** This option gives the same output as SQLITE_UTF8, but can be more efficient
5871
+ ** by avoiding the need to make a copy of the input string, in some cases.
5872
+ ** However, if z is allocated to hold fewer than n+1 bytes or if the
5873
+ ** z&#91;n&#93; byte is not zero, undefined behavior may result.
5874
+ ** </dl>
5769
5875
  */
5770
5876
  #define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
5771
5877
  #define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
@@ -5773,6 +5879,7 @@ SQLITE_API int sqlite3_create_window_function(
5773
5879
  #define SQLITE_UTF16 4 /* Use native byte order */
5774
5880
  #define SQLITE_ANY 5 /* Deprecated */
5775
5881
  #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
5882
+ #define SQLITE_UTF8_ZT 16 /* Zero-terminated UTF8 */
5776
5883
 
5777
5884
  /*
5778
5885
  ** CAPI3REF: Function Flags
@@ -6007,26 +6114,22 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
6007
6114
  ** the SQL function that supplied the [sqlite3_value*] parameters.
6008
6115
  **
6009
6116
  ** As long as the input parameter is correct, these routines can only
6010
- ** fail if an out-of-memory error occurs during a format conversion.
6011
- ** Only the following subset of interfaces are subject to out-of-memory
6012
- ** errors:
6013
- **
6014
- ** <ul>
6015
- ** <li> sqlite3_value_blob()
6016
- ** <li> sqlite3_value_text()
6017
- ** <li> sqlite3_value_text16()
6018
- ** <li> sqlite3_value_text16le()
6019
- ** <li> sqlite3_value_text16be()
6020
- ** <li> sqlite3_value_bytes()
6021
- ** <li> sqlite3_value_bytes16()
6022
- ** </ul>
6023
- **
6117
+ ** fail if an out-of-memory error occurs while trying to do a
6118
+ ** UTF8&rarr;UTF16 or UTF16&rarr;UTF8 conversion.
6024
6119
  ** If an out-of-memory error occurs, then the return value from these
6025
6120
  ** routines is the same as if the column had contained an SQL NULL value.
6026
- ** Valid SQL NULL returns can be distinguished from out-of-memory errors
6027
- ** by invoking the [sqlite3_errcode()] immediately after the suspect
6121
+ ** If the input sqlite3_value was not obtained from [sqlite3_value_dup()],
6122
+ ** then valid SQL NULL returns can also be distinguished from
6123
+ ** out-of-memory errors after extracting the value
6124
+ ** by invoking the [sqlite3_errcode()] immediately after the suspicious
6028
6125
  ** return value is obtained and before any
6029
6126
  ** other SQLite interface is called on the same [database connection].
6127
+ ** If the input sqlite3_value was obtained from sqlite3_value_dup() then
6128
+ ** it is disconnected from the database connection and so sqlite3_errcode()
6129
+ ** will not work.
6130
+ ** In that case, the only way to distinguish an out-of-memory
6131
+ ** condition from a true SQL NULL is to invoke sqlite3_value_type() on the
6132
+ ** input to see if it is NULL prior to trying to extract the value.
6030
6133
  */
6031
6134
  SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
6032
6135
  SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -6053,7 +6156,8 @@ SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
6053
6156
  ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
6054
6157
  ** returns something other than SQLITE_TEXT, then the return value from
6055
6158
  ** sqlite3_value_encoding(X) is meaningless. ^Calls to
6056
- ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)],
6159
+ ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)],
6160
+ ** [sqlite3_value_text16be(X)],
6057
6161
  ** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
6058
6162
  ** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
6059
6163
  ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
@@ -6184,17 +6288,17 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
6184
6288
  ** query execution, under some circumstances the associated auxiliary data
6185
6289
  ** might be preserved. An example of where this might be useful is in a
6186
6290
  ** regular-expression matching function. The compiled version of the regular
6187
- ** expression can be stored as auxiliary data associated with the pattern string.
6188
- ** Then as long as the pattern string remains the same,
6291
+ ** expression can be stored as auxiliary data associated with the pattern
6292
+ ** string. Then as long as the pattern string remains the same,
6189
6293
  ** the compiled regular expression can be reused on multiple
6190
6294
  ** invocations of the same function.
6191
6295
  **
6192
- ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
6193
- ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
6194
- ** value to the application-defined function. ^N is zero for the left-most
6195
- ** function argument. ^If there is no auxiliary data
6196
- ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
6197
- ** returns a NULL pointer.
6296
+ ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary
6297
+ ** data associated by the sqlite3_set_auxdata(C,N,P,X) function with the
6298
+ ** Nth argument value to the application-defined function. ^N is zero
6299
+ ** for the left-most function argument. ^If there is no auxiliary data
6300
+ ** associated with the function argument, the sqlite3_get_auxdata(C,N)
6301
+ ** interface returns a NULL pointer.
6198
6302
  **
6199
6303
  ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6200
6304
  ** N-th argument of the application-defined function. ^Subsequent
@@ -6278,10 +6382,14 @@ SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(voi
6278
6382
  **
6279
6383
  ** There is no limit (other than available memory) on the number of different
6280
6384
  ** client data pointers (with different names) that can be attached to a
6281
- ** single database connection. However, the implementation is optimized
6282
- ** for the case of having only one or two different client data names.
6283
- ** Applications and wrapper libraries are discouraged from using more than
6284
- ** one client data name each.
6385
+ ** single database connection. However, the current implementation stores
6386
+ ** the content on a linked list. Insert and retrieval performance will
6387
+ ** be proportional to the number of entries. The design use case, and
6388
+ ** the use case for which the implementation is optimized, is
6389
+ ** that an application will store only small number of client data names,
6390
+ ** typically just one or two. This interface is not intended to be a
6391
+ ** generalized key/value store for thousands or millions of keys. It
6392
+ ** will work for that, but performance might be disappointing.
6285
6393
  **
6286
6394
  ** There is no way to enumerate the client data pointers
6287
6395
  ** associated with a database connection. The N parameter can be thought
@@ -6389,10 +6497,14 @@ typedef void (*sqlite3_destructor_type)(void*);
6389
6497
  ** set the return value of the application-defined function to be
6390
6498
  ** a text string which is represented as UTF-8, UTF-16 native byte order,
6391
6499
  ** UTF-16 little endian, or UTF-16 big endian, respectively.
6392
- ** ^The sqlite3_result_text64() interface sets the return value of an
6500
+ ** ^The sqlite3_result_text64(C,Z,N,D,E) interface sets the return value of an
6393
6501
  ** application-defined function to be a text string in an encoding
6394
- ** specified by the fifth (and last) parameter, which must be one
6395
- ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
6502
+ ** specified the E parameter, which must be one
6503
+ ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
6504
+ ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
6505
+ ** the result text is both UTF-8 and zero-terminated. In other words,
6506
+ ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that
6507
+ ** the Z&#91;N&#93; is zero.
6396
6508
  ** ^SQLite takes the text result from the application from
6397
6509
  ** the 2nd parameter of the sqlite3_result_text* interfaces.
6398
6510
  ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
@@ -6479,7 +6591,7 @@ SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
6479
6591
  SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
6480
6592
  SQLITE_API void sqlite3_result_null(sqlite3_context*);
6481
6593
  SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
6482
- SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
6594
+ SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char *z, sqlite3_uint64 n,
6483
6595
  void(*)(void*), unsigned char encoding);
6484
6596
  SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
6485
6597
  SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
@@ -7418,7 +7530,7 @@ SQLITE_API int sqlite3_table_column_metadata(
7418
7530
  ** ^The sqlite3_load_extension() interface attempts to load an
7419
7531
  ** [SQLite extension] library contained in the file zFile. If
7420
7532
  ** the file cannot be loaded directly, attempts are made to load
7421
- ** with various operating-system specific extensions added.
7533
+ ** with various operating-system specific filename extensions added.
7422
7534
  ** So for example, if "samplelib" cannot be loaded, then names like
7423
7535
  ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
7424
7536
  ** be tried also.
@@ -7426,10 +7538,10 @@ SQLITE_API int sqlite3_table_column_metadata(
7426
7538
  ** ^The entry point is zProc.
7427
7539
  ** ^(zProc may be 0, in which case SQLite will try to come up with an
7428
7540
  ** entry point name on its own. It first tries "sqlite3_extension_init".
7429
- ** If that does not work, it constructs a name "sqlite3_X_init" where
7430
- ** X consists of the lower-case equivalent of all ASCII alphabetic
7431
- ** characters in the filename from the last "/" to the first following
7432
- ** "." and omitting any initial "lib".)^
7541
+ ** If that does not work, it tries names of the form "sqlite3_X_init"
7542
+ ** where X consists of the lower-case equivalent of all ASCII alphabetic
7543
+ ** characters or all ASCII alphanumeric characters in the filename from
7544
+ ** the last "/" to the first following "." and omitting any initial "lib".)^
7433
7545
  ** ^The sqlite3_load_extension() interface returns
7434
7546
  ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
7435
7547
  ** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7503,7 +7615,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
7503
7615
  ** <blockquote><pre>
7504
7616
  ** &nbsp; int xEntryPoint(
7505
7617
  ** &nbsp; sqlite3 *db,
7506
- ** &nbsp; const char **pzErrMsg,
7618
+ ** &nbsp; char **pzErrMsg,
7507
7619
  ** &nbsp; const struct sqlite3_api_routines *pThunk
7508
7620
  ** &nbsp; );
7509
7621
  ** </pre></blockquote>)^
@@ -8253,13 +8365,6 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
8253
8365
  ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
8254
8366
  ** and Windows.
8255
8367
  **
8256
- ** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
8257
- ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
8258
- ** implementation is included with the library. In this case the
8259
- ** application must supply a custom mutex implementation using the
8260
- ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
8261
- ** before calling sqlite3_initialize() or any other public sqlite3_
8262
- ** function that calls sqlite3_initialize().
8263
8368
  **
8264
8369
  ** ^The sqlite3_mutex_alloc() routine allocates a new
8265
8370
  ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
@@ -8614,6 +8719,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8614
8719
  #define SQLITE_TESTCTRL_TUNE 32
8615
8720
  #define SQLITE_TESTCTRL_LOGEST 33
8616
8721
  #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
8722
+ #define SQLITE_TESTCTRL_ATOF 34
8617
8723
  #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8618
8724
 
8619
8725
  /*
@@ -8722,17 +8828,22 @@ SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);
8722
8828
  ** pass the returned value to [sqlite3_free()] to avoid a memory leak.
8723
8829
  ** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
8724
8830
  ** errors were encountered during construction of the string. ^The
8725
- ** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
8831
+ ** [sqlite3_str_finish(X)] interface might also return a NULL pointer if the
8726
8832
  ** string in [sqlite3_str] object X is zero bytes long.
8833
+ **
8834
+ ** ^The [sqlite3_str_free(X)] interface destroys both the sqlite3_str object
8835
+ ** X and the string content it contains. Calling sqlite3_str_free(X) is
8836
+ ** the equivalent of calling [sqlite3_free](sqlite3_str_finish(X)).
8727
8837
  */
8728
8838
  SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
8839
+ SQLITE_API void sqlite3_str_free(sqlite3_str*);
8729
8840
 
8730
8841
  /*
8731
8842
  ** CAPI3REF: Add Content To A Dynamic String
8732
8843
  ** METHOD: sqlite3_str
8733
8844
  **
8734
- ** These interfaces add content to an sqlite3_str object previously obtained
8735
- ** from [sqlite3_str_new()].
8845
+ ** These interfaces add or remove content to an sqlite3_str object
8846
+ ** previously obtained from [sqlite3_str_new()].
8736
8847
  **
8737
8848
  ** ^The [sqlite3_str_appendf(X,F,...)] and
8738
8849
  ** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
@@ -8755,6 +8866,10 @@ SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
8755
8866
  ** ^The [sqlite3_str_reset(X)] method resets the string under construction
8756
8867
  ** inside [sqlite3_str] object X back to zero bytes in length.
8757
8868
  **
8869
+ ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
8870
+ ** under construction to be N bytes or less. This routine is a no-op if
8871
+ ** N is negative or if the string is already N bytes or smaller in size.
8872
+ **
8758
8873
  ** These methods do not return a result code. ^If an error occurs, that fact
8759
8874
  ** is recorded in the [sqlite3_str] object and can be recovered by a
8760
8875
  ** subsequent call to [sqlite3_str_errcode(X)].
@@ -8765,6 +8880,7 @@ SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
8765
8880
  SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
8766
8881
  SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
8767
8882
  SQLITE_API void sqlite3_str_reset(sqlite3_str*);
8883
+ SQLITE_API void sqlite3_str_truncate(sqlite3_str*,int N);
8768
8884
 
8769
8885
  /*
8770
8886
  ** CAPI3REF: Status Of A Dynamic String
@@ -10295,7 +10411,8 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10295
10411
  ** <tr>
10296
10412
  ** <td valign="top">sqlite3_vtab_distinct() return value
10297
10413
  ** <td valign="top">Rows are returned in aOrderBy order
10298
- ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
10414
+ ** <td valign="top">Rows with the same value in all aOrderBy columns are
10415
+ ** adjacent
10299
10416
  ** <td valign="top">Duplicates over all colUsed columns may be omitted
10300
10417
  ** <tr><td>0<td>yes<td>yes<td>no
10301
10418
  ** <tr><td>1<td>no<td>yes<td>no
@@ -10304,8 +10421,8 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10304
10421
  ** </table>
10305
10422
  **
10306
10423
  ** ^For the purposes of comparing virtual table output values to see if the
10307
- ** values are the same value for sorting purposes, two NULL values are considered
10308
- ** to be the same. In other words, the comparison operator is "IS"
10424
+ ** values are the same value for sorting purposes, two NULL values are
10425
+ ** considered to be the same. In other words, the comparison operator is "IS"
10309
10426
  ** (or "IS NOT DISTINCT FROM") and not "==".
10310
10427
  **
10311
10428
  ** If a virtual table implementation is unable to meet the requirements
@@ -10598,9 +10715,9 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10598
10715
  ** a variable pointed to by the "pOut" parameter.
10599
10716
  **
10600
10717
  ** The "flags" parameter must be passed a mask of flags. At present only
10601
- ** one flag is defined - SQLITE_SCANSTAT_COMPLEX. If SQLITE_SCANSTAT_COMPLEX
10718
+ ** one flag is defined - [SQLITE_SCANSTAT_COMPLEX]. If SQLITE_SCANSTAT_COMPLEX
10602
10719
  ** is specified, then status information is available for all elements
10603
- ** of a query plan that are reported by "EXPLAIN QUERY PLAN" output. If
10720
+ ** of a query plan that are reported by "[EXPLAIN QUERY PLAN]" output. If
10604
10721
  ** SQLITE_SCANSTAT_COMPLEX is not specified, then only query plan elements
10605
10722
  ** that correspond to query loops (the "SCAN..." and "SEARCH..." elements of
10606
10723
  ** the EXPLAIN QUERY PLAN output) are available. Invoking API
@@ -10614,7 +10731,8 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10614
10731
  ** elements used to implement the statement - a non-zero value is returned and
10615
10732
  ** the variable that pOut points to is unchanged.
10616
10733
  **
10617
- ** See also: [sqlite3_stmt_scanstatus_reset()]
10734
+ ** See also: [sqlite3_stmt_scanstatus_reset()] and the
10735
+ ** [nexec and ncycle] columns of the [bytecode virtual table].
10618
10736
  */
10619
10737
  SQLITE_API int sqlite3_stmt_scanstatus(
10620
10738
  sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
@@ -11156,19 +11274,42 @@ SQLITE_API int sqlite3_deserialize(
11156
11274
  /*
11157
11275
  ** CAPI3REF: Bind array values to the CARRAY table-valued function
11158
11276
  **
11159
- ** The sqlite3_carray_bind(S,I,P,N,F,X) interface binds an array value to
11160
- ** one of the first argument of the [carray() table-valued function]. The
11161
- ** S parameter is a pointer to the [prepared statement] that uses the carray()
11162
- ** functions. I is the parameter index to be bound. P is a pointer to the
11163
- ** array to be bound, and N is the number of eements in the array. The
11164
- ** F argument is one of constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64],
11165
- ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT], or [SQLITE_CARRAY_BLOB] to
11166
- ** indicate the datatype of the array being bound. The X argument is not a
11167
- ** NULL pointer, then SQLite will invoke the function X on the P parameter
11168
- ** after it has finished using P, even if the call to
11169
- ** sqlite3_carray_bind() fails. The special-case finalizer
11170
- ** SQLITE_TRANSIENT has no effect here.
11171
- */
11277
+ ** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
11278
+ ** parameter that is the first argument of the [carray() table-valued function].
11279
+ ** The S parameter is a pointer to the [prepared statement] that uses the
11280
+ ** carray() functions. I is the parameter index to be bound. I must be the
11281
+ ** index of the parameter that is the first argument to the carray()
11282
+ ** table-valued function. P is a pointer to the array to be bound, and N
11283
+ ** is the number of elements in the array. The F argument is one of
11284
+ ** constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64],
11285
+ ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
11286
+ ** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
11287
+ **
11288
+ ** If the X argument is not a NULL pointer or one of the special
11289
+ ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11290
+ ** the function X with argument D when it is finished using the data in P.
11291
+ ** The call to X(D) is a destructor for the array P. The destructor X(D)
11292
+ ** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X
11293
+ ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
11294
+ ** that the data static and the destructor is never invoked. If the X
11295
+ ** parameter is the special-case value [SQLITE_TRANSIENT], then
11296
+ ** sqlite3_carray_bind_v2() makes its own private copy of the data prior
11297
+ ** to returning and never invokes the destructor X.
11298
+ **
11299
+ ** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2()
11300
+ ** with a D parameter set to P. In other words,
11301
+ ** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11302
+ ** sqlite3_carray_bind_v2(S,I,P,N,F,X,P).
11303
+ */
11304
+ SQLITE_API int sqlite3_carray_bind_v2(
11305
+ sqlite3_stmt *pStmt, /* Statement to be bound */
11306
+ int i, /* Parameter index */
11307
+ void *aData, /* Pointer to array data */
11308
+ int nData, /* Number of data elements */
11309
+ int mFlags, /* CARRAY flags */
11310
+ void (*xDel)(void*), /* Destructor for aData */
11311
+ void *pDel /* Optional argument to xDel() */
11312
+ );
11172
11313
  SQLITE_API int sqlite3_carray_bind(
11173
11314
  sqlite3_stmt *pStmt, /* Statement to be bound */
11174
11315
  int i, /* Parameter index */
@@ -13199,6 +13340,232 @@ SQLITE_API int sqlite3session_config(int op, void *pArg);
13199
13340
  */
13200
13341
  #define SQLITE_SESSION_CONFIG_STRMSIZE 1
13201
13342
 
13343
+ /*
13344
+ ** CAPI3REF: Configure a changegroup object
13345
+ **
13346
+ ** Configure the changegroup object passed as the first argument.
13347
+ ** At present the only valid value for the second parameter is
13348
+ ** [SQLITE_CHANGEGROUP_CONFIG_PATCHSET].
13349
+ */
13350
+ SQLITE_API int sqlite3changegroup_config(sqlite3_changegroup*, int, void *pArg);
13351
+
13352
+ /*
13353
+ ** CAPI3REF: Options for sqlite3changegroup_config().
13354
+ **
13355
+ ** The following values may be passed as the 2nd parameter to
13356
+ ** sqlite3changegroup_config().
13357
+ **
13358
+ ** <dt>SQLITE_CHANGEGROUP_CONFIG_PATCHSET <dd>
13359
+ ** A changegroup object generates either a changeset or patchset. Usually,
13360
+ ** this is determined by whether the first call to sqlite3changegroup_add()
13361
+ ** is passed a changeset or a patchset. Or, if the first changes are added
13362
+ ** to the changegroup object using the sqlite3changegroup_change_xxx()
13363
+ ** APIs, then this option may be used to configure whether the changegroup
13364
+ ** object generates a changeset or patchset.
13365
+ **
13366
+ ** When this option is invoked, parameter pArg must point to a value of
13367
+ ** type int. If the changegroup currently contains zero changes, and the
13368
+ ** value of the int variable is zero or greater than zero, then the
13369
+ ** changegroup is configured to generate a changeset or patchset,
13370
+ ** respectively. It is a no-op, not an error, if the changegroup is not
13371
+ ** configured because it has already started accumulating changes.
13372
+ **
13373
+ ** Before returning, the int variable is set to 0 if the changegroup is
13374
+ ** configured to generate a changeset, or 1 if it is configured to generate
13375
+ ** a patchset.
13376
+ */
13377
+ #define SQLITE_CHANGEGROUP_CONFIG_PATCHSET 1
13378
+
13379
+
13380
+ /*
13381
+ ** CAPI3REF: Begin adding a change to a changegroup
13382
+ **
13383
+ ** This API is used, in concert with other sqlite3changegroup_change_xxx()
13384
+ ** APIs, to add changes to a changegroup object one at a time. To add a
13385
+ ** single change, the caller must:
13386
+ **
13387
+ ** 1. Invoke sqlite3changegroup_change_begin() to indicate the type of
13388
+ ** change (INSERT, UPDATE or DELETE), the affected table and whether
13389
+ ** or not the change should be marked as indirect.
13390
+ **
13391
+ ** 2. Invoke sqlite3changegroup_change_int64() or one of the other four
13392
+ ** value functions - _null(), _double(), _text() or _blob() - one or
13393
+ ** more times to specify old.* and new.* values for the change being
13394
+ ** constructed.
13395
+ **
13396
+ ** 3. Invoke sqlite3changegroup_change_finish() to either finish adding
13397
+ ** the change to the group, or to discard the change altogether.
13398
+ **
13399
+ ** The first argument to this function must be a pointer to the existing
13400
+ ** changegroup object that the change will be added to. The second argument
13401
+ ** must be SQLITE_INSERT, SQLITE_UPDATE or SQLITE_DELETE. The third is the
13402
+ ** name of the table that the change affects, and the fourth is a boolean
13403
+ ** flag specifying whether the change should be marked as "indirect" (if
13404
+ ** bIndirect is non-zero) or not indirect (if bIndirect is zero).
13405
+ **
13406
+ ** Following a successful call to this function, this function may not be
13407
+ ** called again on the same changegroup object until after
13408
+ ** sqlite3changegroup_change_finish() has been called. Doing so is an
13409
+ ** SQLITE_MISUSE error.
13410
+ **
13411
+ ** The changegroup object passed as the first argument must be already
13412
+ ** configured with schema data for the specified table. It may be configured
13413
+ ** either by calling sqlite3changegroup_schema() with a database that contains
13414
+ ** the table, or sqlite3changegroup_add() with a changeset that contains the
13415
+ ** table. If the changegroup object has not been configured with a schema for
13416
+ ** the specified table when this function is called, SQLITE_ERROR is returned.
13417
+ **
13418
+ ** If successful, SQLITE_OK is returned. Otherwise, if an error occurs, an
13419
+ ** SQLite error code is returned. In this case, if argument pzErr is non-NULL,
13420
+ ** then (*pzErr) may be set to point to a buffer containing a utf-8 formated,
13421
+ ** nul-terminated, English language error message. It is the responsibility
13422
+ ** of the caller to eventually free this buffer using sqlite3_free().
13423
+ */
13424
+ SQLITE_API int sqlite3changegroup_change_begin(
13425
+ sqlite3_changegroup*,
13426
+ int eOp,
13427
+ const char *zTab,
13428
+ int bIndirect,
13429
+ char **pzErr
13430
+ );
13431
+
13432
+ /*
13433
+ ** CAPI3REF: Add a 64-bit integer to a changegroup
13434
+ **
13435
+ ** This function may only be called between a successful call to
13436
+ ** sqlite3changegroup_change_begin() and its matching
13437
+ ** sqlite3changegroup_change_finish() call. If it is called at any
13438
+ ** other time, it is an SQLITE_MISUSE error. Calling this function
13439
+ ** specifies a 64-bit integer value to be used in the change currently being
13440
+ ** added to the changegroup object passed as the first argument.
13441
+ **
13442
+ ** The second parameter, bNew, specifies whether the value is to be part of
13443
+ ** the new.* (if bNew is non-zero) or old.* (if bNew is zero) record of
13444
+ ** the change under construction. If this does not match the type of change
13445
+ ** specified by the preceding call to sqlite3changegroup_change_begin() (i.e.
13446
+ ** an old.* value for an SQLITE_INSERT change, or a new.* value for an
13447
+ ** SQLITE_DELETE), then SQLITE_ERROR is returned.
13448
+ **
13449
+ ** The third parameter specifies the column of the old.* or new.* record that
13450
+ ** the value will be a part of. If the specified table has an explicit primary
13451
+ ** key, then this is the index of the table column, numbered from 0 in the order
13452
+ ** specified within the CREATE TABLE statement. Or, if the table uses an
13453
+ ** implicit rowid key, then the column 0 is the rowid and the explicit columns
13454
+ ** are numbered starting from 1. If the iCol parameter is less than 0 or greater
13455
+ ** than the index of the last column in the table, SQLITE_RANGE is returned.
13456
+ **
13457
+ ** The fourth parameter is the integer value to use as part of the old.* or
13458
+ ** new.* record.
13459
+ **
13460
+ ** If this call is successful, SQLITE_OK is returned. Otherwise, if an
13461
+ ** error occurs, an SQLite error code is returned.
13462
+ */
13463
+ SQLITE_API int sqlite3changegroup_change_int64(
13464
+ sqlite3_changegroup*,
13465
+ int bNew,
13466
+ int iCol,
13467
+ sqlite3_int64 iVal
13468
+ );
13469
+
13470
+ /*
13471
+ ** CAPI3REF: Add a NULL to a changegroup
13472
+ **
13473
+ ** This function is similar to sqlite3changegroup_change_int64(). Except that
13474
+ ** it configures the change currently under construction with a NULL value
13475
+ ** instead of a 64-bit integer.
13476
+ */
13477
+ SQLITE_API int sqlite3changegroup_change_null(sqlite3_changegroup*, int, int);
13478
+
13479
+ /*
13480
+ ** CAPI3REF: Add an double to a changegroup
13481
+ **
13482
+ ** This function is similar to sqlite3changegroup_change_int64(). Except that
13483
+ ** it configures the change currently being constructed with a real value
13484
+ ** instead of a 64-bit integer.
13485
+ */
13486
+ SQLITE_API int sqlite3changegroup_change_double(sqlite3_changegroup*, int, int, double);
13487
+
13488
+ /*
13489
+ ** CAPI3REF: Add a text value to a changegroup
13490
+ **
13491
+ ** This function is similar to sqlite3changegroup_change_int64(). It configures
13492
+ ** the currently accumulated change with a text value instead of a 64-bit
13493
+ ** integer. Parameter pVal points to a buffer containing the text encoded using
13494
+ ** utf-8. Parameter nVal may either be the size of the text value in bytes, or
13495
+ ** else a negative value, in which case the buffer pVal points to is assumed to
13496
+ ** be nul-terminated.
13497
+ */
13498
+ SQLITE_API int sqlite3changegroup_change_text(
13499
+ sqlite3_changegroup*, int, int, const char *pVal, int nVal
13500
+ );
13501
+
13502
+ /*
13503
+ ** CAPI3REF: Add a blob to a changegroup
13504
+ **
13505
+ ** This function is similar to sqlite3changegroup_change_int64(). It configures
13506
+ ** the currently accumulated change with a blob value instead of a 64-bit
13507
+ ** integer. Parameter pVal points to a buffer containing the blob. Parameter
13508
+ ** nVal is the size of the blob in bytes.
13509
+ */
13510
+ SQLITE_API int sqlite3changegroup_change_blob(
13511
+ sqlite3_changegroup*, int, int, const void *pVal, int nVal
13512
+ );
13513
+
13514
+ /*
13515
+ ** CAPI3REF: Finish adding one-at-at-time changes to a changegroup
13516
+ **
13517
+ ** This function may only be called following a successful call to
13518
+ ** sqlite3changegroup_change_begin(). Otherwise, it is an SQLITE_MISUSE error.
13519
+ **
13520
+ ** If parameter bDiscard is non-zero, then the current change is simply
13521
+ ** discarded. In this case this function is always successful and SQLITE_OK
13522
+ ** returned.
13523
+ **
13524
+ ** If parameter bDiscard is zero, then an attempt is made to add the current
13525
+ ** change to the changegroup. Assuming the changegroup is configured to
13526
+ ** produce a changeset (not a patchset), this requires that:
13527
+ **
13528
+ ** * If the change is an INSERT or DELETE, then a value must be specified
13529
+ ** for all columns of the new.* or old.* record, respectively.
13530
+ **
13531
+ ** * If the change is an UPDATE record, then values must be provided for
13532
+ ** the PRIMARY KEY columns of the old.* record, but must not be provided
13533
+ ** for PRIMARY KEY columns of the new.* record.
13534
+ **
13535
+ ** * If the change is an UPDATE record, then for each non-PRIMARY KEY
13536
+ ** column in the old.* record for which a value has been provided, a
13537
+ ** value must also be provided for the same column in the new.* record.
13538
+ ** Similarly, for each non-PK column in the old.* record for which
13539
+ ** a value is not provided, a value must not be provided for the same
13540
+ ** column in the new.* record.
13541
+ **
13542
+ ** * All values specified for PRIMARY KEY columns must be non-NULL.
13543
+ **
13544
+ ** Otherwise, it is an error.
13545
+ **
13546
+ ** If the changegroup already contains a change for the same row (identified
13547
+ ** by PRIMARY KEY columns), then the current change is combined with the
13548
+ ** existing change in the same way as for sqlite3changegroup_add().
13549
+ **
13550
+ ** For a patchset, all of the above rules apply except that it doesn't matter
13551
+ ** whether or not values are provided for the non-PK old.* record columns
13552
+ ** for an UPDATE or DELETE change. This means that code used to produce
13553
+ ** a changeset using the sqlite3changegroup_change_xxx() APIs may also
13554
+ ** be used to produce patchsets.
13555
+ **
13556
+ ** If the call is successful, SQLITE_OK is returned. Otherwise, if an error
13557
+ ** occurs, an SQLite error code is returned. If an error is returned and
13558
+ ** parameter pzErr is not NULL, then (*pzErr) may be set to point to a buffer
13559
+ ** containing a nul-terminated, utf-8 encoded, English language error message.
13560
+ ** It is the responsibility of the caller to eventually free any such error
13561
+ ** message buffer using sqlite3_free().
13562
+ */
13563
+ SQLITE_API int sqlite3changegroup_change_finish(
13564
+ sqlite3_changegroup*,
13565
+ int bDiscard,
13566
+ char **pzErr
13567
+ );
13568
+
13202
13569
  /*
13203
13570
  ** Make sure we can call this stuff from C++.
13204
13571
  */