amalgalite 2.0.0 → 2.1.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.0"
150
- #define SQLITE_VERSION_NUMBER 3051000
151
- #define SQLITE_SOURCE_ID "2025-11-04 19:38:17 fb2c931ae597f8d00a37574ff67aeed3eced4e5547f9120744ae4bfa8e74527b"
152
- #define SQLITE_SCM_BRANCH "trunk"
153
- #define SQLITE_SCM_TAGS "release major-release version-3.51.0"
154
- #define SQLITE_SCM_DATETIME "2025-11-04T19:38:17.314Z"
149
+ #define SQLITE_VERSION "3.54.1"
150
+ #define SQLITE_VERSION_NUMBER 3054001
151
+ #define SQLITE_SOURCE_ID "2026-10-16 14:45:20 555e07ef33f69a0957d24d8e555b702464a131d6f1607f4c3c1e4551e8e6ca76"
152
+ #define SQLITE_SCM_BRANCH "branch-3.54"
153
+ #define SQLITE_SCM_TAGS "release version-3.54.1"
154
+ #define SQLITE_SCM_DATETIME "2026-10-16T14:45:20.546Z"
155
155
 
156
156
  /*
157
157
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -463,7 +463,7 @@ SQLITE_API int sqlite3_exec(
463
463
  #define SQLITE_FULL 13 /* Insertion failed because database is full */
464
464
  #define SQLITE_CANTOPEN 14 /* Unable to open the database file */
465
465
  #define SQLITE_PROTOCOL 15 /* Database lock protocol error */
466
- #define SQLITE_EMPTY 16 /* Internal use only */
466
+ #define SQLITE_EMPTY 16 /* No content */
467
467
  #define SQLITE_SCHEMA 17 /* The database schema changed */
468
468
  #define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
469
469
  #define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
@@ -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
@@ -2929,8 +2960,9 @@ SQLITE_API int sqlite3_is_interrupted(sqlite3*);
2929
2960
  ** These routines are useful during command-line input to determine if the
2930
2961
  ** currently entered text seems to form a complete SQL statement or
2931
2962
  ** if additional input is needed before sending the text into
2932
- ** SQLite for parsing. ^These routines return 1 if the input string
2933
- ** appears to be a complete SQL statement. ^A statement is judged to be
2963
+ ** SQLite for parsing. ^The sqlite3_complete(X) and sqlite3_complete16(X)
2964
+ ** routines return 1 if the input string X appears to be a complete SQL
2965
+ ** statement. ^A statement is judged to be
2934
2966
  ** complete if it ends with a semicolon token and is not a prefix of a
2935
2967
  ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
2936
2968
  ** string literals or quoted identifier names or comments are not
@@ -2938,11 +2970,25 @@ SQLITE_API int sqlite3_is_interrupted(sqlite3*);
2938
2970
  ** embedded) and thus do not count as a statement terminator. ^Whitespace
2939
2971
  ** and comments that follow the final semicolon are ignored.
2940
2972
  **
2941
- ** ^These routines return 0 if the statement is incomplete. ^If a
2942
- ** memory allocation fails, then SQLITE_NOMEM is returned.
2943
- **
2944
- ** ^These routines do not parse the SQL statements and thus
2945
- ** will not detect syntactically incorrect SQL.
2973
+ ** ^The sqlite3_complete(X) and sqlite3_complete16(X) routines return 0
2974
+ ** if the statement is incomplete. ^If a memory allocation fails, then
2975
+ ** SQLITE_NOMEM is returned.
2976
+ **
2977
+ ** The [sqlite3_incomplete(X)] routine is similar to [sqlite3_complete(X)]
2978
+ ** except that sqlite3_incomplete(X) returns SQLITE_OK if the input X is
2979
+ ** complete, SQLITE_EMPTY if input X consists entirely of whitespace and/or
2980
+ ** comments, SQLITE_MISUSE if X is a NULL pointer, and some other non-zero
2981
+ ** value if X is incomplete. The non-zero return from
2982
+ ** sqlite3_incomplete(X) contains additional information about what is
2983
+ ** needed to complete the input X. See the header comment on the
2984
+ ** implemenation of the sqlite3_incomplete() routine for a full description
2985
+ ** of its non-zero return values. The sqlite3_incomplete(X) interface
2986
+ ** is only available for UTF-8 text.
2987
+ **
2988
+ ** ^None of these routines do a full parse the SQL statements and thus
2989
+ ** will not detect syntactically incorrect SQL. They only determine if
2990
+ ** input text has properly terminated comments, string literals, and
2991
+ ** quoted identifiers, and if the statement ends with a semicolon.
2946
2992
  **
2947
2993
  ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
2948
2994
  ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
@@ -2950,14 +2996,15 @@ SQLITE_API int sqlite3_is_interrupted(sqlite3*);
2950
2996
  ** then the return value from sqlite3_complete16() will be non-zero
2951
2997
  ** regardless of whether or not the input SQL is complete.)^
2952
2998
  **
2953
- ** The input to [sqlite3_complete()] must be a zero-terminated
2954
- ** UTF-8 string.
2999
+ ** The X input to [sqlite3_complete(X)] and [sqlite3_incomplete(X)]
3000
+ ** must be a zero-terminated UTF-8 string.
2955
3001
  **
2956
3002
  ** The input to [sqlite3_complete16()] must be a zero-terminated
2957
3003
  ** UTF-16 string in native byte order.
2958
3004
  */
2959
3005
  SQLITE_API int sqlite3_complete(const char *sql);
2960
3006
  SQLITE_API int sqlite3_complete16(const void *sql);
3007
+ SQLITE_API sqlite3_int64 sqlite3_incomplete(const char *sql);
2961
3008
 
2962
3009
  /*
2963
3010
  ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
@@ -3370,7 +3417,7 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
3370
3417
  **
3371
3418
  ** ^The first parameter to the authorizer callback is a copy of the third
3372
3419
  ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
3373
- ** to the callback is an integer [SQLITE_COPY | action code] that specifies
3420
+ ** to the callback is an integer [SQLITE_READ | action code] that specifies
3374
3421
  ** the particular action to be authorized. ^The third through sixth parameters
3375
3422
  ** to the callback are either NULL pointers or zero-terminated strings
3376
3423
  ** that contain additional details about the action to be authorized.
@@ -3413,21 +3460,33 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
3413
3460
  ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
3414
3461
  ** The authorizer is disabled by default.
3415
3462
  **
3416
- ** The authorizer callback must not do anything that will modify
3463
+ ** <h3>Limitations And Caveats</h3><ul>
3464
+ **
3465
+ ** <li>The authorizer callback must not do anything that will modify
3417
3466
  ** the database connection that invoked the authorizer callback.
3418
3467
  ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3419
3468
  ** database connections for the meaning of "modify" in this paragraph.
3420
3469
  **
3421
- ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
3470
+ ** <li>^When [sqlite3_prepare_v2()] is used to prepare a statement, the
3422
3471
  ** statement might be re-prepared during [sqlite3_step()] due to a
3423
3472
  ** schema change. Hence, the application should ensure that the
3424
3473
  ** correct authorizer callback remains in place during the [sqlite3_step()].
3425
3474
  **
3426
- ** ^Note that the authorizer callback is invoked only during
3475
+ ** <li>^The authorizer callback is invoked only during
3427
3476
  ** [sqlite3_prepare()] or its variants. Authorization is not
3428
3477
  ** performed during statement evaluation in [sqlite3_step()], unless
3429
3478
  ** as stated in the previous paragraph, sqlite3_step() invokes
3430
3479
  ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
3480
+ **
3481
+ ** <li>Authorizer callbacks for the expressions of a
3482
+ ** [generated column] are invoked when the schema is parsed (and specifically
3483
+ ** when the [CREATE TABLE] statement that contains the generated column is
3484
+ ** parsed) not when the generated column is used in a DML statement.
3485
+ ** This is deliberate, as one of the purposes of generated columns
3486
+ ** is to give schema designers the ability to provide gated access
3487
+ ** to privileged columns and/or functions.
3488
+ **
3489
+ ** </ul>
3431
3490
  */
3432
3491
  SQLITE_API int sqlite3_set_authorizer(
3433
3492
  sqlite3*,
@@ -3468,6 +3527,11 @@ SQLITE_API int sqlite3_set_authorizer(
3468
3527
  ** is the name of the inner-most trigger or view that is responsible for
3469
3528
  ** the access attempt or NULL if this access attempt is directly from
3470
3529
  ** top-level SQL code.
3530
+ **
3531
+ ** The case of strings in the 3rd through the 6th argument to the
3532
+ ** authorization callback is arbitrary. Authorization callbacks
3533
+ ** implementations should use [sqlite3_stricmp()] or similar when
3534
+ ** doing comparisons against those values.
3471
3535
  */
3472
3536
  /******************************************* 3rd ************ 4th ***********/
3473
3537
  #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
@@ -3502,9 +3566,14 @@ SQLITE_API int sqlite3_set_authorizer(
3502
3566
  #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
3503
3567
  #define SQLITE_FUNCTION 31 /* NULL Function Name */
3504
3568
  #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
3505
- #define SQLITE_COPY 0 /* No longer used */
3506
3569
  #define SQLITE_RECURSIVE 33 /* NULL NULL */
3507
3570
 
3571
+ /*
3572
+ ** Note: The SQLITE_COPY macro (with value 0) used to be one of the
3573
+ ** action codes above. That macro has now been repurposed as a possible
3574
+ ** value to the 3rd argument to sqlite3_result_str().
3575
+ */
3576
+
3508
3577
  /*
3509
3578
  ** CAPI3REF: Deprecated Tracing And Profiling Functions
3510
3579
  ** DEPRECATED
@@ -4011,8 +4080,7 @@ SQLITE_API int sqlite3_open_v2(
4011
4080
  **
4012
4081
  ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
4013
4082
  ** 64-bit signed integer and returns that integer, or D if P does not
4014
- ** exist. If the value of P is something other than an integer, then
4015
- ** zero is returned.
4083
+ ** exist or if the value of P is something other than an integer.
4016
4084
  **
4017
4085
  ** The sqlite3_uri_key(F,N) returns a pointer to the name (not
4018
4086
  ** the value) of the N-th query parameter for filename F, or a NULL
@@ -4171,6 +4239,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
4171
4239
  ** <li> sqlite3_errmsg()
4172
4240
  ** <li> sqlite3_errmsg16()
4173
4241
  ** <li> sqlite3_error_offset()
4242
+ ** <li> sqlite3_db_handle()
4174
4243
  ** </ul>
4175
4244
  **
4176
4245
  ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -4217,7 +4286,7 @@ SQLITE_API const char *sqlite3_errstr(int);
4217
4286
  SQLITE_API int sqlite3_error_offset(sqlite3 *db);
4218
4287
 
4219
4288
  /*
4220
- ** CAPI3REF: Set Error Codes And Message
4289
+ ** CAPI3REF: Set Error Code And Message
4221
4290
  ** METHOD: sqlite3
4222
4291
  **
4223
4292
  ** Set the error code of the database handle passed as the first argument
@@ -4334,7 +4403,12 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4334
4403
  ** or in an ORDER BY or GROUP BY clause.</dd>)^
4335
4404
  **
4336
4405
  ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
4337
- ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
4406
+ ** <dd>The maximum depth of the parse tree on any expression and
4407
+ ** the maximum nesting depth for subqueries and VIEWs</dd>)^
4408
+ **
4409
+ ** [[SQLITE_LIMIT_PARSER_DEPTH]] ^(<dt>SQLITE_LIMIT_PARSER_DEPTH</dt>
4410
+ ** <dd>The maximum depth of the LALR(1) parser stack used to analyze
4411
+ ** input SQL statements.</dd>)^
4338
4412
  **
4339
4413
  ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
4340
4414
  ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
@@ -4361,11 +4435,20 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4361
4435
  ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
4362
4436
  **
4363
4437
  ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
4364
- ** <dd>The maximum depth of recursion for triggers.</dd>)^
4438
+ ** <dd>The maximum depth of recursion for triggers, and the maximum
4439
+ ** nesting depth for separate triggers.</dd>)^
4365
4440
  **
4366
4441
  ** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
4367
4442
  ** <dd>The maximum number of auxiliary worker threads that a single
4368
4443
  ** [prepared statement] may start.</dd>)^
4444
+ **
4445
+ ** [[SQLITE_LIMIT_SCHEMA]] ^(<dt>SQLITE_LIMIT_SCHEMA</dt>
4446
+ ** <dd>The maximum number of objects (tables, indexes, triggers, and views)
4447
+ ** defined by the database schema.</dd>)^
4448
+ **
4449
+ ** [[SQLITE_LIMIT_TRIGGER_STEPS]] ^(<dt>SQLITE_LIMIT_TRIGGER_STEPS</dt>
4450
+ ** <dd>The maximum number of SQL statements that can be contained within
4451
+ ** a single trigger.</dd>)^
4369
4452
  ** </dl>
4370
4453
  */
4371
4454
  #define SQLITE_LIMIT_LENGTH 0
@@ -4380,6 +4463,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4380
4463
  #define SQLITE_LIMIT_VARIABLE_NUMBER 9
4381
4464
  #define SQLITE_LIMIT_TRIGGER_DEPTH 10
4382
4465
  #define SQLITE_LIMIT_WORKER_THREADS 11
4466
+ #define SQLITE_LIMIT_PARSER_DEPTH 12
4467
+ #define SQLITE_LIMIT_SCHEMA 13
4468
+ #define SQLITE_LIMIT_TRIGGER_STEPS 14
4383
4469
 
4384
4470
  /*
4385
4471
  ** CAPI3REF: Prepare Flags
@@ -4424,12 +4510,29 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4424
4510
  ** fails, the sqlite3_prepare_v3() call returns the same error indications
4425
4511
  ** with or without this flag; it just omits the call to [sqlite3_log()] that
4426
4512
  ** logs the error.
4513
+ **
4514
+ ** [[SQLITE_PREPARE_FROM_DDL]] <dt>SQLITE_PREPARE_FROM_DDL</dt>
4515
+ ** <dd>The SQLITE_PREPARE_FROM_DDL flag causes the SQL compiler to enforce
4516
+ ** security constraints that would otherwise only be enforced when parsing
4517
+ ** the database schema. In other words, the SQLITE_PREPARE_FROM_DDL flag
4518
+ ** causes the SQL compiler to treat the SQL statement being prepared as if
4519
+ ** it had come from an attacker. When SQLITE_PREPARE_FROM_DDL is used and
4520
+ ** [SQLITE_DBCONFIG_TRUSTED_SCHEMA] is off, SQL functions may only be called
4521
+ ** if they are tagged with [SQLITE_INNOCUOUS] and virtual tables may only
4522
+ ** be used if they are tagged with [SQLITE_VTAB_INNOCUOUS]. Best practice
4523
+ ** is to use the SQLITE_PREPARE_FROM_DDL option when preparing any SQL that
4524
+ ** is derived from parts of the database schema. In particular, virtual
4525
+ ** table implementations that run SQL statements that are derived from
4526
+ ** arguments to their CREATE VIRTUAL TABLE statement should always use
4527
+ ** [sqlite3_prepare_v3()] and set the SQLITE_PREPARE_FROM_DDL flag to
4528
+ ** prevent bypass of the [SQLITE_DBCONFIG_TRUSTED_SCHEMA] security checks.
4427
4529
  ** </dl>
4428
4530
  */
4429
4531
  #define SQLITE_PREPARE_PERSISTENT 0x01
4430
4532
  #define SQLITE_PREPARE_NORMALIZE 0x02
4431
4533
  #define SQLITE_PREPARE_NO_VTAB 0x04
4432
4534
  #define SQLITE_PREPARE_DONT_LOG 0x10
4535
+ #define SQLITE_PREPARE_FROM_DDL 0x20
4433
4536
 
4434
4537
  /*
4435
4538
  ** CAPI3REF: Compiling An SQL Statement
@@ -4443,8 +4546,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4443
4546
  **
4444
4547
  ** The preferred routine to use is [sqlite3_prepare_v2()]. The
4445
4548
  ** [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.
4549
+ ** [sqlite3_prepare_v3()] has an extra
4550
+ ** [SQLITE_PREPARE_FROM_DDL|"prepFlags" option] that is sometimes
4551
+ ** needed for special purpose or to pass along security restrictions.
4448
4552
  **
4449
4553
  ** The use of the UTF-8 interfaces is preferred, as SQLite currently
4450
4554
  ** does all parsing using UTF-8. The UTF-16 interfaces are provided
@@ -4473,6 +4577,8 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4473
4577
  ** the nul-terminator.
4474
4578
  ** Note that nByte measures the length of the input in bytes, not
4475
4579
  ** characters, even for the UTF-16 interfaces.
4580
+ ** For the sqlite3_prepare16() and sqlite3_prepare16_v2() interfaces,
4581
+ ** the nByte value must be even or undefined behavior can result.
4476
4582
  **
4477
4583
  ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
4478
4584
  ** past the end of the first SQL statement in zSql. These routines only
@@ -4849,8 +4955,8 @@ typedef struct sqlite3_context sqlite3_context;
4849
4955
  ** it should be a pointer to well-formed UTF16 text.
4850
4956
  ** ^If the third parameter to sqlite3_bind_text64() is not NULL, then
4851
4957
  ** 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.
4958
+ ** either UTF8 if the sixth parameter is SQLITE_UTF8 or SQLITE_UTF8_ZT,
4959
+ ** or UTF16 otherwise.
4854
4960
  **
4855
4961
  ** [[byte-order determination rules]] ^The byte-order of
4856
4962
  ** UTF16 input text is determined by the byte-order mark (BOM, U+FEFF)
@@ -4896,10 +5002,15 @@ typedef struct sqlite3_context sqlite3_context;
4896
5002
  ** object and pointer to it must remain valid until then. ^SQLite will then
4897
5003
  ** manage the lifetime of its private copy.
4898
5004
  **
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
5005
+ ** ^The sixth argument (the E argument)
5006
+ ** to sqlite3_bind_text64(S,K,Z,N,D,E) must be one of
5007
+ ** [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
5008
+ ** or [SQLITE_UTF16LE] to specify the encoding of the text in the
5009
+ ** third parameter, Z. The special value [SQLITE_UTF8_ZT] means that the
5010
+ ** string argument is both UTF-8 encoded and is zero-terminated. In other
5011
+ ** words, SQLITE_UTF8_ZT means that the Z array is allocated to hold at
5012
+ ** least N+1 bytes and that the Z&#91;N&#93; byte is zero. If
5013
+ ** the E argument to sqlite3_bind_text64(S,K,Z,N,D,E) is not one of the
4903
5014
  ** allowed values shown above, or if the text encoding is different
4904
5015
  ** from the encoding specified by the sixth parameter, then the behavior
4905
5016
  ** is undefined.
@@ -5214,7 +5325,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
5214
5325
  ** [prepared statement]. ^In the "v2" interface,
5215
5326
  ** the more specific error code is returned directly by sqlite3_step().
5216
5327
  **
5217
- ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
5328
+ ** [SQLITE_MISUSE] means that this routine was called inappropriately.
5218
5329
  ** Perhaps it was called on a [prepared statement] that has
5219
5330
  ** already been [sqlite3_finalize | finalized] or on one that had
5220
5331
  ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could
@@ -5766,6 +5877,52 @@ SQLITE_API int sqlite3_create_window_function(
5766
5877
  **
5767
5878
  ** These constants define integer codes that represent the various
5768
5879
  ** text encodings supported by SQLite.
5880
+ **
5881
+ ** <dl>
5882
+ ** [[SQLITE_UTF8]] <dt>SQLITE_UTF8</dt><dd>Text is encoding as UTF-8</dd>
5883
+ **
5884
+ ** [[SQLITE_UTF16LE]] <dt>SQLITE_UTF16LE</dt><dd>Text is encoding as UTF-16
5885
+ ** with each code point being expressed "little endian" - the least significant
5886
+ ** byte first. This is the usual encoding, for example on Windows.</dd>
5887
+ **
5888
+ ** [[SQLITE_UTF16BE]] <dt>SQLITE_UTF16BE</dt><dd>Text is encoding as UTF-16
5889
+ ** with each code point being expressed "big endian" - the most significant
5890
+ ** byte first. This encoding is less common, but is still sometimes seen,
5891
+ ** specially on older systems.
5892
+ **
5893
+ ** [[SQLITE_UTF16]] <dt>SQLITE_UTF16</dt><dd>Text is encoding as UTF-16
5894
+ ** with each code point being expressed either little endian or as big
5895
+ ** endian, according to the native endianness of the host computer.
5896
+ **
5897
+ ** [[SQLITE_ANY]] <dt>SQLITE_ANY</dt><dd>This encoding value may only be used
5898
+ ** to declare the preferred text for [application-defined SQL functions]
5899
+ ** created using [sqlite3_create_function()] and similar. If the preferred
5900
+ ** encoding (the 4th parameter to sqlite3_create_function() - the eTextRep
5901
+ ** parameter) is SQLITE_ANY, that indicates that the function does not have
5902
+ ** a preference regarding the text encoding of its parameters and can take
5903
+ ** any text encoding that the SQLite core find convenient to supply. This
5904
+ ** option is deprecated. Please do not use it in new applications.
5905
+ **
5906
+ ** [[SQLITE_UTF16_ALIGNED]] <dt>SQLITE_UTF16_ALIGNED</dt><dd>This encoding
5907
+ ** value may be used as the 3rd parameter (the eTextRep parameter) to
5908
+ ** [sqlite3_create_collation()] and similar. This encoding value means
5909
+ ** that the application-defined collating sequence created expects its
5910
+ ** input strings to be in UTF16 in native byte order, and that the start
5911
+ ** of the strings must be aligned to a 2-byte boundary.
5912
+ **
5913
+ ** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
5914
+ ** used to specify the text encoding to strings input to
5915
+ ** [sqlite3_result_text64()] and [sqlite3_bind_text64()].
5916
+ ** The SQLITE_UTF8_ZT encoding means that the input string (call it "z")
5917
+ ** is UTF-8 encoded and that it is zero-terminated. If the length parameter
5918
+ ** (call it "n") is non-negative, this encoding option means that the caller
5919
+ ** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
5920
+ ** byte has a value of zero.
5921
+ ** This option gives the same output as SQLITE_UTF8, but can be more efficient
5922
+ ** by avoiding the need to make a copy of the input string, in some cases.
5923
+ ** However, if z is allocated to hold fewer than n+1 bytes or if the
5924
+ ** z&#91;n&#93; byte is not zero, undefined behavior may result.
5925
+ ** </dl>
5769
5926
  */
5770
5927
  #define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
5771
5928
  #define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
@@ -5773,6 +5930,7 @@ SQLITE_API int sqlite3_create_window_function(
5773
5930
  #define SQLITE_UTF16 4 /* Use native byte order */
5774
5931
  #define SQLITE_ANY 5 /* Deprecated */
5775
5932
  #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
5933
+ #define SQLITE_UTF8_ZT 16 /* Zero-terminated UTF8 */
5776
5934
 
5777
5935
  /*
5778
5936
  ** CAPI3REF: Function Flags
@@ -6007,26 +6165,22 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
6007
6165
  ** the SQL function that supplied the [sqlite3_value*] parameters.
6008
6166
  **
6009
6167
  ** 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
- **
6168
+ ** fail if an out-of-memory error occurs while trying to do a
6169
+ ** UTF8&rarr;UTF16 or UTF16&rarr;UTF8 conversion.
6024
6170
  ** If an out-of-memory error occurs, then the return value from these
6025
6171
  ** 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
6172
+ ** If the input sqlite3_value was not obtained from [sqlite3_value_dup()],
6173
+ ** then valid SQL NULL returns can also be distinguished from
6174
+ ** out-of-memory errors after extracting the value
6175
+ ** by invoking the [sqlite3_errcode()] immediately after the suspicious
6028
6176
  ** return value is obtained and before any
6029
6177
  ** other SQLite interface is called on the same [database connection].
6178
+ ** If the input sqlite3_value was obtained from sqlite3_value_dup() then
6179
+ ** it is disconnected from the database connection and so sqlite3_errcode()
6180
+ ** will not work.
6181
+ ** In that case, the only way to distinguish an out-of-memory
6182
+ ** condition from a true SQL NULL is to invoke sqlite3_value_type() on the
6183
+ ** input to see if it is NULL prior to trying to extract the value.
6030
6184
  */
6031
6185
  SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
6032
6186
  SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -6053,7 +6207,8 @@ SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
6053
6207
  ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
6054
6208
  ** returns something other than SQLITE_TEXT, then the return value from
6055
6209
  ** sqlite3_value_encoding(X) is meaningless. ^Calls to
6056
- ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)],
6210
+ ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)],
6211
+ ** [sqlite3_value_text16be(X)],
6057
6212
  ** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
6058
6213
  ** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
6059
6214
  ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
@@ -6184,17 +6339,17 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
6184
6339
  ** query execution, under some circumstances the associated auxiliary data
6185
6340
  ** might be preserved. An example of where this might be useful is in a
6186
6341
  ** 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,
6342
+ ** expression can be stored as auxiliary data associated with the pattern
6343
+ ** string. Then as long as the pattern string remains the same,
6189
6344
  ** the compiled regular expression can be reused on multiple
6190
6345
  ** invocations of the same function.
6191
6346
  **
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.
6347
+ ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary
6348
+ ** data associated by the sqlite3_set_auxdata(C,N,P,X) function with the
6349
+ ** Nth argument value to the application-defined function. ^N is zero
6350
+ ** for the left-most function argument. ^If there is no auxiliary data
6351
+ ** associated with the function argument, the sqlite3_get_auxdata(C,N)
6352
+ ** interface returns a NULL pointer.
6198
6353
  **
6199
6354
  ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6200
6355
  ** N-th argument of the application-defined function. ^Subsequent
@@ -6278,10 +6433,14 @@ SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(voi
6278
6433
  **
6279
6434
  ** There is no limit (other than available memory) on the number of different
6280
6435
  ** 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.
6436
+ ** single database connection. However, the current implementation stores
6437
+ ** the content on a linked list. Insert and retrieval performance will
6438
+ ** be proportional to the number of entries. The design use case, and
6439
+ ** the use case for which the implementation is optimized, is
6440
+ ** that an application will store only small number of client data names,
6441
+ ** typically just one or two. This interface is not intended to be a
6442
+ ** generalized key/value store for thousands or millions of keys. It
6443
+ ** will work for that, but performance might be disappointing.
6285
6444
  **
6286
6445
  ** There is no way to enumerate the client data pointers
6287
6446
  ** associated with a database connection. The N parameter can be thought
@@ -6339,7 +6498,11 @@ typedef void (*sqlite3_destructor_type)(void*);
6339
6498
  **
6340
6499
  ** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
6341
6500
  ** interfaces set the result of the application-defined function to be
6342
- ** a BLOB containing all zero bytes and N bytes in size.
6501
+ ** a BLOB containing all zero bytes and N bytes in size. The
6502
+ ** zeroblob64(C,N) interface returns a [result code], which is normally
6503
+ ** [SQLITE_OK] but might be some other value if the requested operation
6504
+ ** could not be complete, for example if insufficient memory is available
6505
+ ** or if the value of N is out of range.
6343
6506
  **
6344
6507
  ** ^The sqlite3_result_double() interface sets the result from
6345
6508
  ** an application-defined function to be a floating point value specified
@@ -6389,10 +6552,14 @@ typedef void (*sqlite3_destructor_type)(void*);
6389
6552
  ** set the return value of the application-defined function to be
6390
6553
  ** a text string which is represented as UTF-8, UTF-16 native byte order,
6391
6554
  ** UTF-16 little endian, or UTF-16 big endian, respectively.
6392
- ** ^The sqlite3_result_text64() interface sets the return value of an
6555
+ ** ^The sqlite3_result_text64(C,Z,N,D,E) interface sets the return value of an
6393
6556
  ** 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].
6557
+ ** specified the E parameter, which must be one
6558
+ ** of [SQLITE_UTF8], [SQLITE_UTF8_ZT], [SQLITE_UTF16], [SQLITE_UTF16BE],
6559
+ ** or [SQLITE_UTF16LE]. ^The special value [SQLITE_UTF8_ZT] means that
6560
+ ** the result text is both UTF-8 and zero-terminated. In other words,
6561
+ ** SQLITE_UTF8_ZT means that the Z array holds at least N+1 bytes and that
6562
+ ** the Z&#91;N&#93; is zero.
6396
6563
  ** ^SQLite takes the text result from the application from
6397
6564
  ** the 2nd parameter of the sqlite3_result_text* interfaces.
6398
6565
  ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
@@ -6479,7 +6646,7 @@ SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
6479
6646
  SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
6480
6647
  SQLITE_API void sqlite3_result_null(sqlite3_context*);
6481
6648
  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,
6649
+ SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char *z, sqlite3_uint64 n,
6483
6650
  void(*)(void*), unsigned char encoding);
6484
6651
  SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
6485
6652
  SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
@@ -7418,7 +7585,7 @@ SQLITE_API int sqlite3_table_column_metadata(
7418
7585
  ** ^The sqlite3_load_extension() interface attempts to load an
7419
7586
  ** [SQLite extension] library contained in the file zFile. If
7420
7587
  ** the file cannot be loaded directly, attempts are made to load
7421
- ** with various operating-system specific extensions added.
7588
+ ** with various operating-system specific filename extensions added.
7422
7589
  ** So for example, if "samplelib" cannot be loaded, then names like
7423
7590
  ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
7424
7591
  ** be tried also.
@@ -7426,10 +7593,10 @@ SQLITE_API int sqlite3_table_column_metadata(
7426
7593
  ** ^The entry point is zProc.
7427
7594
  ** ^(zProc may be 0, in which case SQLite will try to come up with an
7428
7595
  ** 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".)^
7596
+ ** If that does not work, it tries names of the form "sqlite3_X_init"
7597
+ ** where X consists of the lower-case equivalent of all ASCII alphabetic
7598
+ ** characters or all ASCII alphanumeric characters in the filename from
7599
+ ** the last "/" to the first following "." and omitting any initial "lib".)^
7433
7600
  ** ^The sqlite3_load_extension() interface returns
7434
7601
  ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
7435
7602
  ** ^If an error occurs and pzErrMsg is not 0, then the
@@ -7503,7 +7670,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
7503
7670
  ** <blockquote><pre>
7504
7671
  ** &nbsp; int xEntryPoint(
7505
7672
  ** &nbsp; sqlite3 *db,
7506
- ** &nbsp; const char **pzErrMsg,
7673
+ ** &nbsp; char **pzErrMsg,
7507
7674
  ** &nbsp; const struct sqlite3_api_routines *pThunk
7508
7675
  ** &nbsp; );
7509
7676
  ** </pre></blockquote>)^
@@ -8253,13 +8420,6 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
8253
8420
  ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
8254
8421
  ** and Windows.
8255
8422
  **
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
8423
  **
8264
8424
  ** ^The sqlite3_mutex_alloc() routine allocates a new
8265
8425
  ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
@@ -8614,6 +8774,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8614
8774
  #define SQLITE_TESTCTRL_TUNE 32
8615
8775
  #define SQLITE_TESTCTRL_LOGEST 33
8616
8776
  #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
8777
+ #define SQLITE_TESTCTRL_ATOF 34
8617
8778
  #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8618
8779
 
8619
8780
  /*
@@ -8679,8 +8840,8 @@ SQLITE_API int sqlite3_keyword_check(const char*,int);
8679
8840
  ** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
8680
8841
  ** <li> ^Text is appended to the sqlite3_str object using various
8681
8842
  ** methods, such as [sqlite3_str_appendf()].
8682
- ** <li> ^The sqlite3_str object is destroyed and the string it created
8683
- ** is returned using the [sqlite3_str_finish()] interface.
8843
+ ** <li> The sqlite3_str object is destroyed and the string it created
8844
+ ** is returned using [sqlite3_str_finish()] or [sqlite3_result_str()].
8684
8845
  ** </ol>
8685
8846
  */
8686
8847
  typedef struct sqlite3_str sqlite3_str;
@@ -8722,17 +8883,56 @@ SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);
8722
8883
  ** pass the returned value to [sqlite3_free()] to avoid a memory leak.
8723
8884
  ** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any
8724
8885
  ** errors were encountered during construction of the string. ^The
8725
- ** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the
8886
+ ** [sqlite3_str_finish(X)] interface might also return a NULL pointer if the
8726
8887
  ** string in [sqlite3_str] object X is zero bytes long.
8888
+ **
8889
+ ** ^The [sqlite3_str_free(X)] interface destroys both the sqlite3_str object
8890
+ ** X and the string content it contains. Calling sqlite3_str_free(X) is
8891
+ ** the equivalent of calling [sqlite3_free](sqlite3_str_finish(X)).
8727
8892
  */
8728
8893
  SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
8894
+ SQLITE_API void sqlite3_str_free(sqlite3_str*);
8895
+
8896
+ /*
8897
+ ** CAPI3REF: Return A Dynamic String From an SQL Function
8898
+ **
8899
+ ** The [sqlite3_result_str(C,S,F)] interface causes the
8900
+ ** [sqlite3_str|dynamic string] S to become the return value for the
8901
+ ** application-defined function or virtual table that uses
8902
+ ** [sqlite3_context] C. The F flag can be one of [SQLITE_COPY]
8903
+ ** or [SQLITE_XFER] or [SQLITE_FINISH].
8904
+ **
8905
+ ** If the dynamic string is invalid or incomplete due to an out-of-memory
8906
+ ** or string-too-large error, then this routine transfers that error
8907
+ ** over to the SQL function.
8908
+ **
8909
+ ** If the F argument is SQLITE_COPY, then a copy of the dynamic string
8910
+ ** content is made and the dynamic string object is unchanged.
8911
+ ** If the F argument is SQLITE_XFER, then ownership of the content
8912
+ ** in the dynamic is transferred to the SQL function (via a pointer copy
8913
+ ** rather than a string copy) and the dynamic string is reset to an
8914
+ ** empty string. The SQLITE_FINISH value for F works like SQLITE_RESET
8915
+ ** except that it also invokes the [sqlite3_str_free(S)] destructor
8916
+ ** on the dynamic string object.
8917
+ */
8918
+ SQLITE_API void sqlite3_result_str(sqlite3_context*, sqlite3_str*, int);
8919
+
8920
+ /*
8921
+ ** CAPI3REF: Control Flags For sqlite3_result_str()
8922
+ **
8923
+ ** The following integers can be used as the third "F" argument
8924
+ ** to [sqlite3_result_str(C,S,F)].
8925
+ */
8926
+ #define SQLITE_COPY 0 /* Results copied. Dynamic string unchanged */
8927
+ #define SQLITE_XFER 1 /* Results transfered. Dynamic string reset */
8928
+ #define SQLITE_FINISH 2 /* Like SQLITE_XFER, plus dynamic string freed */
8729
8929
 
8730
8930
  /*
8731
8931
  ** CAPI3REF: Add Content To A Dynamic String
8732
8932
  ** METHOD: sqlite3_str
8733
8933
  **
8734
- ** These interfaces add content to an sqlite3_str object previously obtained
8735
- ** from [sqlite3_str_new()].
8934
+ ** These interfaces add or remove content to an sqlite3_str object
8935
+ ** previously obtained from [sqlite3_str_new()].
8736
8936
  **
8737
8937
  ** ^The [sqlite3_str_appendf(X,F,...)] and
8738
8938
  ** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]
@@ -8755,6 +8955,10 @@ SQLITE_API char *sqlite3_str_finish(sqlite3_str*);
8755
8955
  ** ^The [sqlite3_str_reset(X)] method resets the string under construction
8756
8956
  ** inside [sqlite3_str] object X back to zero bytes in length.
8757
8957
  **
8958
+ ** ^The [sqlite3_str_truncate(X,N)] method changes the length of the string
8959
+ ** under construction to be N bytes or less. This routine is a no-op if
8960
+ ** N is negative or if the string is already N bytes or smaller in size.
8961
+ **
8758
8962
  ** These methods do not return a result code. ^If an error occurs, that fact
8759
8963
  ** is recorded in the [sqlite3_str] object and can be recovered by a
8760
8964
  ** subsequent call to [sqlite3_str_errcode(X)].
@@ -8765,6 +8969,7 @@ SQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);
8765
8969
  SQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);
8766
8970
  SQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);
8767
8971
  SQLITE_API void sqlite3_str_reset(sqlite3_str*);
8972
+ SQLITE_API void sqlite3_str_truncate(sqlite3_str*,int N);
8768
8973
 
8769
8974
  /*
8770
8975
  ** CAPI3REF: Status Of A Dynamic String
@@ -10295,7 +10500,8 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10295
10500
  ** <tr>
10296
10501
  ** <td valign="top">sqlite3_vtab_distinct() return value
10297
10502
  ** <td valign="top">Rows are returned in aOrderBy order
10298
- ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
10503
+ ** <td valign="top">Rows with the same value in all aOrderBy columns are
10504
+ ** adjacent
10299
10505
  ** <td valign="top">Duplicates over all colUsed columns may be omitted
10300
10506
  ** <tr><td>0<td>yes<td>yes<td>no
10301
10507
  ** <tr><td>1<td>no<td>yes<td>no
@@ -10304,8 +10510,8 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
10304
10510
  ** </table>
10305
10511
  **
10306
10512
  ** ^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"
10513
+ ** values are the same value for sorting purposes, two NULL values are
10514
+ ** considered to be the same. In other words, the comparison operator is "IS"
10309
10515
  ** (or "IS NOT DISTINCT FROM") and not "==".
10310
10516
  **
10311
10517
  ** If a virtual table implementation is unable to meet the requirements
@@ -10426,7 +10632,7 @@ SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
10426
10632
  ** &nbsp; ){
10427
10633
  ** &nbsp; // do something with pVal
10428
10634
  ** &nbsp; }
10429
- ** &nbsp; if( rc!=SQLITE_OK ){
10635
+ ** &nbsp; if( rc!=SQLITE_DONE ){
10430
10636
  ** &nbsp; // an error has occurred
10431
10637
  ** &nbsp; }
10432
10638
  ** </pre></blockquote>)^
@@ -10598,9 +10804,9 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10598
10804
  ** a variable pointed to by the "pOut" parameter.
10599
10805
  **
10600
10806
  ** 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
10807
+ ** one flag is defined - [SQLITE_SCANSTAT_COMPLEX]. If SQLITE_SCANSTAT_COMPLEX
10602
10808
  ** is specified, then status information is available for all elements
10603
- ** of a query plan that are reported by "EXPLAIN QUERY PLAN" output. If
10809
+ ** of a query plan that are reported by "[EXPLAIN QUERY PLAN]" output. If
10604
10810
  ** SQLITE_SCANSTAT_COMPLEX is not specified, then only query plan elements
10605
10811
  ** that correspond to query loops (the "SCAN..." and "SEARCH..." elements of
10606
10812
  ** the EXPLAIN QUERY PLAN output) are available. Invoking API
@@ -10614,7 +10820,8 @@ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **
10614
10820
  ** elements used to implement the statement - a non-zero value is returned and
10615
10821
  ** the variable that pOut points to is unchanged.
10616
10822
  **
10617
- ** See also: [sqlite3_stmt_scanstatus_reset()]
10823
+ ** See also: [sqlite3_stmt_scanstatus_reset()] and the
10824
+ ** [nexec and ncycle] columns of the [bytecode virtual table].
10618
10825
  */
10619
10826
  SQLITE_API int sqlite3_stmt_scanstatus(
10620
10827
  sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
@@ -11085,8 +11292,19 @@ SQLITE_API unsigned char *sqlite3_serialize(
11085
11292
  ** used. The serialized database P is N bytes in size. M is the size
11086
11293
  ** of the buffer P, which might be larger than N. If M is larger than
11087
11294
  ** N, and the SQLITE_DESERIALIZE_READONLY bit is not set in F, then
11088
- ** SQLite is permitted to add content to the in-memory database as
11089
- ** long as the total size does not exceed M bytes.
11295
+ ** SQLite is permitted to add content to the in-memory database, in
11296
+ ** page-sized chunks, as long as the total size does not exceed M bytes.
11297
+ **
11298
+ ** The parameter M must be greater than or equal to N. Ideally, M
11299
+ ** should have a value which is N+(512&times;K)+20 where K determines how
11300
+ ** must extra space is available to hold new content as the database
11301
+ ** grows. K can be 0 if the database is read-only.
11302
+ **
11303
+ ** If the database content in P is malformed in a malicious way then
11304
+ ** it is possible that SQLite might try to read a few more than N bytes
11305
+ ** from P. If the veracity of the database content P is uncertain,
11306
+ ** then applications are advised to allocate about 20 extra bytes on
11307
+ ** the end of the P buffer to avoid a memory error.
11090
11308
  **
11091
11309
  ** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will
11092
11310
  ** invoke sqlite3_free() on the serialization buffer when the database
@@ -11156,19 +11374,42 @@ SQLITE_API int sqlite3_deserialize(
11156
11374
  /*
11157
11375
  ** CAPI3REF: Bind array values to the CARRAY table-valued function
11158
11376
  **
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
- */
11377
+ ** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
11378
+ ** parameter that is the first argument of the [carray() table-valued function].
11379
+ ** The S parameter is a pointer to the [prepared statement] that uses the
11380
+ ** carray() functions. I is the parameter index to be bound. I must be the
11381
+ ** index of the parameter that is the first argument to the carray()
11382
+ ** table-valued function. P is a pointer to the array to be bound, and N
11383
+ ** is the number of elements in the array. The F argument is one of
11384
+ ** constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64],
11385
+ ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
11386
+ ** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
11387
+ **
11388
+ ** If the X argument is not a NULL pointer or one of the special
11389
+ ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11390
+ ** the function X with argument D when it is finished using the data in P.
11391
+ ** The call to X(D) is a destructor for the array P. The destructor X(D)
11392
+ ** is invoked even if the call to sqlite3_carray_bind_v2() fails. If the X
11393
+ ** parameter is the special-case value [SQLITE_STATIC], then SQLite assumes
11394
+ ** that the data static and the destructor is never invoked. If the X
11395
+ ** parameter is the special-case value [SQLITE_TRANSIENT], then
11396
+ ** sqlite3_carray_bind_v2() makes its own private copy of the data prior
11397
+ ** to returning and never invokes the destructor X.
11398
+ **
11399
+ ** The sqlite3_carray_bind() function works the same as sqlite3_carray_bind_v2()
11400
+ ** with a D parameter set to P. In other words,
11401
+ ** sqlite3_carray_bind(S,I,P,N,F,X) is same as
11402
+ ** sqlite3_carray_bind_v2(S,I,P,N,F,X,P).
11403
+ */
11404
+ SQLITE_API int sqlite3_carray_bind_v2(
11405
+ sqlite3_stmt *pStmt, /* Statement to be bound */
11406
+ int i, /* Parameter index */
11407
+ void *aData, /* Pointer to array data */
11408
+ int nData, /* Number of data elements */
11409
+ int mFlags, /* CARRAY flags */
11410
+ void (*xDel)(void*), /* Destructor for aData */
11411
+ void *pDel /* Optional argument to xDel() */
11412
+ );
11172
11413
  SQLITE_API int sqlite3_carray_bind(
11173
11414
  sqlite3_stmt *pStmt, /* Statement to be bound */
11174
11415
  int i, /* Parameter index */
@@ -12712,11 +12953,23 @@ SQLITE_API int sqlite3changeset_apply_v3(
12712
12953
  ** database behave as if they were declared with "ON UPDATE NO ACTION ON
12713
12954
  ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
12714
12955
  ** or SET DEFAULT.
12956
+ **
12957
+ ** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
12958
+ ** Sometimes, a changeset contains two or more update statements such that
12959
+ ** although after applying all updates the database will contain no
12960
+ ** constraint violations, no single update can be applied before the others.
12961
+ ** The simplest example of this is a pair of UPDATEs that have "swapped"
12962
+ ** two column values with a UNIQUE constraint.
12963
+ ** <p>
12964
+ ** Usually, sqlite3changeset_apply() and similar functions work hard to try
12965
+ ** to find a way to apply such a changeset. However, if this flag is set,
12966
+ ** then all such updates are considered CONSTRAINT conflicts.
12715
12967
  */
12716
12968
  #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12717
12969
  #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12718
12970
  #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12719
12971
  #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
12972
+ #define SQLITE_CHANGESETAPPLY_NOUPDATELOOP 0x0010
12720
12973
 
12721
12974
  /*
12722
12975
  ** CAPI3REF: Constants Passed To The Conflict Handler
@@ -13199,6 +13452,232 @@ SQLITE_API int sqlite3session_config(int op, void *pArg);
13199
13452
  */
13200
13453
  #define SQLITE_SESSION_CONFIG_STRMSIZE 1
13201
13454
 
13455
+ /*
13456
+ ** CAPI3REF: Configure a changegroup object
13457
+ **
13458
+ ** Configure the changegroup object passed as the first argument.
13459
+ ** At present the only valid value for the second parameter is
13460
+ ** [SQLITE_CHANGEGROUP_CONFIG_PATCHSET].
13461
+ */
13462
+ SQLITE_API int sqlite3changegroup_config(sqlite3_changegroup*, int, void *pArg);
13463
+
13464
+ /*
13465
+ ** CAPI3REF: Options for sqlite3changegroup_config().
13466
+ **
13467
+ ** The following values may be passed as the 2nd parameter to
13468
+ ** sqlite3changegroup_config().
13469
+ **
13470
+ ** <dt>SQLITE_CHANGEGROUP_CONFIG_PATCHSET <dd>
13471
+ ** A changegroup object generates either a changeset or patchset. Usually,
13472
+ ** this is determined by whether the first call to sqlite3changegroup_add()
13473
+ ** is passed a changeset or a patchset. Or, if the first changes are added
13474
+ ** to the changegroup object using the sqlite3changegroup_change_xxx()
13475
+ ** APIs, then this option may be used to configure whether the changegroup
13476
+ ** object generates a changeset or patchset.
13477
+ **
13478
+ ** When this option is invoked, parameter pArg must point to a value of
13479
+ ** type int. If the changegroup currently contains zero changes, and the
13480
+ ** value of the int variable is zero or greater than zero, then the
13481
+ ** changegroup is configured to generate a changeset or patchset,
13482
+ ** respectively. It is a no-op, not an error, if the changegroup is not
13483
+ ** configured because it has already started accumulating changes.
13484
+ **
13485
+ ** Before returning, the int variable is set to 0 if the changegroup is
13486
+ ** configured to generate a changeset, or 1 if it is configured to generate
13487
+ ** a patchset.
13488
+ */
13489
+ #define SQLITE_CHANGEGROUP_CONFIG_PATCHSET 1
13490
+
13491
+
13492
+ /*
13493
+ ** CAPI3REF: Begin adding a change to a changegroup
13494
+ **
13495
+ ** This API is used, in concert with other sqlite3changegroup_change_xxx()
13496
+ ** APIs, to add changes to a changegroup object one at a time. To add a
13497
+ ** single change, the caller must:
13498
+ **
13499
+ ** 1. Invoke sqlite3changegroup_change_begin() to indicate the type of
13500
+ ** change (INSERT, UPDATE or DELETE), the affected table and whether
13501
+ ** or not the change should be marked as indirect.
13502
+ **
13503
+ ** 2. Invoke sqlite3changegroup_change_int64() or one of the other four
13504
+ ** value functions - _null(), _double(), _text() or _blob() - one or
13505
+ ** more times to specify old.* and new.* values for the change being
13506
+ ** constructed.
13507
+ **
13508
+ ** 3. Invoke sqlite3changegroup_change_finish() to either finish adding
13509
+ ** the change to the group, or to discard the change altogether.
13510
+ **
13511
+ ** The first argument to this function must be a pointer to the existing
13512
+ ** changegroup object that the change will be added to. The second argument
13513
+ ** must be SQLITE_INSERT, SQLITE_UPDATE or SQLITE_DELETE. The third is the
13514
+ ** name of the table that the change affects, and the fourth is a boolean
13515
+ ** flag specifying whether the change should be marked as "indirect" (if
13516
+ ** bIndirect is non-zero) or not indirect (if bIndirect is zero).
13517
+ **
13518
+ ** Following a successful call to this function, this function may not be
13519
+ ** called again on the same changegroup object until after
13520
+ ** sqlite3changegroup_change_finish() has been called. Doing so is an
13521
+ ** SQLITE_MISUSE error.
13522
+ **
13523
+ ** The changegroup object passed as the first argument must be already
13524
+ ** configured with schema data for the specified table. It may be configured
13525
+ ** either by calling sqlite3changegroup_schema() with a database that contains
13526
+ ** the table, or sqlite3changegroup_add() with a changeset that contains the
13527
+ ** table. If the changegroup object has not been configured with a schema for
13528
+ ** the specified table when this function is called, SQLITE_ERROR is returned.
13529
+ **
13530
+ ** If successful, SQLITE_OK is returned. Otherwise, if an error occurs, an
13531
+ ** SQLite error code is returned. In this case, if argument pzErr is non-NULL,
13532
+ ** then (*pzErr) may be set to point to a buffer containing a utf-8 formated,
13533
+ ** nul-terminated, English language error message. It is the responsibility
13534
+ ** of the caller to eventually free this buffer using sqlite3_free().
13535
+ */
13536
+ SQLITE_API int sqlite3changegroup_change_begin(
13537
+ sqlite3_changegroup*,
13538
+ int eOp,
13539
+ const char *zTab,
13540
+ int bIndirect,
13541
+ char **pzErr
13542
+ );
13543
+
13544
+ /*
13545
+ ** CAPI3REF: Add a 64-bit integer to a changegroup
13546
+ **
13547
+ ** This function may only be called between a successful call to
13548
+ ** sqlite3changegroup_change_begin() and its matching
13549
+ ** sqlite3changegroup_change_finish() call. If it is called at any
13550
+ ** other time, it is an SQLITE_MISUSE error. Calling this function
13551
+ ** specifies a 64-bit integer value to be used in the change currently being
13552
+ ** added to the changegroup object passed as the first argument.
13553
+ **
13554
+ ** The second parameter, bNew, specifies whether the value is to be part of
13555
+ ** the new.* (if bNew is non-zero) or old.* (if bNew is zero) record of
13556
+ ** the change under construction. If this does not match the type of change
13557
+ ** specified by the preceding call to sqlite3changegroup_change_begin() (i.e.
13558
+ ** an old.* value for an SQLITE_INSERT change, or a new.* value for an
13559
+ ** SQLITE_DELETE), then SQLITE_ERROR is returned.
13560
+ **
13561
+ ** The third parameter specifies the column of the old.* or new.* record that
13562
+ ** the value will be a part of. If the specified table has an explicit primary
13563
+ ** key, then this is the index of the table column, numbered from 0 in the order
13564
+ ** specified within the CREATE TABLE statement. Or, if the table uses an
13565
+ ** implicit rowid key, then the column 0 is the rowid and the explicit columns
13566
+ ** are numbered starting from 1. If the iCol parameter is less than 0 or greater
13567
+ ** than the index of the last column in the table, SQLITE_RANGE is returned.
13568
+ **
13569
+ ** The fourth parameter is the integer value to use as part of the old.* or
13570
+ ** new.* record.
13571
+ **
13572
+ ** If this call is successful, SQLITE_OK is returned. Otherwise, if an
13573
+ ** error occurs, an SQLite error code is returned.
13574
+ */
13575
+ SQLITE_API int sqlite3changegroup_change_int64(
13576
+ sqlite3_changegroup*,
13577
+ int bNew,
13578
+ int iCol,
13579
+ sqlite3_int64 iVal
13580
+ );
13581
+
13582
+ /*
13583
+ ** CAPI3REF: Add a NULL to a changegroup
13584
+ **
13585
+ ** This function is similar to sqlite3changegroup_change_int64(). Except that
13586
+ ** it configures the change currently under construction with a NULL value
13587
+ ** instead of a 64-bit integer.
13588
+ */
13589
+ SQLITE_API int sqlite3changegroup_change_null(sqlite3_changegroup*, int, int);
13590
+
13591
+ /*
13592
+ ** CAPI3REF: Add an double to a changegroup
13593
+ **
13594
+ ** This function is similar to sqlite3changegroup_change_int64(). Except that
13595
+ ** it configures the change currently being constructed with a real value
13596
+ ** instead of a 64-bit integer.
13597
+ */
13598
+ SQLITE_API int sqlite3changegroup_change_double(sqlite3_changegroup*, int, int, double);
13599
+
13600
+ /*
13601
+ ** CAPI3REF: Add a text value to a changegroup
13602
+ **
13603
+ ** This function is similar to sqlite3changegroup_change_int64(). It configures
13604
+ ** the currently accumulated change with a text value instead of a 64-bit
13605
+ ** integer. Parameter pVal points to a buffer containing the text encoded using
13606
+ ** utf-8. Parameter nVal may either be the size of the text value in bytes, or
13607
+ ** else a negative value, in which case the buffer pVal points to is assumed to
13608
+ ** be nul-terminated.
13609
+ */
13610
+ SQLITE_API int sqlite3changegroup_change_text(
13611
+ sqlite3_changegroup*, int, int, const char *pVal, int nVal
13612
+ );
13613
+
13614
+ /*
13615
+ ** CAPI3REF: Add a blob to a changegroup
13616
+ **
13617
+ ** This function is similar to sqlite3changegroup_change_int64(). It configures
13618
+ ** the currently accumulated change with a blob value instead of a 64-bit
13619
+ ** integer. Parameter pVal points to a buffer containing the blob. Parameter
13620
+ ** nVal is the size of the blob in bytes.
13621
+ */
13622
+ SQLITE_API int sqlite3changegroup_change_blob(
13623
+ sqlite3_changegroup*, int, int, const void *pVal, int nVal
13624
+ );
13625
+
13626
+ /*
13627
+ ** CAPI3REF: Finish adding one-at-at-time changes to a changegroup
13628
+ **
13629
+ ** This function may only be called following a successful call to
13630
+ ** sqlite3changegroup_change_begin(). Otherwise, it is an SQLITE_MISUSE error.
13631
+ **
13632
+ ** If parameter bDiscard is non-zero, then the current change is simply
13633
+ ** discarded. In this case this function is always successful and SQLITE_OK
13634
+ ** returned.
13635
+ **
13636
+ ** If parameter bDiscard is zero, then an attempt is made to add the current
13637
+ ** change to the changegroup. Assuming the changegroup is configured to
13638
+ ** produce a changeset (not a patchset), this requires that:
13639
+ **
13640
+ ** * If the change is an INSERT or DELETE, then a value must be specified
13641
+ ** for all columns of the new.* or old.* record, respectively.
13642
+ **
13643
+ ** * If the change is an UPDATE record, then values must be provided for
13644
+ ** the PRIMARY KEY columns of the old.* record, but must not be provided
13645
+ ** for PRIMARY KEY columns of the new.* record.
13646
+ **
13647
+ ** * If the change is an UPDATE record, then for each non-PRIMARY KEY
13648
+ ** column in the old.* record for which a value has been provided, a
13649
+ ** value must also be provided for the same column in the new.* record.
13650
+ ** Similarly, for each non-PK column in the old.* record for which
13651
+ ** a value is not provided, a value must not be provided for the same
13652
+ ** column in the new.* record.
13653
+ **
13654
+ ** * All values specified for PRIMARY KEY columns must be non-NULL.
13655
+ **
13656
+ ** Otherwise, it is an error.
13657
+ **
13658
+ ** If the changegroup already contains a change for the same row (identified
13659
+ ** by PRIMARY KEY columns), then the current change is combined with the
13660
+ ** existing change in the same way as for sqlite3changegroup_add().
13661
+ **
13662
+ ** For a patchset, all of the above rules apply except that it doesn't matter
13663
+ ** whether or not values are provided for the non-PK old.* record columns
13664
+ ** for an UPDATE or DELETE change. This means that code used to produce
13665
+ ** a changeset using the sqlite3changegroup_change_xxx() APIs may also
13666
+ ** be used to produce patchsets.
13667
+ **
13668
+ ** If the call is successful, SQLITE_OK is returned. Otherwise, if an error
13669
+ ** occurs, an SQLite error code is returned. If an error is returned and
13670
+ ** parameter pzErr is not NULL, then (*pzErr) may be set to point to a buffer
13671
+ ** containing a nul-terminated, utf-8 encoded, English language error message.
13672
+ ** It is the responsibility of the caller to eventually free any such error
13673
+ ** message buffer using sqlite3_free().
13674
+ */
13675
+ SQLITE_API int sqlite3changegroup_change_finish(
13676
+ sqlite3_changegroup*,
13677
+ int bDiscard,
13678
+ char **pzErr
13679
+ );
13680
+
13202
13681
  /*
13203
13682
  ** Make sure we can call this stuff from C++.
13204
13683
  */