Fossil SCM

Update the built-in SQLite to the latest 3.53.0 beta for SQLite testing.

drh 2026-04-01 12:18 trunk
Commit ad59a046cb820c51b0fa85bd86a515c69eba32118a5587ba8d578e8ba8df997c
2 files changed +918 -190 +284 -48
+918 -190
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** c5af6a10245b6b847d30002806c1577b020c with changes in files:
21
+** 7bc1d0c4572f126cfe68fa51fe992d2bd46b with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470470
#define SQLITE_VERSION "3.53.0"
471471
#define SQLITE_VERSION_NUMBER 3053000
472
-#define SQLITE_SOURCE_ID "2026-03-26 19:11:57 c5af6a10245b6b847d30002806c1577b020c36ab27f7b1cf202ade136aa4779c"
472
+#define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2026-03-26T19:11:57.079Z"
475
+#define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -897,11 +897,11 @@
897897
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
898898
#define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
899899
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
900900
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
901901
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
902
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
902
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal only */
903903
904904
/*
905905
** CAPI3REF: Flags For File Open Operations
906906
**
907907
** These bit values are intended for use in the
@@ -1609,10 +1609,16 @@
16091609
/* deprecated names */
16101610
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
16111611
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
16121612
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
16131613
1614
+/* reserved file-control numbers:
1615
+** 101
1616
+** 102
1617
+** 103
1618
+*/
1619
+
16141620
16151621
/*
16161622
** CAPI3REF: Mutex Handle
16171623
**
16181624
** The mutex module within SQLite defines [sqlite3_mutex] to be an
@@ -2030,11 +2036,12 @@
20302036
** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
20312037
** The exceptional configuration options that may be invoked at any time
20322038
** are called "anytime configuration options".
20332039
** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
20342040
** [sqlite3_shutdown()] with a first argument that is not an anytime
2035
-** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
2041
+** configuration option, then the sqlite3_config() call will
2042
+** return SQLITE_MISUSE.
20362043
** Note, however, that ^sqlite3_config() can be called as part of the
20372044
** implementation of an application-defined [sqlite3_os_init()].
20382045
**
20392046
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
20402047
** ^If the option is unknown or SQLite is unable to set the option
@@ -2596,13 +2603,14 @@
25962603
** <li><P>The second argument ("sz") is the
25972604
** size of each lookaside buffer slot. Lookaside is disabled if "sz"
25982605
** is less than 8. The "sz" argument should be a multiple of 8 less than
25992606
** 65536. If "sz" does not meet this constraint, it is reduced in size until
26002607
** it does.
2601
-** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2602
-** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2603
-** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2608
+** <li><p>The third argument ("cnt") is the number of slots.
2609
+** Lookaside is disabled if "cnt"is less than 1.
2610
+* The "cnt" value will be reduced, if necessary, so
2611
+** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
26042612
** parameter is usually chosen so that the product of "sz" and "cnt" is less
26052613
** than 1,000,000.
26062614
** </ol>
26072615
** <p>If the "buf" argument is not NULL, then it must
26082616
** point to a memory buffer with a size that is greater than
@@ -2977,11 +2985,11 @@
29772985
** default value 17, as of SQLite version 3.52.0. The value was 15 in all
29782986
** prior versions.<p>
29792987
** This option takes two arguments which are an integer and a pointer
29802988
** to an integer. The first argument is a small integer, between 3 and 23, or
29812989
** zero. The FP_DIGITS setting is changed to that small integer, or left
2982
-** unaltered if the first argument is zero or out of range. The second argument
2990
+** unaltered if the first argument is zero or out of range. The second argument
29832991
** is a pointer to an integer. If the pointer is not NULL, then the value of
29842992
** the FP_DIGITS setting, after possibly being modified by the first
29852993
** arguments, is written into the integer to which the second argument points.
29862994
** </dd>
29872995
**
@@ -2989,14 +2997,16 @@
29892997
**
29902998
** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
29912999
**
29923000
** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
29933001
** overall call to [sqlite3_db_config()] has a total of four parameters.
2994
-** The first argument (the third parameter to sqlite3_db_config()) is an integer.
2995
-** The second argument is a pointer to an integer. If the first argument is 1,
2996
-** then the option becomes enabled. If the first integer argument is 0, then the
2997
-** option is disabled. If the first argument is -1, then the option setting
3002
+** The first argument (the third parameter to sqlite3_db_config()) is
3003
+** an integer.
3004
+** The second argument is a pointer to an integer. If the first argument is 1,
3005
+** then the option becomes enabled. If the first integer argument is 0,
3006
+** then the option is disabled.
3007
+** If the first argument is -1, then the option setting
29983008
** is unchanged. The second argument, the pointer to an integer, may be NULL.
29993009
** If the second argument is not NULL, then a value of 0 or 1 is written into
30003010
** the integer to which the second argument points, depending on whether the
30013011
** setting is disabled or enabled after applying any changes specified by
30023012
** the first argument.
@@ -6169,12 +6179,13 @@
61696179
** that the application-defined collating sequence created expects its
61706180
** input strings to be in UTF16 in native byte order, and that the start
61716181
** of the strings must be aligned to a 2-byte boundary.
61726182
**
61736183
** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
6174
-** used to specify the text encoding to strings input to [sqlite3_result_text64()]
6175
-** and [sqlite3_bind_text64()]. It means that the input string (call it "z")
6184
+** used to specify the text encoding to strings input to
6185
+** [sqlite3_result_text64()] and [sqlite3_bind_text64()].
6186
+** The SQLITE_UTF8_ZT encoding means that the input string (call it "z")
61766187
** is UTF-8 encoded and that it is zero-terminated. If the length parameter
61776188
** (call it "n") is non-negative, this encoding option means that the caller
61786189
** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
61796190
** byte has a value of zero.
61806191
** This option gives the same output as SQLITE_UTF8, but can be more efficient
@@ -6422,30 +6433,26 @@
64226433
**
64236434
** These routines must be called from the same thread as
64246435
** the SQL function that supplied the [sqlite3_value*] parameters.
64256436
**
64266437
** As long as the input parameter is correct, these routines can only
6427
-** fail if an out-of-memory error occurs during a format conversion.
6428
-** Only the following subset of interfaces are subject to out-of-memory
6429
-** errors:
6430
-**
6431
-** <ul>
6432
-** <li> sqlite3_value_blob()
6433
-** <li> sqlite3_value_text()
6434
-** <li> sqlite3_value_text16()
6435
-** <li> sqlite3_value_text16le()
6436
-** <li> sqlite3_value_text16be()
6437
-** <li> sqlite3_value_bytes()
6438
-** <li> sqlite3_value_bytes16()
6439
-** </ul>
6440
-**
6438
+** fail if an out-of-memory error occurs while trying to do a
6439
+** UTF8&rarr;UTF16 or UTF16&rarr;UTF8 conversion.
64416440
** If an out-of-memory error occurs, then the return value from these
64426441
** routines is the same as if the column had contained an SQL NULL value.
6443
-** Valid SQL NULL returns can be distinguished from out-of-memory errors
6444
-** by invoking the [sqlite3_errcode()] immediately after the suspect
6442
+** If the input sqlite3_value was not obtained from [sqlite3_value_dup()],
6443
+** then valid SQL NULL returns can also be distinguished from
6444
+** out-of-memory errors after extracting the value
6445
+** by invoking the [sqlite3_errcode()] immediately after the suspicious
64456446
** return value is obtained and before any
64466447
** other SQLite interface is called on the same [database connection].
6448
+** If the input sqlite3_value was obtained from sqlite3_value_dup() then
6449
+** it is disconnected from the database connection and so sqlite3_errcode()
6450
+** will not work.
6451
+** In that case, the only way to distinguish an out-of-memory
6452
+** condition from a true SQL NULL is to invoke sqlite3_value_type() on the
6453
+** input to see if it is NULL prior to trying to extract the value.
64476454
*/
64486455
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
64496456
SQLITE_API double sqlite3_value_double(sqlite3_value*);
64506457
SQLITE_API int sqlite3_value_int(sqlite3_value*);
64516458
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -6468,11 +6475,12 @@
64686475
** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
64696476
** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding
64706477
** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
64716478
** returns something other than SQLITE_TEXT, then the return value from
64726479
** sqlite3_value_encoding(X) is meaningless. ^Calls to
6473
-** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)],
6480
+** [sqlite3_value_text(X)], [sqlite3_value_text16(X)],
6481
+** [sqlite3_value_text16be(X)],
64746482
** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
64756483
** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
64766484
** thus change the return from subsequent calls to sqlite3_value_encoding(X).
64776485
**
64786486
** This routine is intended for used by applications that test and validate
@@ -6599,21 +6607,21 @@
65996607
** associate auxiliary data with argument values. If the same argument
66006608
** value is passed to multiple invocations of the same SQL function during
66016609
** query execution, under some circumstances the associated auxiliary data
66026610
** might be preserved. An example of where this might be useful is in a
66036611
** regular-expression matching function. The compiled version of the regular
6604
-** expression can be stored as auxiliary data associated with the pattern string.
6605
-** Then as long as the pattern string remains the same,
6612
+** expression can be stored as auxiliary data associated with the pattern
6613
+** string. Then as long as the pattern string remains the same,
66066614
** the compiled regular expression can be reused on multiple
66076615
** invocations of the same function.
66086616
**
6609
-** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
6610
-** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
6611
-** value to the application-defined function. ^N is zero for the left-most
6612
-** function argument. ^If there is no auxiliary data
6613
-** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
6614
-** returns a NULL pointer.
6617
+** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary
6618
+** data associated by the sqlite3_set_auxdata(C,N,P,X) function with the
6619
+** Nth argument value to the application-defined function. ^N is zero
6620
+** for the left-most function argument. ^If there is no auxiliary data
6621
+** associated with the function argument, the sqlite3_get_auxdata(C,N)
6622
+** interface returns a NULL pointer.
66156623
**
66166624
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
66176625
** N-th argument of the application-defined function. ^Subsequent
66186626
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
66196627
** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
@@ -10722,21 +10730,22 @@
1072210730
**
1072310731
** <table border=1 cellspacing=0 cellpadding=10 width="90%">
1072410732
** <tr>
1072510733
** <td valign="top">sqlite3_vtab_distinct() return value
1072610734
** <td valign="top">Rows are returned in aOrderBy order
10727
-** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
10735
+** <td valign="top">Rows with the same value in all aOrderBy columns are
10736
+** adjacent
1072810737
** <td valign="top">Duplicates over all colUsed columns may be omitted
1072910738
** <tr><td>0<td>yes<td>yes<td>no
1073010739
** <tr><td>1<td>no<td>yes<td>no
1073110740
** <tr><td>2<td>no<td>yes<td>yes
1073210741
** <tr><td>3<td>yes<td>yes<td>yes
1073310742
** </table>
1073410743
**
1073510744
** ^For the purposes of comparing virtual table output values to see if the
10736
-** values are the same value for sorting purposes, two NULL values are considered
10737
-** to be the same. In other words, the comparison operator is "IS"
10745
+** values are the same value for sorting purposes, two NULL values are
10746
+** considered to be the same. In other words, the comparison operator is "IS"
1073810747
** (or "IS NOT DISTINCT FROM") and not "==".
1073910748
**
1074010749
** If a virtual table implementation is unable to meet the requirements
1074110750
** specified above, then it must not set the "orderByConsumed" flag in the
1074210751
** [sqlite3_index_info] object or an incorrect answer may result.
@@ -11586,16 +11595,17 @@
1158611595
/*
1158711596
** CAPI3REF: Bind array values to the CARRAY table-valued function
1158811597
**
1158911598
** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
1159011599
** parameter that is the first argument of the [carray() table-valued function].
11591
-** The S parameter is a pointer to the [prepared statement] that uses the carray()
11592
-** functions. I is the parameter index to be bound. I must be the index of the
11593
-** parameter that is the first argument to the carray() table-valued function.
11594
-** P is a pointer to the array to be bound, and N is the number of elements in
11595
-** the array. The F argument is one of constants [SQLITE_CARRAY_INT32],
11596
-** [SQLITE_CARRAY_INT64], [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
11600
+** The S parameter is a pointer to the [prepared statement] that uses the
11601
+** carray() functions. I is the parameter index to be bound. I must be the
11602
+** index of the parameter that is the first argument to the carray()
11603
+** table-valued function. P is a pointer to the array to be bound, and N
11604
+** is the number of elements in the array. The F argument is one of
11605
+** constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64],
11606
+** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
1159711607
** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
1159811608
**
1159911609
** If the X argument is not a NULL pointer or one of the special
1160011610
** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
1160111611
** the function X with argument D when it is finished using the data in P.
@@ -13648,10 +13658,236 @@
1364813658
1364913659
/*
1365013660
** CAPI3REF: Values for sqlite3session_config().
1365113661
*/
1365213662
#define SQLITE_SESSION_CONFIG_STRMSIZE 1
13663
+
13664
+/*
13665
+** CAPI3REF: Configure a changegroup object
13666
+**
13667
+** Configure the changegroup object passed as the first argument.
13668
+** At present the only valid value for the second parameter is
13669
+** [SQLITE_CHANGEGROUP_CONFIG_PATCHSET].
13670
+*/
13671
+SQLITE_API int sqlite3changegroup_config(sqlite3_changegroup*, int, void *pArg);
13672
+
13673
+/*
13674
+** CAPI3REF: Options for sqlite3changegroup_config().
13675
+**
13676
+** The following values may be passed as the 2nd parameter to
13677
+** sqlite3changegroup_config().
13678
+**
13679
+** <dt>SQLITE_CHANGEGROUP_CONFIG_PATCHSET <dd>
13680
+** A changegroup object generates either a changeset or patchset. Usually,
13681
+** this is determined by whether the first call to sqlite3changegroup_add()
13682
+** is passed a changeset or a patchset. Or, if the first changes are added
13683
+** to the changegroup object using the sqlite3changegroup_change_xxx()
13684
+** APIs, then this option may be used to configure whether the changegroup
13685
+** object generates a changeset or patchset.
13686
+**
13687
+** When this option is invoked, parameter pArg must point to a value of
13688
+** type int. If the changegroup currently contains zero changes, and the
13689
+** value of the int variable is zero or greater than zero, then the
13690
+** changegroup is configured to generate a changeset or patchset,
13691
+** respectively. It is a no-op, not an error, if the changegroup is not
13692
+** configured because it has already started accumulating changes.
13693
+**
13694
+** Before returning, the int variable is set to 0 if the changegroup is
13695
+** configured to generate a changeset, or 1 if it is configured to generate
13696
+** a patchset.
13697
+*/
13698
+#define SQLITE_CHANGEGROUP_CONFIG_PATCHSET 1
13699
+
13700
+
13701
+/*
13702
+** CAPI3REF: Begin adding a change to a changegroup
13703
+**
13704
+** This API is used, in concert with other sqlite3changegroup_change_xxx()
13705
+** APIs, to add changes to a changegroup object one at a time. To add a
13706
+** single change, the caller must:
13707
+**
13708
+** 1. Invoke sqlite3changegroup_change_begin() to indicate the type of
13709
+** change (INSERT, UPDATE or DELETE), the affected table and whether
13710
+** or not the change should be marked as indirect.
13711
+**
13712
+** 2. Invoke sqlite3changegroup_change_int64() or one of the other four
13713
+** value functions - _null(), _double(), _text() or _blob() - one or
13714
+** more times to specify old.* and new.* values for the change being
13715
+** constructed.
13716
+**
13717
+** 3. Invoke sqlite3changegroup_change_finish() to either finish adding
13718
+** the change to the group, or to discard the change altogether.
13719
+**
13720
+** The first argument to this function must be a pointer to the existing
13721
+** changegroup object that the change will be added to. The second argument
13722
+** must be SQLITE_INSERT, SQLITE_UPDATE or SQLITE_DELETE. The third is the
13723
+** name of the table that the change affects, and the fourth is a boolean
13724
+** flag specifying whether the change should be marked as "indirect" (if
13725
+** bIndirect is non-zero) or not indirect (if bIndirect is zero).
13726
+**
13727
+** Following a successful call to this function, this function may not be
13728
+** called again on the same changegroup object until after
13729
+** sqlite3changegroup_change_finish() has been called. Doing so is an
13730
+** SQLITE_MISUSE error.
13731
+**
13732
+** The changegroup object passed as the first argument must be already
13733
+** configured with schema data for the specified table. It may be configured
13734
+** either by calling sqlite3changegroup_schema() with a database that contains
13735
+** the table, or sqlite3changegroup_add() with a changeset that contains the
13736
+** table. If the changegroup object has not been configured with a schema for
13737
+** the specified table when this function is called, SQLITE_ERROR is returned.
13738
+**
13739
+** If successful, SQLITE_OK is returned. Otherwise, if an error occurs, an
13740
+** SQLite error code is returned. In this case, if argument pzErr is non-NULL,
13741
+** then (*pzErr) may be set to point to a buffer containing a utf-8 formated,
13742
+** nul-terminated, English language error message. It is the responsibility
13743
+** of the caller to eventually free this buffer using sqlite3_free().
13744
+*/
13745
+SQLITE_API int sqlite3changegroup_change_begin(
13746
+ sqlite3_changegroup*,
13747
+ int eOp,
13748
+ const char *zTab,
13749
+ int bIndirect,
13750
+ char **pzErr
13751
+);
13752
+
13753
+/*
13754
+** CAPI3REF: Add a 64-bit integer to a changegroup
13755
+**
13756
+** This function may only be called between a successful call to
13757
+** sqlite3changegroup_change_begin() and its matching
13758
+** sqlite3changegroup_change_finish() call. If it is called at any
13759
+** other time, it is an SQLITE_MISUSE error. Calling this function
13760
+** specifies a 64-bit integer value to be used in the change currently being
13761
+** added to the changegroup object passed as the first argument.
13762
+**
13763
+** The second parameter, bNew, specifies whether the value is to be part of
13764
+** the new.* (if bNew is non-zero) or old.* (if bNew is zero) record of
13765
+** the change under construction. If this does not match the type of change
13766
+** specified by the preceding call to sqlite3changegroup_change_begin() (i.e.
13767
+** an old.* value for an SQLITE_INSERT change, or a new.* value for an
13768
+** SQLITE_DELETE), then SQLITE_ERROR is returned.
13769
+**
13770
+** The third parameter specifies the column of the old.* or new.* record that
13771
+** the value will be a part of. If the specified table has an explicit primary
13772
+** key, then this is the index of the table column, numbered from 0 in the order
13773
+** specified within the CREATE TABLE statement. Or, if the table uses an
13774
+** implicit rowid key, then the column 0 is the rowid and the explicit columns
13775
+** are numbered starting from 1. If the iCol parameter is less than 0 or greater
13776
+** than the index of the last column in the table, SQLITE_RANGE is returned.
13777
+**
13778
+** The fourth parameter is the integer value to use as part of the old.* or
13779
+** new.* record.
13780
+**
13781
+** If this call is successful, SQLITE_OK is returned. Otherwise, if an
13782
+** error occurs, an SQLite error code is returned.
13783
+*/
13784
+SQLITE_API int sqlite3changegroup_change_int64(
13785
+ sqlite3_changegroup*,
13786
+ int bNew,
13787
+ int iCol,
13788
+ sqlite3_int64 iVal
13789
+);
13790
+
13791
+/*
13792
+** CAPI3REF: Add a NULL to a changegroup
13793
+**
13794
+** This function is similar to sqlite3changegroup_change_int64(). Except that
13795
+** it configures the change currently under construction with a NULL value
13796
+** instead of a 64-bit integer.
13797
+*/
13798
+SQLITE_API int sqlite3changegroup_change_null(sqlite3_changegroup*, int, int);
13799
+
13800
+/*
13801
+** CAPI3REF: Add an double to a changegroup
13802
+**
13803
+** This function is similar to sqlite3changegroup_change_int64(). Except that
13804
+** it configures the change currently being constructed with a real value
13805
+** instead of a 64-bit integer.
13806
+*/
13807
+SQLITE_API int sqlite3changegroup_change_double(sqlite3_changegroup*, int, int, double);
13808
+
13809
+/*
13810
+** CAPI3REF: Add a text value to a changegroup
13811
+**
13812
+** This function is similar to sqlite3changegroup_change_int64(). It configures
13813
+** the currently accumulated change with a text value instead of a 64-bit
13814
+** integer. Parameter pVal points to a buffer containing the text encoded using
13815
+** utf-8. Parameter nVal may either be the size of the text value in bytes, or
13816
+** else a negative value, in which case the buffer pVal points to is assumed to
13817
+** be nul-terminated.
13818
+*/
13819
+SQLITE_API int sqlite3changegroup_change_text(
13820
+ sqlite3_changegroup*, int, int, const char *pVal, int nVal
13821
+);
13822
+
13823
+/*
13824
+** CAPI3REF: Add a blob to a changegroup
13825
+**
13826
+** This function is similar to sqlite3changegroup_change_int64(). It configures
13827
+** the currently accumulated change with a blob value instead of a 64-bit
13828
+** integer. Parameter pVal points to a buffer containing the blob. Parameter
13829
+** nVal is the size of the blob in bytes.
13830
+*/
13831
+SQLITE_API int sqlite3changegroup_change_blob(
13832
+ sqlite3_changegroup*, int, int, const void *pVal, int nVal
13833
+);
13834
+
13835
+/*
13836
+** CAPI3REF: Finish adding one-at-at-time changes to a changegroup
13837
+**
13838
+** This function may only be called following a successful call to
13839
+** sqlite3changegroup_change_begin(). Otherwise, it is an SQLITE_MISUSE error.
13840
+**
13841
+** If parameter bDiscard is non-zero, then the current change is simply
13842
+** discarded. In this case this function is always successful and SQLITE_OK
13843
+** returned.
13844
+**
13845
+** If parameter bDiscard is zero, then an attempt is made to add the current
13846
+** change to the changegroup. Assuming the changegroup is configured to
13847
+** produce a changeset (not a patchset), this requires that:
13848
+**
13849
+** * If the change is an INSERT or DELETE, then a value must be specified
13850
+** for all columns of the new.* or old.* record, respectively.
13851
+**
13852
+** * If the change is an UPDATE record, then values must be provided for
13853
+** the PRIMARY KEY columns of the old.* record, but must not be provided
13854
+** for PRIMARY KEY columns of the new.* record.
13855
+**
13856
+** * If the change is an UPDATE record, then for each non-PRIMARY KEY
13857
+** column in the old.* record for which a value has been provided, a
13858
+** value must also be provided for the same column in the new.* record.
13859
+** Similarly, for each non-PK column in the old.* record for which
13860
+** a value is not provided, a value must not be provided for the same
13861
+** column in the new.* record.
13862
+**
13863
+** * All values specified for PRIMARY KEY columns must be non-NULL.
13864
+**
13865
+** Otherwise, it is an error.
13866
+**
13867
+** If the changegroup already contains a change for the same row (identified
13868
+** by PRIMARY KEY columns), then the current change is combined with the
13869
+** existing change in the same way as for sqlite3changegroup_add().
13870
+**
13871
+** For a patchset, all of the above rules apply except that it doesn't matter
13872
+** whether or not values are provided for the non-PK old.* record columns
13873
+** for an UPDATE or DELETE change. This means that code used to produce
13874
+** a changeset using the sqlite3changegroup_change_xxx() APIs may also
13875
+** be used to produce patchsets.
13876
+**
13877
+** If the call is successful, SQLITE_OK is returned. Otherwise, if an error
13878
+** occurs, an SQLite error code is returned. If an error is returned and
13879
+** parameter pzErr is not NULL, then (*pzErr) may be set to point to a buffer
13880
+** containing a nul-terminated, utf-8 encoded, English language error message.
13881
+** It is the responsibility of the caller to eventually free any such error
13882
+** message buffer using sqlite3_free().
13883
+*/
13884
+SQLITE_API int sqlite3changegroup_change_finish(
13885
+ sqlite3_changegroup*,
13886
+ int bDiscard,
13887
+ char **pzErr
13888
+);
1365313889
1365413890
/*
1365513891
** Make sure we can call this stuff from C++.
1365613892
*/
1365713893
#if 0
@@ -21585,21 +21821,26 @@
2158521821
int nArg; /* Total number of arguments */
2158621822
int nUsed; /* Number of arguments used so far */
2158721823
sqlite3_value **apArg; /* The argument values */
2158821824
};
2158921825
21826
+/*
21827
+** Maxium number of base-10 digits in an unsigned 64-bit integer
21828
+*/
21829
+#define SQLITE_U64_DIGITS 20
21830
+
2159021831
/*
2159121832
** An instance of this object receives the decoding of a floating point
2159221833
** value into an approximate decimal representation.
2159321834
*/
2159421835
struct FpDecode {
21595
- int n; /* Significant digits in the decode */
21596
- int iDP; /* Location of the decimal point */
21597
- char *z; /* Start of significant digits */
21598
- char zBuf[20]; /* Storage for significant digits */
21599
- char sign; /* '+' or '-' */
21600
- char isSpecial; /* 1: Infinity 2: NaN */
21836
+ int n; /* Significant digits in the decode */
21837
+ int iDP; /* Location of the decimal point */
21838
+ char *z; /* Start of significant digits */
21839
+ char zBuf[SQLITE_U64_DIGITS+1]; /* Storage for significant digits */
21840
+ char sign; /* '+' or '-' */
21841
+ char isSpecial; /* 1: Infinity 2: NaN */
2160121842
};
2160221843
2160321844
SQLITE_PRIVATE void sqlite3FpDecode(FpDecode*,double,int,int);
2160421845
SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
2160521846
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
@@ -22283,10 +22524,11 @@
2228322524
SQLITE_PRIVATE char *sqlite3RCStrNew(u64);
2228422525
SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64);
2228522526
2228622527
SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
2228722528
SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, i64);
22529
+SQLITE_PRIVATE int sqlite3StrAccumEnlargeIfNeeded(StrAccum*, i64);
2228822530
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
2228922531
SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum*, u8);
2229022532
SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
2229122533
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
2229222534
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
@@ -32635,10 +32877,11 @@
3263532877
case etEXP:
3263632878
case etGENERIC: {
3263732879
FpDecode s;
3263832880
int iRound;
3263932881
int j;
32882
+ i64 szBufNeeded; /* Size needed to hold the output */
3264032883
3264132884
if( bArgList ){
3264232885
realvalue = getDoubleArg(pArgList);
3264332886
}else{
3264432887
realvalue = va_arg(ap,double);
@@ -32723,21 +32966,19 @@
3272332966
if( xtype==etEXP ){
3272432967
e2 = 0;
3272532968
}else{
3272632969
e2 = s.iDP - 1;
3272732970
}
32728
- bufpt = buf;
32729
- {
32730
- i64 szBufNeeded; /* Size of a temporary buffer needed */
32731
- szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
32732
- if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32733
- if( szBufNeeded > etBUFSIZE ){
32734
- bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
32735
- if( bufpt==0 ) return;
32736
- }
32737
- }
32738
- zOut = bufpt;
32971
+
32972
+ szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+8;
32973
+ if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32974
+ if( sqlite3StrAccumEnlargeIfNeeded(pAccum, szBufNeeded) ){
32975
+ width = length = 0;
32976
+ break;
32977
+ }
32978
+ bufpt = zOut = pAccum->zText + pAccum->nChar;
32979
+
3273932980
flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
3274032981
/* The sign in front of the number */
3274132982
if( prefix ){
3274232983
*(bufpt++) = prefix;
3274332984
}
@@ -32781,17 +33022,15 @@
3278133022
int nn = s.n - j;
3278233023
if( NEVER(nn>precision) ) nn = precision;
3278333024
if( nn>0 ){
3278433025
memcpy(bufpt, s.z+j, nn);
3278533026
bufpt += nn;
32786
- j += nn;
3278733027
precision -= nn;
3278833028
}
3278933029
if( precision>0 && !flag_rtz ){
3279033030
memset(bufpt, '0', precision);
3279133031
bufpt += precision;
32792
- precision = 0;
3279333032
}
3279433033
}
3279533034
/* Remove trailing zeros and the "." if no digits follow the "." */
3279633035
if( flag_rtz && flag_dp ){
3279733036
while( bufpt[-1]=='0' ) *(--bufpt) = 0;
@@ -32818,31 +33057,35 @@
3281833057
exp %= 100;
3281933058
}
3282033059
*(bufpt++) = (char)(exp/10+'0'); /* 10's digit */
3282133060
*(bufpt++) = (char)(exp%10+'0'); /* 1's digit */
3282233061
}
32823
- *bufpt = 0;
3282433062
32825
- /* The converted number is in buf[] and zero terminated. Output it.
32826
- ** Note that the number is in the usual order, not reversed as with
32827
- ** integer conversions. */
3282833063
length = (int)(bufpt-zOut);
32829
- bufpt = zOut;
32830
-
32831
- /* Special case: Add leading zeros if the flag_zeropad flag is
32832
- ** set and we are not left justified */
32833
- if( flag_zeropad && !flag_leftjustify && length < width){
32834
- int i;
32835
- int nPad = width - length;
32836
- for(i=width; i>=nPad; i--){
32837
- bufpt[i] = bufpt[i-nPad];
32838
- }
32839
- i = prefix!=0;
32840
- while( nPad-- ) bufpt[i++] = '0';
33064
+ assert( length <= szBufNeeded );
33065
+ if( length<width ){
33066
+ i64 nPad = width - length;
33067
+ if( flag_leftjustify ){
33068
+ memset(bufpt, ' ', nPad);
33069
+ }else if( !flag_zeropad ){
33070
+ memmove(zOut+nPad, zOut, length);
33071
+ memset(zOut, ' ', nPad);
33072
+ }else{
33073
+ int adj = prefix!=0;
33074
+ memmove(zOut+nPad+adj, zOut+adj, length-adj);
33075
+ memset(zOut+adj, '0', nPad);
33076
+ }
3284133077
length = width;
3284233078
}
32843
- break;
33079
+ pAccum->nChar += length;
33080
+ zOut[length] = 0;
33081
+
33082
+ /* Floating point conversions render directly into the output
33083
+ ** buffer. Hence, don't just break out of the switch(). Bypass the
33084
+ ** output buffer writing that occurs after the switch() by continuing
33085
+ ** to the next character in the format string. */
33086
+ continue;
3284433087
}
3284533088
case etSIZE:
3284633089
if( !bArgList ){
3284733090
*(va_arg(ap,int*)) = pAccum->nChar;
3284833091
}
@@ -32882,15 +33125,14 @@
3288233125
precision--;
3288333126
while( precision > 1 ){
3288433127
i64 nCopyBytes;
3288533128
if( nPrior > precision-1 ) nPrior = precision - 1;
3288633129
nCopyBytes = length*nPrior;
32887
- if( nCopyBytes + pAccum->nChar >= pAccum->nAlloc ){
32888
- sqlite3StrAccumEnlarge(pAccum, nCopyBytes);
33130
+ if( sqlite3StrAccumEnlargeIfNeeded(pAccum, nCopyBytes) ){
33131
+ break;
3288933132
}
32890
- if( pAccum->accError ) break;
32891
- sqlite3_str_append(pAccum,
33133
+ sqlite3_str_append(pAccum,
3289233134
&pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
3289333135
precision -= nPrior;
3289433136
nPrior *= 2;
3289533137
}
3289633138
}
@@ -33231,10 +33473,17 @@
3323133473
}
3323233474
}
3323333475
assert( N>=0 && N<=0x7fffffff );
3323433476
return (int)N;
3323533477
}
33478
+
33479
+SQLITE_PRIVATE int sqlite3StrAccumEnlargeIfNeeded(StrAccum *p, i64 N){
33480
+ if( N + p->nChar >= p->nAlloc ){
33481
+ sqlite3StrAccumEnlarge(p, N);
33482
+ }
33483
+ return p->accError;
33484
+}
3323633485
3323733486
/*
3323833487
** Append N copies of character c to the given string buffer.
3323933488
*/
3324033489
SQLITE_API void sqlite3_str_appendchar(sqlite3_str *p, int N, char c){
@@ -36548,15 +36797,16 @@
3654836797
** lower 64-bits of the result into *pLo, and return the high-order
3654936798
** 64 bits.
3655036799
*/
3655136800
static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
3655236801
#if (defined(__GNUC__) || defined(__clang__)) \
36553
- && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv))
36802
+ && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36803
+ && !defined(SQLITE_DISABLE_INTRINSIC)
3655436804
__uint128_t r = (__uint128_t)a * b;
3655536805
*pLo = (u64)r;
3655636806
return (u64)(r>>64);
36557
-#elif defined(_MSC_VER) && defined(_M_X64)
36807
+#elif defined(_WIN64) && !defined(SQLITE_DISABLE_INTRINSIC)
3655836808
*pLo = a*b;
3655936809
return __umulh(a, b);
3656036810
#else
3656136811
u64 a0 = (u32)a;
3656236812
u64 a1 = a >> 32;
@@ -36583,21 +36833,23 @@
3658336833
**
3658436834
** The lower 64 bits of A*B are discarded.
3658536835
*/
3658636836
static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
3658736837
#if (defined(__GNUC__) || defined(__clang__)) \
36588
- && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv))
36838
+ && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36839
+ && !defined(SQLITE_DISABLE_INTRINSIC)
3658936840
__uint128_t r = (__uint128_t)a * b;
3659036841
r += ((__uint128_t)aLo * b) >> 32;
3659136842
*pLo = (r>>32)&0xffffffff;
3659236843
return r>>64;
36593
-#elif defined(_MSC_VER) && defined(_M_X64)
36844
+#elif defined(_WIN64) && !defined(SQLITE_DISABLE_INTRINSIC)
3659436845
u64 r1_hi = __umulh(a,b);
3659536846
u64 r1_lo = a*b;
3659636847
u64 r2 = (__umulh((u64)aLo,b)<<32) + ((aLo*b)>>32);
36597
- r1_hi += _addcarry_u64(0, r1_lo, r2, &r1_lo);
36598
- *pLo = r1_lo>>32;
36848
+ u64 t = r1_lo + r2;
36849
+ if( t<r1_lo ) r1_hi++;
36850
+ *pLo = t>>32;
3659936851
return r1_hi;
3660036852
#else
3660136853
u64 x2 = a>>32;
3660236854
u64 x1 = a&0xffffffff;
3660336855
u64 x0 = aLo;
@@ -36805,11 +37057,12 @@
3680537057
3680637058
/*
3680737059
** Count leading zeros for a 64-bit unsigned integer.
3680837060
*/
3680937061
static int countLeadingZeros(u64 m){
36810
-#if defined(__GNUC__) || defined(__clang__)
37062
+#if (defined(__GNUC__) || defined(__clang__)) \
37063
+ && !defined(SQLITE_DISABLE_INTRINSIC)
3681137064
return __builtin_clzll(m);
3681237065
#else
3681337066
int n = 0;
3681437067
if( m <= 0x00000000ffffffffULL) { n += 32; m <<= 32; }
3681537068
if( m <= 0x0000ffffffffffffULL) { n += 16; m <<= 16; }
@@ -36906,16 +37159,19 @@
3690637159
** Return positive if the result is a valid real number (or integer) and
3690737160
** zero or negative if the string is empty or contains extraneous text.
3690837161
** Lower bits of the return value contain addition information about the
3690937162
** parse:
3691037163
**
36911
-** bit 0 => Set for any valid input
36912
-** bit 1 => Input contains a decimal point or eNNN clause
36913
-** This bit is zero if the input is an integer
37164
+** bit 0 => Set if any prefix of the input is valid. Clear if
37165
+** there is no prefix of the input that can be seen as
37166
+** a valid floating point number.
37167
+** bit 1 => Set if the input contains a decimal point or eNNN
37168
+** clause. Zero if the input is an integer.
3691437169
** bit 2 => The input is exactly 0.0, not an underflow from
36915
-** some value near zero
36916
-** bit 3 => More than 19 significant digits in the input
37170
+** some value near zero.
37171
+** bit 3 => Set if there are more than about 19 significant
37172
+** digits in the input.
3691737173
**
3691837174
** If the input contains a syntax error but begins with text that might
3691937175
** be a valid number of some kind, then the result is negative. The
3692037176
** result is only zero if no prefix of the input could be interpreted as
3692137177
** a number.
@@ -37077,10 +37333,73 @@
3707737333
"70717273747576777879"
3707837334
"80818283848586878889"
3707937335
"90919293949596979899"
3708037336
};
3708137337
37338
+/*
37339
+** ARMv6, ARMv7, PPC32 are known to not support hardware u64 division.
37340
+*/
37341
+#if (defined(__arm__) && !defined(__aarch64__)) || \
37342
+ (defined(__ppc__) && !defined(__ppc64__))
37343
+# define SQLITE_AVOID_U64_DIVIDE 1
37344
+#endif
37345
+
37346
+#ifdef SQLITE_AVOID_U64_DIVIDE
37347
+/*
37348
+** Render an unsigned 64-bit integer as text onto the end of a 2-byte
37349
+** aligned buffer that is SQLITE_U64_DIGIT+1 bytes long. The last byte
37350
+** of the buffer will be filled with a \000 byte.
37351
+**
37352
+** Return the index into the buffer of the first byte.
37353
+**
37354
+** This routine is used on platforms where u64-division is slow because
37355
+** it is not available in hardware and has to be emulated in software.
37356
+** It seeks to minimize the number of u64 divisions and use u32 divisions
37357
+** instead. It is slower on platforms that have hardware u64 division,
37358
+** but much faster on platforms that do not.
37359
+*/
37360
+static int sqlite3UInt64ToText(u64 v, char *zOut){
37361
+ u32 x32, kk;
37362
+ int i;
37363
+ zOut[SQLITE_U64_DIGITS] = 0;
37364
+ i = SQLITE_U64_DIGITS;
37365
+ assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[0]) );
37366
+ assert( TWO_BYTE_ALIGNMENT(zOut) );
37367
+ while( (v>>32)!=0 ){
37368
+ u32 y, x0, x1, y0, y1;
37369
+ x32 = v % 100000000;
37370
+ v = v / 100000000;
37371
+ y = x32 % 10000;
37372
+ x32 /= 10000;
37373
+ x1 = x32 / 100;
37374
+ x0 = x32 % 100;
37375
+ y1 = y / 100;
37376
+ y0 = y % 100;
37377
+ assert( i>=8 );
37378
+ i -= 8;
37379
+ *(u16*)(&zOut[i]) = *(u16*)&sqlite3DigitPairs.a[x1*2];
37380
+ *(u16*)(&zOut[i+2]) = *(u16*)&sqlite3DigitPairs.a[x0*2];
37381
+ *(u16*)(&zOut[i+4]) = *(u16*)&sqlite3DigitPairs.a[y1*2];
37382
+ *(u16*)(&zOut[i+6]) = *(u16*)&sqlite3DigitPairs.a[y0*2];
37383
+ }
37384
+ x32 = v;
37385
+ while( x32>=10 ){
37386
+ kk = x32 % 100;
37387
+ x32 = x32 / 100;
37388
+ assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk*2]) );
37389
+ assert( i>=2 );
37390
+ i -= 2;
37391
+ assert( TWO_BYTE_ALIGNMENT(&zOut[i]) );
37392
+ *(u16*)(&zOut[i]) = *(u16*)&sqlite3DigitPairs.a[kk*2];
37393
+ }
37394
+ if( x32 ){
37395
+ assert( i>0 );
37396
+ zOut[--i] = x32 + '0';
37397
+ }
37398
+ return i;
37399
+}
37400
+#endif /* defined(SQLITE_AVOID_U64_DIVIDE) */
3708237401
3708337402
/*
3708437403
** Render an signed 64-bit integer as text. Store the result in zOut[] and
3708537404
** return the length of the string that was stored, in bytes. The value
3708637405
** returned does not include the zero terminator at the end of the output
@@ -37090,11 +37409,11 @@
3709037409
*/
3709137410
SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){
3709237411
int i;
3709337412
u64 x;
3709437413
union {
37095
- char a[23];
37414
+ char a[SQLITE_U64_DIGITS+1];
3709637415
u16 forceAlignment;
3709737416
} u;
3709837417
if( v>0 ){
3709937418
x = v;
3710037419
}else if( v==0 ){
@@ -37102,10 +37421,13 @@
3710237421
zOut[1] = 0;
3710337422
return 1;
3710437423
}else{
3710537424
x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : (u64)-v;
3710637425
}
37426
+#ifdef SQLITE_AVOID_U64_DIVIDE
37427
+ i = sqlite3UInt64ToText(x, u.a);
37428
+#else
3710737429
i = sizeof(u.a)-1;
3710837430
u.a[i] = 0;
3710937431
while( x>=10 ){
3711037432
int kk = (x%100)*2;
3711137433
assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
@@ -37115,10 +37437,11 @@
3711537437
x /= 100;
3711637438
}
3711737439
if( x ){
3711837440
u.a[--i] = x + '0';
3711937441
}
37442
+#endif /* SQLITE_AVOID_U64_DIVIDE */
3712037443
if( v<0 ) u.a[--i] = '-';
3712137444
memcpy(zOut, &u.a[i], sizeof(u.a)-i);
3712237445
return sizeof(u.a)-1-i;
3712337446
}
3712437447
@@ -37434,41 +37757,47 @@
3743437757
sqlite3Fp2Convert10(v, e, (iRound<=0||iRound>=18)?18:iRound+1, &v, &exp);
3743537758
3743637759
/* Extract significant digits, start at the right-most slot in p->zBuf
3743737760
** and working back to the right. "i" keeps track of the next slot in
3743837761
** which to store a digit. */
37439
- i = sizeof(p->zBuf)-1;
37762
+ assert( sizeof(p->zBuf)==SQLITE_U64_DIGITS+1 );
37763
+ assert( v>0 );
3744037764
zBuf = p->zBuf;
37441
- assert( v>0 );
37765
+#ifdef SQLITE_AVOID_U64_DIVIDE
37766
+ i = sqlite3UInt64ToText(v, zBuf);
37767
+#else
37768
+ i = SQLITE_U64_DIGITS;
3744237769
while( v>=10 ){
3744337770
int kk = (v%100)*2;
3744437771
assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
37445
- assert( TWO_BYTE_ALIGNMENT(&zBuf[i-1]) );
37446
- *(u16*)(&zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
37772
+ assert( TWO_BYTE_ALIGNMENT(&zBuf[i]) );
37773
+ assert( i-2>=0 );
37774
+ *(u16*)(&zBuf[i-2]) = *(u16*)&sqlite3DigitPairs.a[kk];
3744737775
i -= 2;
3744837776
v /= 100;
3744937777
}
3745037778
if( v ){
3745137779
assert( v<10 );
37452
- zBuf[i--] = v + '0';
37780
+ assert( i>0 );
37781
+ zBuf[--i] = v + '0';
3745337782
}
37454
- assert( i>=0 && i<sizeof(p->zBuf)-1 );
37455
- n = sizeof(p->zBuf) - 1 - i; /* Total number of digits extracted */
37783
+#endif /* SQLITE_AVOID_U64_DIVIDE */
37784
+ assert( i>=0 && i<SQLITE_U64_DIGITS );
37785
+ n = SQLITE_U64_DIGITS - i; /* Total number of digits extracted */
3745637786
assert( n>0 );
37457
- assert( n<sizeof(p->zBuf) );
37458
- testcase( n==sizeof(p->zBuf)-1 );
37787
+ assert( n<=SQLITE_U64_DIGITS );
3745937788
p->iDP = n + exp;
3746037789
if( iRound<=0 ){
3746137790
iRound = p->iDP - iRound;
37462
- if( iRound==0 && zBuf[i+1]>='5' ){
37791
+ if( iRound==0 && zBuf[i]>='5' ){
3746337792
iRound = 1;
37464
- zBuf[i--] = '0';
37793
+ zBuf[--i] = '0';
3746537794
n++;
3746637795
p->iDP++;
3746737796
}
3746837797
}
37469
- z = &zBuf[i+1]; /* z points to the first digit */
37798
+ z = &zBuf[i]; /* z points to the first digit */
3747037799
if( iRound>0 && (iRound<n || n>mxRound) ){
3747137800
if( iRound>mxRound ) iRound = mxRound;
3747237801
if( iRound==17 ){
3747337802
/* If the precision is exactly 17, which only happens with the "!"
3747437803
** flag (ex: "%!.17g") then try to reduce the precision if that
@@ -85833,11 +86162,11 @@
8583386162
** rc>0 => All of the input is well-formed
8583486163
** (rc&2)==0 => The number is expressed as an integer, with no
8583586164
** decimal point or eNNN suffix.
8583686165
*/
8583786166
SQLITE_PRIVATE int sqlite3MemRealValueRC(Mem *pMem, double *pValue){
85838
- assert( pMem->db!=0 );
86167
+ testcase( pMem->db==0 );
8583986168
assert( pMem->flags & (MEM_Str|MEM_Blob) );
8584086169
if( pMem->z==0 ){
8584186170
*pValue = 0.0;
8584286171
return 0;
8584386172
}else if( pMem->enc==SQLITE_UTF8
@@ -131514,11 +131843,10 @@
131514131843
** forms 2 through 5, then rebuild the union of all matching indexes,
131515131844
** taken care to avoid rebuilding the same index more than once.
131516131845
*/
131517131846
#ifndef SQLITE_OMIT_REINDEX
131518131847
SQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){
131519
- CollSeq *pColl; /* Collating sequence to be reindexed, or NULL */
131520131848
char *z = 0; /* Name of a table or index or collation */
131521131849
const char *zDb = 0; /* Name of the database */
131522131850
int iReDb = -1; /* The database index number */
131523131851
sqlite3 *db = pParse->db; /* The database connection */
131524131852
Token *pObjName; /* Name of the table or index to be reindexed */
@@ -131553,11 +131881,11 @@
131553131881
if( !bAll ){
131554131882
if( zDb==0 && sqlite3StrICmp(z, "expressions")==0 ){
131555131883
isExprIdx = 1;
131556131884
bMatch = 1;
131557131885
}
131558
- if( zDb==0 && (pColl = sqlite3FindCollSeq(db, ENC(db), z, 0))!=0 ){
131886
+ if( zDb==0 && sqlite3FindCollSeq(db, ENC(db), z, 0)!=0 ){
131559131887
zColl = z;
131560131888
bMatch = 1;
131561131889
}
131562131890
if( zColl==0 && (pReTab = sqlite3FindTable(db, z, zDb))!=0 ){
131563131891
bMatch = 1;
@@ -134449,22 +134777,15 @@
134449134777
** require enhancements to the implementation. */
134450134778
assert( pStr!=0 && pStr->nChar==0 );
134451134779
134452134780
switch( sqlite3_value_type(pValue) ){
134453134781
case SQLITE_FLOAT: {
134454
- double r1, r2;
134455
- const char *zVal;
134456
- r1 = sqlite3_value_double(pValue);
134457
- sqlite3_str_appendf(pStr, "%!0.15g", r1);
134458
- zVal = sqlite3_str_value(pStr);
134459
- if( zVal ){
134460
- sqlite3AtoF(zVal, &r2);
134461
- if( r1!=r2 ){
134462
- sqlite3_str_reset(pStr);
134463
- sqlite3_str_appendf(pStr, "%!0.20e", r1);
134464
- }
134465
- }
134782
+ /* ,--- Show infinity as 9.0e+999
134783
+ ** |
134784
+ ** | ,--- 17 precision guarantees round-trip
134785
+ ** v v */
134786
+ sqlite3_str_appendf(pStr, "%!0.17g", sqlite3_value_double(pValue));
134466134787
break;
134467134788
}
134468134789
case SQLITE_INTEGER: {
134469134790
sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
134470134791
break;
@@ -186195,11 +186516,11 @@
186195186516
if( db->mallocFailed ){
186196186517
pParse->rc = SQLITE_NOMEM_BKPT;
186197186518
}
186198186519
if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){
186199186520
if( pParse->zErrMsg==0 ){
186200
- pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
186521
+ pParse->zErrMsg = sqlite3DbStrDup(db, sqlite3ErrStr(pParse->rc));
186201186522
}
186202186523
if( (pParse->prepFlags & SQLITE_PREPARE_DONT_LOG)==0 ){
186203186524
sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
186204186525
}
186205186526
nErr++;
@@ -233377,10 +233698,23 @@
233377233698
aBuf[4] = (i>>24) & 0xFF;
233378233699
aBuf[5] = (i>>16) & 0xFF;
233379233700
aBuf[6] = (i>> 8) & 0xFF;
233380233701
aBuf[7] = (i>> 0) & 0xFF;
233381233702
}
233703
+
233704
+/*
233705
+** Write a double value to the buffer aBuf[].
233706
+*/
233707
+static void sessionPutDouble(u8 *aBuf, double r){
233708
+ /* TODO: SQLite does something special to deal with mixed-endian
233709
+ ** floating point values (e.g. ARM7). This code probably should
233710
+ ** too. */
233711
+ u64 i;
233712
+ assert( sizeof(double)==8 && sizeof(u64)==8 );
233713
+ memcpy(&i, &r, 8);
233714
+ sessionPutI64(aBuf, i);
233715
+}
233382233716
233383233717
/*
233384233718
** This function is used to serialize the contents of value pValue (see
233385233719
** comment titled "RECORD FORMAT" above).
233386233720
**
@@ -233415,20 +233749,17 @@
233415233749
case SQLITE_FLOAT:
233416233750
if( aBuf ){
233417233751
/* TODO: SQLite does something special to deal with mixed-endian
233418233752
** floating point values (e.g. ARM7). This code probably should
233419233753
** too. */
233420
- u64 i;
233421233754
if( eType==SQLITE_INTEGER ){
233422
- i = (u64)sqlite3_value_int64(pValue);
233755
+ u64 i = (u64)sqlite3_value_int64(pValue);
233756
+ sessionPutI64(&aBuf[1], i);
233423233757
}else{
233424
- double r;
233425
- assert( sizeof(double)==8 && sizeof(u64)==8 );
233426
- r = sqlite3_value_double(pValue);
233427
- memcpy(&i, &r, 8);
233758
+ double r = sqlite3_value_double(pValue);
233759
+ sessionPutDouble(&aBuf[1], r);
233428233760
}
233429
- sessionPutI64(&aBuf[1], i);
233430233761
}
233431233762
nByte = 9;
233432233763
break;
233433233764
233434233765
default: {
@@ -234356,13 +234687,11 @@
234356234687
break;
234357234688
}
234358234689
234359234690
case SQLITE_FLOAT: {
234360234691
double rVal = sqlite3_column_double(pDflt, iField);
234361
- i64 iVal = 0;
234362
- memcpy(&iVal, &rVal, sizeof(rVal));
234363
- sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal);
234692
+ sessionPutDouble(&pNew->aRecord[pNew->nRecord], rVal);
234364234693
pNew->nRecord += 8;
234365234694
break;
234366234695
}
234367234696
234368234697
case SQLITE_TEXT: {
@@ -235615,19 +235944,18 @@
235615235944
){
235616235945
if( *pRc==SQLITE_OK ){
235617235946
int eType = sqlite3_column_type(pStmt, iCol);
235618235947
sessionAppendByte(p, (u8)eType, pRc);
235619235948
if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
235620
- sqlite3_int64 i;
235621235949
u8 aBuf[8];
235622235950
if( eType==SQLITE_INTEGER ){
235623
- i = sqlite3_column_int64(pStmt, iCol);
235951
+ sqlite3_int64 i = sqlite3_column_int64(pStmt, iCol);
235952
+ sessionPutI64(aBuf, i);
235624235953
}else{
235625235954
double r = sqlite3_column_double(pStmt, iCol);
235626
- memcpy(&i, &r, 8);
235955
+ sessionPutDouble(aBuf, r);
235627235956
}
235628
- sessionPutI64(aBuf, i);
235629235957
sessionAppendBlob(p, aBuf, 8, pRc);
235630235958
}
235631235959
if( eType==SQLITE_BLOB || eType==SQLITE_TEXT ){
235632235960
u8 *z;
235633235961
int nByte;
@@ -238664,10 +238992,25 @@
238664238992
xFilter, 0, xConflict, pCtx,
238665238993
0, 0, 0
238666238994
);
238667238995
}
238668238996
238997
+/*
238998
+** The parts of the sqlite3_changegroup structure used by the
238999
+** sqlite3changegroup_change_xxx() APIs.
239000
+*/
239001
+typedef struct ChangeData ChangeData;
239002
+struct ChangeData {
239003
+ SessionTable *pTab;
239004
+ int bIndirect;
239005
+ int eOp;
239006
+
239007
+ int nBufAlloc;
239008
+ SessionBuffer *aBuf;
239009
+ SessionBuffer record;
239010
+};
239011
+
238669239012
/*
238670239013
** sqlite3_changegroup handle.
238671239014
*/
238672239015
struct sqlite3_changegroup {
238673239016
int rc; /* Error code */
@@ -238675,10 +239018,11 @@
238675239018
SessionTable *pList; /* List of tables in current patch */
238676239019
SessionBuffer rec;
238677239020
238678239021
sqlite3 *db; /* Configured by changegroup_schema() */
238679239022
char *zDb; /* Configured by changegroup_schema() */
239023
+ ChangeData cd; /* Used by changegroup_change_xxx() APIs. */
238680239024
};
238681239025
238682239026
/*
238683239027
** This function is called to merge two changes to the same row together as
238684239028
** part of an sqlite3changeset_concat() operation. A new change object is
@@ -238914,19 +239258,18 @@
238914239258
int eType = sqlite3_column_type(pTab->pDfltStmt, ii);
238915239259
sessionAppendByte(pOut, eType, &rc);
238916239260
switch( eType ){
238917239261
case SQLITE_FLOAT:
238918239262
case SQLITE_INTEGER: {
238919
- i64 iVal;
238920
- if( eType==SQLITE_INTEGER ){
238921
- iVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
238922
- }else{
238923
- double rVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
238924
- memcpy(&iVal, &rVal, sizeof(i64));
238925
- }
238926239263
if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){
238927
- sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal);
239264
+ if( eType==SQLITE_INTEGER ){
239265
+ sqlite3_int64 iVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
239266
+ sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal);
239267
+ }else{
239268
+ double rVal = sqlite3_column_double(pTab->pDfltStmt, ii);
239269
+ sessionPutDouble(&pOut->aBuf[pOut->nBuf], rVal);
239270
+ }
238928239271
pOut->nBuf += 8;
238929239272
}
238930239273
break;
238931239274
}
238932239275
@@ -238993,17 +239336,23 @@
238993239336
int nTab = (int)strlen(zTab);
238994239337
u8 *abPK = 0;
238995239338
int nCol = 0;
238996239339
238997239340
*ppTab = 0;
238998
- sqlite3changeset_pk(pIter, &abPK, &nCol);
238999239341
239000239342
/* Search the list for an existing table */
239001239343
for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){
239002239344
if( 0==sqlite3_strnicmp(pTab->zName, zTab, nTab+1) ) break;
239003239345
}
239004239346
239347
+
239348
+ if( pIter ){
239349
+ sqlite3changeset_pk(pIter, &abPK, &nCol);
239350
+ }else if( !pTab && !pGrp->db ){
239351
+ return SQLITE_OK;
239352
+ }
239353
+
239005239354
/* If one was not found above, create a new table now */
239006239355
if( !pTab ){
239007239356
SessionTable **ppNew;
239008239357
239009239358
pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nTab+1);
@@ -239018,12 +239367,12 @@
239018239367
memcpy(pTab->zName, zTab, nTab+1);
239019239368
239020239369
if( pGrp->db ){
239021239370
pTab->nCol = 0;
239022239371
rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb);
239023
- if( rc ){
239024
- assert( pTab->azCol==0 );
239372
+ if( rc || pTab->nCol==0 ){
239373
+ sqlite3_free(pTab->azCol);
239025239374
sqlite3_free(pTab);
239026239375
return rc;
239027239376
}
239028239377
}
239029239378
@@ -239034,78 +239383,61 @@
239034239383
for(ppNew=&pGrp->pList; *ppNew; ppNew=&(*ppNew)->pNext);
239035239384
*ppNew = pTab;
239036239385
}
239037239386
239038239387
/* Check that the table is compatible. */
239039
- if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){
239388
+ if( pIter && !sessionChangesetCheckCompat(pTab, nCol, abPK) ){
239040239389
rc = SQLITE_SCHEMA;
239041239390
}
239042239391
239043239392
*ppTab = pTab;
239044239393
return rc;
239045239394
}
239046239395
239047239396
/*
239048
-** Add the change currently indicated by iterator pIter to the hash table
239049
-** belonging to changegroup pGrp.
239397
+** Add a single change to the changegroup pGrp.
239050239398
*/
239051239399
static int sessionOneChangeToHash(
239052
- sqlite3_changegroup *pGrp,
239053
- sqlite3_changeset_iter *pIter,
239054
- int bRebase
239400
+ sqlite3_changegroup *pGrp, /* Changegroup to update */
239401
+ SessionTable *pTab, /* Table change pertains to */
239402
+ int op, /* One of SQLITE_INSERT, UPDATE, DELETE */
239403
+ int bIndirect, /* True to flag change as "indirect" */
239404
+ int nCol, /* Number of columns in record(s) */
239405
+ u8 *aRec, /* Serialized change record(s) */
239406
+ int nRec, /* Size of aRec[] in bytes */
239407
+ int bRebase /* True if this is a rebase blob */
239055239408
){
239056239409
int rc = SQLITE_OK;
239057
- int nCol = 0;
239058
- int op = 0;
239059239410
int iHash = 0;
239060
- int bIndirect = 0;
239061239411
SessionChange *pChange = 0;
239062239412
SessionChange *pExist = 0;
239063239413
SessionChange **pp = 0;
239064
- SessionTable *pTab = 0;
239065
- u8 *aRec = &pIter->in.aData[pIter->in.iCurrent + 2];
239066
- int nRec = (pIter->in.iNext - pIter->in.iCurrent) - 2;
239067239414
239068239415
assert( nRec>0 );
239069239416
239070
- /* Ensure that only changesets, or only patchsets, but not a mixture
239071
- ** of both, are being combined. It is an error to try to combine a
239072
- ** changeset and a patchset. */
239073
- if( pGrp->pList==0 ){
239074
- pGrp->bPatch = pIter->bPatchset;
239075
- }else if( pIter->bPatchset!=pGrp->bPatch ){
239076
- rc = SQLITE_ERROR;
239077
- }
239078
-
239079
- if( rc==SQLITE_OK ){
239080
- const char *zTab = 0;
239081
- sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
239082
- rc = sessionChangesetFindTable(pGrp, zTab, pIter, &pTab);
239083
- }
239084
-
239085
- if( rc==SQLITE_OK && nCol<pTab->nCol ){
239417
+ if( nCol<pTab->nCol ){
239086239418
SessionBuffer *pBuf = &pGrp->rec;
239087239419
rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, pBuf);
239088239420
aRec = pBuf->aBuf;
239089239421
nRec = pBuf->nBuf;
239090239422
assert( pGrp->db );
239091239423
}
239092239424
239093
- if( rc==SQLITE_OK && sessionGrowHash(0, pIter->bPatchset, pTab) ){
239425
+ if( rc==SQLITE_OK && sessionGrowHash(0, pGrp->bPatch, pTab) ){
239094239426
rc = SQLITE_NOMEM;
239095239427
}
239096239428
239097239429
if( rc==SQLITE_OK ){
239098239430
/* Search for existing entry. If found, remove it from the hash table.
239099239431
** Code below may link it back in. */
239100239432
iHash = sessionChangeHash(
239101
- pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange
239433
+ pTab, (pGrp->bPatch && op==SQLITE_DELETE), aRec, pTab->nChange
239102239434
);
239103239435
for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){
239104239436
int bPkOnly1 = 0;
239105239437
int bPkOnly2 = 0;
239106
- if( pIter->bPatchset ){
239438
+ if( pGrp->bPatch ){
239107239439
bPkOnly1 = (*pp)->op==SQLITE_DELETE;
239108239440
bPkOnly2 = op==SQLITE_DELETE;
239109239441
}
239110239442
if( sessionChangeEqual(pTab, bPkOnly1, (*pp)->aRecord, bPkOnly2, aRec) ){
239111239443
pExist = *pp;
@@ -239116,18 +239448,59 @@
239116239448
}
239117239449
}
239118239450
239119239451
if( rc==SQLITE_OK ){
239120239452
rc = sessionChangeMerge(pTab, bRebase,
239121
- pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange
239453
+ pGrp->bPatch, pExist, op, bIndirect, aRec, nRec, &pChange
239122239454
);
239123239455
}
239124239456
if( rc==SQLITE_OK && pChange ){
239125239457
pChange->pNext = pTab->apChange[iHash];
239126239458
pTab->apChange[iHash] = pChange;
239127239459
pTab->nEntry++;
239128239460
}
239461
+
239462
+ return rc;
239463
+}
239464
+
239465
+/*
239466
+** Add the change currently indicated by iterator pIter to the hash table
239467
+** belonging to changegroup pGrp.
239468
+*/
239469
+static int sessionOneChangeIterToHash(
239470
+ sqlite3_changegroup *pGrp,
239471
+ sqlite3_changeset_iter *pIter,
239472
+ int bRebase
239473
+){
239474
+ u8 *aRec = &pIter->in.aData[pIter->in.iCurrent + 2];
239475
+ int nRec = (pIter->in.iNext - pIter->in.iCurrent) - 2;
239476
+ const char *zTab = 0;
239477
+ int nCol = 0;
239478
+ int op = 0;
239479
+ int bIndirect = 0;
239480
+ int rc = SQLITE_OK;
239481
+ SessionTable *pTab = 0;
239482
+
239483
+ /* Ensure that only changesets, or only patchsets, but not a mixture
239484
+ ** of both, are being combined. It is an error to try to combine a
239485
+ ** changeset and a patchset. */
239486
+ if( pGrp->pList==0 ){
239487
+ pGrp->bPatch = pIter->bPatchset;
239488
+ }else if( pIter->bPatchset!=pGrp->bPatch ){
239489
+ rc = SQLITE_ERROR;
239490
+ }
239491
+
239492
+ if( rc==SQLITE_OK ){
239493
+ sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
239494
+ rc = sessionChangesetFindTable(pGrp, zTab, pIter, &pTab);
239495
+ }
239496
+
239497
+ if( rc==SQLITE_OK ){
239498
+ rc = sessionOneChangeToHash(
239499
+ pGrp, pTab, op, bIndirect, nCol, aRec, nRec, bRebase
239500
+ );
239501
+ }
239129239502
239130239503
if( rc==SQLITE_OK ) rc = pIter->rc;
239131239504
return rc;
239132239505
}
239133239506
@@ -239144,11 +239517,11 @@
239144239517
int nRec;
239145239518
int rc = SQLITE_OK;
239146239519
239147239520
pIter->in.bNoDiscard = 1;
239148239521
while( SQLITE_ROW==(sessionChangesetNext(pIter, &aRec, &nRec, 0)) ){
239149
- rc = sessionOneChangeToHash(pGrp, pIter, bRebase);
239522
+ rc = sessionOneChangeIterToHash(pGrp, pIter, bRebase);
239150239523
if( rc!=SQLITE_OK ) break;
239151239524
}
239152239525
239153239526
if( rc==SQLITE_OK ) rc = pIter->rc;
239154239527
return rc;
@@ -239233,10 +239606,37 @@
239233239606
memset(p, 0, sizeof(sqlite3_changegroup));
239234239607
}
239235239608
*pp = p;
239236239609
return rc;
239237239610
}
239611
+
239612
+/*
239613
+** Configure a changegroup object.
239614
+*/
239615
+SQLITE_API int sqlite3changegroup_config(
239616
+ sqlite3_changegroup *pGrp,
239617
+ int op,
239618
+ void *pArg
239619
+){
239620
+ int rc = SQLITE_OK;
239621
+
239622
+ switch( op ){
239623
+ case SQLITE_CHANGEGROUP_CONFIG_PATCHSET: {
239624
+ int arg = *(int*)pArg;
239625
+ if( pGrp->pList==0 && arg>=0 ){
239626
+ pGrp->bPatch = (arg>0);
239627
+ }
239628
+ *(int*)pArg = pGrp->bPatch;
239629
+ break;
239630
+ }
239631
+ default:
239632
+ rc = SQLITE_MISUSE;
239633
+ break;
239634
+ }
239635
+
239636
+ return rc;
239637
+}
239238239638
239239239639
/*
239240239640
** Provide a database schema to the changegroup object.
239241239641
*/
239242239642
SQLITE_API int sqlite3changegroup_schema(
@@ -239292,11 +239692,11 @@
239292239692
){
239293239693
/* Iterator does not point to any valid entry or is an INVERT iterator. */
239294239694
rc = SQLITE_ERROR;
239295239695
}else{
239296239696
pIter->in.bNoDiscard = 1;
239297
- rc = sessionOneChangeToHash(pGrp, pIter, 0);
239697
+ rc = sessionOneChangeIterToHash(pGrp, pIter, 0);
239298239698
}
239299239699
return rc;
239300239700
}
239301239701
239302239702
/*
@@ -239344,10 +239744,16 @@
239344239744
/*
239345239745
** Delete a changegroup object.
239346239746
*/
239347239747
SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){
239348239748
if( pGrp ){
239749
+ int ii;
239750
+ for(ii=0; ii<pGrp->cd.nBufAlloc; ii++){
239751
+ sqlite3_free(pGrp->cd.aBuf[ii].aBuf);
239752
+ }
239753
+ sqlite3_free(pGrp->cd.record.aBuf);
239754
+ sqlite3_free(pGrp->cd.aBuf);
239349239755
sqlite3_free(pGrp->zDb);
239350239756
sessionDeleteTable(0, pGrp->pList);
239351239757
sqlite3_free(pGrp->rec.aBuf);
239352239758
sqlite3_free(pGrp);
239353239759
}
@@ -239771,10 +240177,332 @@
239771240177
}
239772240178
default:
239773240179
rc = SQLITE_MISUSE;
239774240180
break;
239775240181
}
240182
+ return rc;
240183
+}
240184
+
240185
+/*
240186
+** Begin adding a change to a changegroup object.
240187
+*/
240188
+SQLITE_API int sqlite3changegroup_change_begin(
240189
+ sqlite3_changegroup *pGrp,
240190
+ int eOp,
240191
+ const char *zTab,
240192
+ int bIndirect,
240193
+ char **pzErr
240194
+){
240195
+ SessionTable *pTab = 0;
240196
+ int rc = SQLITE_OK;
240197
+
240198
+ if( pGrp->cd.pTab ){
240199
+ rc = SQLITE_MISUSE;
240200
+ }else if( eOp!=SQLITE_INSERT && eOp!=SQLITE_UPDATE && eOp!=SQLITE_DELETE ){
240201
+ rc = SQLITE_ERROR;
240202
+ }else{
240203
+ rc = sessionChangesetFindTable(pGrp, zTab, 0, &pTab);
240204
+ }
240205
+ if( rc==SQLITE_OK ){
240206
+ if( pTab==0 ){
240207
+ if( pzErr ){
240208
+ *pzErr = sqlite3_mprintf("no such table: %s", zTab);
240209
+ }
240210
+ rc = SQLITE_ERROR;
240211
+ }else{
240212
+ int nReq = pTab->nCol * (eOp==SQLITE_UPDATE ? 2 : 1);
240213
+ pGrp->cd.pTab = pTab;
240214
+ pGrp->cd.eOp = eOp;
240215
+ pGrp->cd.bIndirect = bIndirect;
240216
+
240217
+ if( pGrp->cd.nBufAlloc<nReq ){
240218
+ SessionBuffer *aBuf = (SessionBuffer*)sqlite3_realloc(
240219
+ pGrp->cd.aBuf, nReq * sizeof(SessionBuffer)
240220
+ );
240221
+ if( aBuf==0 ){
240222
+ rc = SQLITE_NOMEM;
240223
+ }else{
240224
+ memset(&aBuf[pGrp->cd.nBufAlloc], 0,
240225
+ sizeof(SessionBuffer) * (nReq - pGrp->cd.nBufAlloc)
240226
+ );
240227
+ pGrp->cd.aBuf = aBuf;
240228
+ pGrp->cd.nBufAlloc = nReq;
240229
+ }
240230
+ }
240231
+
240232
+#ifdef SQLITE_DEBUG
240233
+ {
240234
+ /* Assert that all column values are currently undefined */
240235
+ int ii;
240236
+ for(ii=0; ii<pGrp->cd.nBufAlloc; ii++){
240237
+ assert( pGrp->cd.aBuf[ii].nBuf==0 );
240238
+ }
240239
+ }
240240
+#endif
240241
+ }
240242
+ }
240243
+
240244
+ return rc;
240245
+}
240246
+
240247
+/*
240248
+** This function does processing common to the _change_int64(), _change_text()
240249
+** and other similar APIs.
240250
+*/
240251
+static int checkChangeParams(
240252
+ sqlite3_changegroup *pGrp,
240253
+ int bNew,
240254
+ int iCol,
240255
+ sqlite3_int64 nReq,
240256
+ SessionBuffer **ppBuf
240257
+){
240258
+ int rc = SQLITE_OK;
240259
+ if( pGrp->cd.pTab==0 ){
240260
+ rc = SQLITE_MISUSE;
240261
+ }else if( iCol<0 || iCol>=pGrp->cd.pTab->nCol ){
240262
+ rc = SQLITE_RANGE;
240263
+ }else if(
240264
+ (bNew && pGrp->cd.eOp==SQLITE_DELETE)
240265
+ || (!bNew && pGrp->cd.eOp==SQLITE_INSERT)
240266
+ ){
240267
+ rc = SQLITE_ERROR;
240268
+ }else{
240269
+ SessionBuffer *pBuf = &pGrp->cd.aBuf[iCol];
240270
+ if( pGrp->cd.eOp==SQLITE_UPDATE && bNew ){
240271
+ pBuf += pGrp->cd.pTab->nCol;
240272
+ }
240273
+ pBuf->nBuf = 0;
240274
+ sessionBufferGrow(pBuf, nReq, &rc);
240275
+ pBuf->nBuf = nReq;
240276
+ *ppBuf = pBuf;
240277
+ }
240278
+ return rc;
240279
+}
240280
+
240281
+/*
240282
+** Configure the change currently under construction with an integer value.
240283
+*/
240284
+SQLITE_API int sqlite3changegroup_change_int64(
240285
+ sqlite3_changegroup *pGrp,
240286
+ int bNew,
240287
+ int iCol,
240288
+ sqlite3_int64 iVal
240289
+){
240290
+ int rc = SQLITE_OK;
240291
+ SessionBuffer *pBuf = 0;
240292
+
240293
+ if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, 9, &pBuf)) ){
240294
+ return rc;
240295
+ }
240296
+
240297
+ pBuf->aBuf[0] = SQLITE_INTEGER;
240298
+ sessionPutI64(&pBuf->aBuf[1], iVal);
240299
+ return SQLITE_OK;
240300
+}
240301
+
240302
+/*
240303
+** Configure the change currently under construction with a null value.
240304
+*/
240305
+SQLITE_API int sqlite3changegroup_change_null(
240306
+ sqlite3_changegroup *pGrp,
240307
+ int bNew,
240308
+ int iCol
240309
+){
240310
+ int rc = SQLITE_OK;
240311
+ SessionBuffer *pBuf = 0;
240312
+
240313
+ if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, 1, &pBuf)) ){
240314
+ return rc;
240315
+ }
240316
+
240317
+ pBuf->aBuf[0] = SQLITE_NULL;
240318
+ return SQLITE_OK;
240319
+}
240320
+
240321
+/*
240322
+** Configure the change currently under construction with a real value.
240323
+*/
240324
+SQLITE_API int sqlite3changegroup_change_double(
240325
+ sqlite3_changegroup *pGrp,
240326
+ int bNew,
240327
+ int iCol,
240328
+ double fVal
240329
+){
240330
+ int rc = SQLITE_OK;
240331
+ SessionBuffer *pBuf = 0;
240332
+
240333
+ if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, 9, &pBuf)) ){
240334
+ return rc;
240335
+ }
240336
+
240337
+ pBuf->aBuf[0] = SQLITE_FLOAT;
240338
+ sessionPutDouble(&pBuf->aBuf[1], fVal);
240339
+ return SQLITE_OK;
240340
+}
240341
+
240342
+/*
240343
+** Configure the change currently under construction with a text value.
240344
+*/
240345
+SQLITE_API int sqlite3changegroup_change_text(
240346
+ sqlite3_changegroup *pGrp,
240347
+ int bNew,
240348
+ int iCol,
240349
+ const char *pVal,
240350
+ int nVal
240351
+){
240352
+ int nText = nVal>=0 ? nVal : strlen(pVal);
240353
+ sqlite3_int64 nByte = 1 + sessionVarintLen(nText) + nText;
240354
+ int rc = SQLITE_OK;
240355
+ SessionBuffer *pBuf = 0;
240356
+
240357
+ if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, nByte, &pBuf)) ){
240358
+ return rc;
240359
+ }
240360
+
240361
+ pBuf->aBuf[0] = SQLITE_TEXT;
240362
+ pBuf->nBuf = (1 + sessionVarintPut(&pBuf->aBuf[1], nText));
240363
+ memcpy(&pBuf->aBuf[pBuf->nBuf], pVal, nText);
240364
+ pBuf->nBuf += nText;
240365
+
240366
+ return SQLITE_OK;
240367
+}
240368
+
240369
+/*
240370
+** Configure the change currently under construction with a blob value.
240371
+*/
240372
+SQLITE_API int sqlite3changegroup_change_blob(
240373
+ sqlite3_changegroup *pGrp,
240374
+ int bNew,
240375
+ int iCol,
240376
+ const void *pVal,
240377
+ int nVal
240378
+){
240379
+ sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) + nVal;
240380
+ int rc = SQLITE_OK;
240381
+ SessionBuffer *pBuf = 0;
240382
+
240383
+ if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, nByte, &pBuf)) ){
240384
+ return rc;
240385
+ }
240386
+
240387
+ pBuf->aBuf[0] = SQLITE_BLOB;
240388
+ pBuf->nBuf = (1 + sessionVarintPut(&pBuf->aBuf[1], nVal));
240389
+ memcpy(&pBuf->aBuf[pBuf->nBuf], pVal, nVal);
240390
+ pBuf->nBuf += nVal;
240391
+
240392
+ return SQLITE_OK;
240393
+}
240394
+
240395
+/*
240396
+** Finish any change currently being constructed by the changegroup object.
240397
+*/
240398
+SQLITE_API int sqlite3changegroup_change_finish(
240399
+ sqlite3_changegroup *pGrp,
240400
+ int bDiscard,
240401
+ char **pzErr
240402
+){
240403
+ int rc = SQLITE_OK;
240404
+ if( pGrp->cd.pTab ){
240405
+ SessionBuffer *aBuf = pGrp->cd.aBuf;
240406
+ int ii;
240407
+
240408
+ if( bDiscard==0 ){
240409
+ int nBuf = pGrp->cd.pTab->nCol;
240410
+ u8 eUndef = SQLITE_NULL;
240411
+ if( pGrp->cd.eOp==SQLITE_UPDATE ){
240412
+ for(ii=0; ii<nBuf; ii++){
240413
+ if( pGrp->cd.pTab->abPK[ii] ){
240414
+ if( aBuf[ii].nBuf<=1 ){
240415
+ *pzErr = sqlite3_mprintf(
240416
+ "invalid change: %s value in PK of old.* record",
240417
+ aBuf[ii].nBuf==1 ? "null" : "undefined"
240418
+ );
240419
+ rc = SQLITE_ERROR;
240420
+ break;
240421
+ }else if( aBuf[ii + nBuf].nBuf>0 ){
240422
+ *pzErr = sqlite3_mprintf(
240423
+ "invalid change: defined value in PK of new.* record"
240424
+ );
240425
+ rc = SQLITE_ERROR;
240426
+ break;
240427
+ }
240428
+ }else
240429
+ if( pGrp->bPatch==0 && (aBuf[ii].nBuf>0)!=(aBuf[ii+nBuf].nBuf>0) ){
240430
+ *pzErr = sqlite3_mprintf(
240431
+ "invalid change: column %d "
240432
+ "- old.* value is %sdefined but new.* is %sdefined",
240433
+ ii, aBuf[ii].nBuf ? "" : "un", aBuf[ii+nBuf].nBuf ? "" : "un"
240434
+ );
240435
+ rc = SQLITE_ERROR;
240436
+ break;
240437
+ }
240438
+ }
240439
+ eUndef = 0x00;
240440
+ if( pGrp->bPatch==0 ) nBuf = nBuf * 2;
240441
+ }else{
240442
+ for(ii=0; ii<nBuf; ii++){
240443
+ int isPK = pGrp->cd.pTab->abPK[ii];
240444
+ if( (pGrp->cd.eOp==SQLITE_INSERT || pGrp->bPatch==0 || isPK)
240445
+ && aBuf[ii].nBuf==0
240446
+ ){
240447
+ *pzErr = sqlite3_mprintf(
240448
+ "invalid change: column %d is undefined", ii
240449
+ );
240450
+ rc = SQLITE_ERROR;
240451
+ break;
240452
+ }
240453
+ if( aBuf[ii].nBuf==1 && isPK ){
240454
+ *pzErr = sqlite3_mprintf(
240455
+ "invalid change: null value in PK"
240456
+ );
240457
+ rc = SQLITE_ERROR;
240458
+ break;
240459
+ }
240460
+ }
240461
+ }
240462
+
240463
+ pGrp->cd.record.nBuf = 0;
240464
+ for(ii=0; ii<nBuf; ii++){
240465
+ SessionBuffer *p = &pGrp->cd.aBuf[ii];
240466
+ if( pGrp->bPatch ){
240467
+ if( pGrp->cd.pTab->abPK[ii]==0 ){
240468
+ if( pGrp->cd.eOp==SQLITE_UPDATE ){
240469
+ p += pGrp->cd.pTab->nCol;
240470
+ }else if( pGrp->cd.eOp==SQLITE_DELETE ){
240471
+ continue;
240472
+ }
240473
+ }
240474
+ }
240475
+ if( 0==sessionBufferGrow(&pGrp->cd.record, p->nBuf?p->nBuf:1, &rc) ){
240476
+ if( p->nBuf ){
240477
+ memcpy(&pGrp->cd.record.aBuf[pGrp->cd.record.nBuf],p->aBuf,p->nBuf);
240478
+ pGrp->cd.record.nBuf += p->nBuf;
240479
+ }else{
240480
+ pGrp->cd.record.aBuf[pGrp->cd.record.nBuf++] = eUndef;
240481
+ }
240482
+ }
240483
+ }
240484
+ if( rc==SQLITE_OK ){
240485
+ rc = sessionOneChangeToHash(
240486
+ pGrp, pGrp->cd.pTab,
240487
+ pGrp->cd.eOp, pGrp->cd.bIndirect, pGrp->cd.pTab->nCol,
240488
+ pGrp->cd.record.aBuf, pGrp->cd.record.nBuf, 0
240489
+ );
240490
+ }
240491
+ }
240492
+
240493
+ /* Reset all aBuf[] entries to "undefined". */
240494
+ {
240495
+ int nZero = pGrp->cd.pTab->nCol;
240496
+ if( pGrp->cd.eOp==SQLITE_UPDATE ) nZero += nZero;
240497
+ for(ii=0; ii<nZero; ii++){
240498
+ pGrp->cd.aBuf[ii].nBuf = 0;
240499
+ }
240500
+ }
240501
+ pGrp->cd.pTab = 0;
240502
+ }
240503
+
239776240504
return rc;
239777240505
}
239778240506
239779240507
#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */
239780240508
@@ -262478,11 +263206,11 @@
262478263206
int nArg, /* Number of args */
262479263207
sqlite3_value **apUnused /* Function arguments */
262480263208
){
262481263209
assert( nArg==0 );
262482263210
UNUSED_PARAM2(nArg, apUnused);
262483
- sqlite3_result_text(pCtx, "fts5: 2026-03-26 14:19:34 97ee48b6ef65fb55633196282c9e75b3b0a3b81ba9755f63493a38e3f1a5610c", -1, SQLITE_TRANSIENT);
263211
+ sqlite3_result_text(pCtx, "fts5: 2026-04-01 11:39:13 009b576dcd5fccaaa52459dbfaa1b2a6fcf6d372e4b8d63553dfa88aab9a759c", -1, SQLITE_TRANSIENT);
262484263212
}
262485263213
262486263214
/*
262487263215
** Implementation of fts5_locale(LOCALE, TEXT) function.
262488263216
**
262489263217
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** c5af6a10245b6b847d30002806c1577b020c with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.53.0"
471 #define SQLITE_VERSION_NUMBER 3053000
472 #define SQLITE_SOURCE_ID "2026-03-26 19:11:57 c5af6a10245b6b847d30002806c1577b020c36ab27f7b1cf202ade136aa4779c"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-03-26T19:11:57.079Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -897,11 +897,11 @@
897 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
898 #define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
899 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
900 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
901 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
902 #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
903
904 /*
905 ** CAPI3REF: Flags For File Open Operations
906 **
907 ** These bit values are intended for use in the
@@ -1609,10 +1609,16 @@
1609 /* deprecated names */
1610 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1611 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1612 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
1613
 
 
 
 
 
 
1614
1615 /*
1616 ** CAPI3REF: Mutex Handle
1617 **
1618 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
@@ -2030,11 +2036,12 @@
2030 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
2031 ** The exceptional configuration options that may be invoked at any time
2032 ** are called "anytime configuration options".
2033 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
2034 ** [sqlite3_shutdown()] with a first argument that is not an anytime
2035 ** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
 
2036 ** Note, however, that ^sqlite3_config() can be called as part of the
2037 ** implementation of an application-defined [sqlite3_os_init()].
2038 **
2039 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
2040 ** ^If the option is unknown or SQLite is unable to set the option
@@ -2596,13 +2603,14 @@
2596 ** <li><P>The second argument ("sz") is the
2597 ** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2598 ** is less than 8. The "sz" argument should be a multiple of 8 less than
2599 ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2600 ** it does.
2601 ** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2602 ** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2603 ** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
 
2604 ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2605 ** than 1,000,000.
2606 ** </ol>
2607 ** <p>If the "buf" argument is not NULL, then it must
2608 ** point to a memory buffer with a size that is greater than
@@ -2977,11 +2985,11 @@
2977 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2978 ** prior versions.<p>
2979 ** This option takes two arguments which are an integer and a pointer
2980 ** to an integer. The first argument is a small integer, between 3 and 23, or
2981 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2982 ** unaltered if the first argument is zero or out of range. The second argument
2983 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2984 ** the FP_DIGITS setting, after possibly being modified by the first
2985 ** arguments, is written into the integer to which the second argument points.
2986 ** </dd>
2987 **
@@ -2989,14 +2997,16 @@
2989 **
2990 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2991 **
2992 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2993 ** overall call to [sqlite3_db_config()] has a total of four parameters.
2994 ** The first argument (the third parameter to sqlite3_db_config()) is an integer.
2995 ** The second argument is a pointer to an integer. If the first argument is 1,
2996 ** then the option becomes enabled. If the first integer argument is 0, then the
2997 ** option is disabled. If the first argument is -1, then the option setting
 
 
2998 ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2999 ** If the second argument is not NULL, then a value of 0 or 1 is written into
3000 ** the integer to which the second argument points, depending on whether the
3001 ** setting is disabled or enabled after applying any changes specified by
3002 ** the first argument.
@@ -6169,12 +6179,13 @@
6169 ** that the application-defined collating sequence created expects its
6170 ** input strings to be in UTF16 in native byte order, and that the start
6171 ** of the strings must be aligned to a 2-byte boundary.
6172 **
6173 ** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
6174 ** used to specify the text encoding to strings input to [sqlite3_result_text64()]
6175 ** and [sqlite3_bind_text64()]. It means that the input string (call it "z")
 
6176 ** is UTF-8 encoded and that it is zero-terminated. If the length parameter
6177 ** (call it "n") is non-negative, this encoding option means that the caller
6178 ** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
6179 ** byte has a value of zero.
6180 ** This option gives the same output as SQLITE_UTF8, but can be more efficient
@@ -6422,30 +6433,26 @@
6422 **
6423 ** These routines must be called from the same thread as
6424 ** the SQL function that supplied the [sqlite3_value*] parameters.
6425 **
6426 ** As long as the input parameter is correct, these routines can only
6427 ** fail if an out-of-memory error occurs during a format conversion.
6428 ** Only the following subset of interfaces are subject to out-of-memory
6429 ** errors:
6430 **
6431 ** <ul>
6432 ** <li> sqlite3_value_blob()
6433 ** <li> sqlite3_value_text()
6434 ** <li> sqlite3_value_text16()
6435 ** <li> sqlite3_value_text16le()
6436 ** <li> sqlite3_value_text16be()
6437 ** <li> sqlite3_value_bytes()
6438 ** <li> sqlite3_value_bytes16()
6439 ** </ul>
6440 **
6441 ** If an out-of-memory error occurs, then the return value from these
6442 ** routines is the same as if the column had contained an SQL NULL value.
6443 ** Valid SQL NULL returns can be distinguished from out-of-memory errors
6444 ** by invoking the [sqlite3_errcode()] immediately after the suspect
 
 
6445 ** return value is obtained and before any
6446 ** other SQLite interface is called on the same [database connection].
 
 
 
 
 
 
6447 */
6448 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
6449 SQLITE_API double sqlite3_value_double(sqlite3_value*);
6450 SQLITE_API int sqlite3_value_int(sqlite3_value*);
6451 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -6468,11 +6475,12 @@
6468 ** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
6469 ** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding
6470 ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
6471 ** returns something other than SQLITE_TEXT, then the return value from
6472 ** sqlite3_value_encoding(X) is meaningless. ^Calls to
6473 ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)],
 
6474 ** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
6475 ** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
6476 ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
6477 **
6478 ** This routine is intended for used by applications that test and validate
@@ -6599,21 +6607,21 @@
6599 ** associate auxiliary data with argument values. If the same argument
6600 ** value is passed to multiple invocations of the same SQL function during
6601 ** query execution, under some circumstances the associated auxiliary data
6602 ** might be preserved. An example of where this might be useful is in a
6603 ** regular-expression matching function. The compiled version of the regular
6604 ** expression can be stored as auxiliary data associated with the pattern string.
6605 ** Then as long as the pattern string remains the same,
6606 ** the compiled regular expression can be reused on multiple
6607 ** invocations of the same function.
6608 **
6609 ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
6610 ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
6611 ** value to the application-defined function. ^N is zero for the left-most
6612 ** function argument. ^If there is no auxiliary data
6613 ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
6614 ** returns a NULL pointer.
6615 **
6616 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6617 ** N-th argument of the application-defined function. ^Subsequent
6618 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
6619 ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
@@ -10722,21 +10730,22 @@
10722 **
10723 ** <table border=1 cellspacing=0 cellpadding=10 width="90%">
10724 ** <tr>
10725 ** <td valign="top">sqlite3_vtab_distinct() return value
10726 ** <td valign="top">Rows are returned in aOrderBy order
10727 ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
 
10728 ** <td valign="top">Duplicates over all colUsed columns may be omitted
10729 ** <tr><td>0<td>yes<td>yes<td>no
10730 ** <tr><td>1<td>no<td>yes<td>no
10731 ** <tr><td>2<td>no<td>yes<td>yes
10732 ** <tr><td>3<td>yes<td>yes<td>yes
10733 ** </table>
10734 **
10735 ** ^For the purposes of comparing virtual table output values to see if the
10736 ** values are the same value for sorting purposes, two NULL values are considered
10737 ** to be the same. In other words, the comparison operator is "IS"
10738 ** (or "IS NOT DISTINCT FROM") and not "==".
10739 **
10740 ** If a virtual table implementation is unable to meet the requirements
10741 ** specified above, then it must not set the "orderByConsumed" flag in the
10742 ** [sqlite3_index_info] object or an incorrect answer may result.
@@ -11586,16 +11595,17 @@
11586 /*
11587 ** CAPI3REF: Bind array values to the CARRAY table-valued function
11588 **
11589 ** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
11590 ** parameter that is the first argument of the [carray() table-valued function].
11591 ** The S parameter is a pointer to the [prepared statement] that uses the carray()
11592 ** functions. I is the parameter index to be bound. I must be the index of the
11593 ** parameter that is the first argument to the carray() table-valued function.
11594 ** P is a pointer to the array to be bound, and N is the number of elements in
11595 ** the array. The F argument is one of constants [SQLITE_CARRAY_INT32],
11596 ** [SQLITE_CARRAY_INT64], [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
 
11597 ** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
11598 **
11599 ** If the X argument is not a NULL pointer or one of the special
11600 ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11601 ** the function X with argument D when it is finished using the data in P.
@@ -13648,10 +13658,236 @@
13648
13649 /*
13650 ** CAPI3REF: Values for sqlite3session_config().
13651 */
13652 #define SQLITE_SESSION_CONFIG_STRMSIZE 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13653
13654 /*
13655 ** Make sure we can call this stuff from C++.
13656 */
13657 #if 0
@@ -21585,21 +21821,26 @@
21585 int nArg; /* Total number of arguments */
21586 int nUsed; /* Number of arguments used so far */
21587 sqlite3_value **apArg; /* The argument values */
21588 };
21589
 
 
 
 
 
21590 /*
21591 ** An instance of this object receives the decoding of a floating point
21592 ** value into an approximate decimal representation.
21593 */
21594 struct FpDecode {
21595 int n; /* Significant digits in the decode */
21596 int iDP; /* Location of the decimal point */
21597 char *z; /* Start of significant digits */
21598 char zBuf[20]; /* Storage for significant digits */
21599 char sign; /* '+' or '-' */
21600 char isSpecial; /* 1: Infinity 2: NaN */
21601 };
21602
21603 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode*,double,int,int);
21604 SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
21605 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
@@ -22283,10 +22524,11 @@
22283 SQLITE_PRIVATE char *sqlite3RCStrNew(u64);
22284 SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64);
22285
22286 SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
22287 SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, i64);
 
22288 SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
22289 SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum*, u8);
22290 SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
22291 SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
22292 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
@@ -32635,10 +32877,11 @@
32635 case etEXP:
32636 case etGENERIC: {
32637 FpDecode s;
32638 int iRound;
32639 int j;
 
32640
32641 if( bArgList ){
32642 realvalue = getDoubleArg(pArgList);
32643 }else{
32644 realvalue = va_arg(ap,double);
@@ -32723,21 +32966,19 @@
32723 if( xtype==etEXP ){
32724 e2 = 0;
32725 }else{
32726 e2 = s.iDP - 1;
32727 }
32728 bufpt = buf;
32729 {
32730 i64 szBufNeeded; /* Size of a temporary buffer needed */
32731 szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
32732 if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32733 if( szBufNeeded > etBUFSIZE ){
32734 bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
32735 if( bufpt==0 ) return;
32736 }
32737 }
32738 zOut = bufpt;
32739 flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
32740 /* The sign in front of the number */
32741 if( prefix ){
32742 *(bufpt++) = prefix;
32743 }
@@ -32781,17 +33022,15 @@
32781 int nn = s.n - j;
32782 if( NEVER(nn>precision) ) nn = precision;
32783 if( nn>0 ){
32784 memcpy(bufpt, s.z+j, nn);
32785 bufpt += nn;
32786 j += nn;
32787 precision -= nn;
32788 }
32789 if( precision>0 && !flag_rtz ){
32790 memset(bufpt, '0', precision);
32791 bufpt += precision;
32792 precision = 0;
32793 }
32794 }
32795 /* Remove trailing zeros and the "." if no digits follow the "." */
32796 if( flag_rtz && flag_dp ){
32797 while( bufpt[-1]=='0' ) *(--bufpt) = 0;
@@ -32818,31 +33057,35 @@
32818 exp %= 100;
32819 }
32820 *(bufpt++) = (char)(exp/10+'0'); /* 10's digit */
32821 *(bufpt++) = (char)(exp%10+'0'); /* 1's digit */
32822 }
32823 *bufpt = 0;
32824
32825 /* The converted number is in buf[] and zero terminated. Output it.
32826 ** Note that the number is in the usual order, not reversed as with
32827 ** integer conversions. */
32828 length = (int)(bufpt-zOut);
32829 bufpt = zOut;
32830
32831 /* Special case: Add leading zeros if the flag_zeropad flag is
32832 ** set and we are not left justified */
32833 if( flag_zeropad && !flag_leftjustify && length < width){
32834 int i;
32835 int nPad = width - length;
32836 for(i=width; i>=nPad; i--){
32837 bufpt[i] = bufpt[i-nPad];
32838 }
32839 i = prefix!=0;
32840 while( nPad-- ) bufpt[i++] = '0';
 
32841 length = width;
32842 }
32843 break;
 
 
 
 
 
 
 
32844 }
32845 case etSIZE:
32846 if( !bArgList ){
32847 *(va_arg(ap,int*)) = pAccum->nChar;
32848 }
@@ -32882,15 +33125,14 @@
32882 precision--;
32883 while( precision > 1 ){
32884 i64 nCopyBytes;
32885 if( nPrior > precision-1 ) nPrior = precision - 1;
32886 nCopyBytes = length*nPrior;
32887 if( nCopyBytes + pAccum->nChar >= pAccum->nAlloc ){
32888 sqlite3StrAccumEnlarge(pAccum, nCopyBytes);
32889 }
32890 if( pAccum->accError ) break;
32891 sqlite3_str_append(pAccum,
32892 &pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
32893 precision -= nPrior;
32894 nPrior *= 2;
32895 }
32896 }
@@ -33231,10 +33473,17 @@
33231 }
33232 }
33233 assert( N>=0 && N<=0x7fffffff );
33234 return (int)N;
33235 }
 
 
 
 
 
 
 
33236
33237 /*
33238 ** Append N copies of character c to the given string buffer.
33239 */
33240 SQLITE_API void sqlite3_str_appendchar(sqlite3_str *p, int N, char c){
@@ -36548,15 +36797,16 @@
36548 ** lower 64-bits of the result into *pLo, and return the high-order
36549 ** 64 bits.
36550 */
36551 static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
36552 #if (defined(__GNUC__) || defined(__clang__)) \
36553 && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv))
 
36554 __uint128_t r = (__uint128_t)a * b;
36555 *pLo = (u64)r;
36556 return (u64)(r>>64);
36557 #elif defined(_MSC_VER) && defined(_M_X64)
36558 *pLo = a*b;
36559 return __umulh(a, b);
36560 #else
36561 u64 a0 = (u32)a;
36562 u64 a1 = a >> 32;
@@ -36583,21 +36833,23 @@
36583 **
36584 ** The lower 64 bits of A*B are discarded.
36585 */
36586 static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36587 #if (defined(__GNUC__) || defined(__clang__)) \
36588 && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv))
 
36589 __uint128_t r = (__uint128_t)a * b;
36590 r += ((__uint128_t)aLo * b) >> 32;
36591 *pLo = (r>>32)&0xffffffff;
36592 return r>>64;
36593 #elif defined(_MSC_VER) && defined(_M_X64)
36594 u64 r1_hi = __umulh(a,b);
36595 u64 r1_lo = a*b;
36596 u64 r2 = (__umulh((u64)aLo,b)<<32) + ((aLo*b)>>32);
36597 r1_hi += _addcarry_u64(0, r1_lo, r2, &r1_lo);
36598 *pLo = r1_lo>>32;
 
36599 return r1_hi;
36600 #else
36601 u64 x2 = a>>32;
36602 u64 x1 = a&0xffffffff;
36603 u64 x0 = aLo;
@@ -36805,11 +37057,12 @@
36805
36806 /*
36807 ** Count leading zeros for a 64-bit unsigned integer.
36808 */
36809 static int countLeadingZeros(u64 m){
36810 #if defined(__GNUC__) || defined(__clang__)
 
36811 return __builtin_clzll(m);
36812 #else
36813 int n = 0;
36814 if( m <= 0x00000000ffffffffULL) { n += 32; m <<= 32; }
36815 if( m <= 0x0000ffffffffffffULL) { n += 16; m <<= 16; }
@@ -36906,16 +37159,19 @@
36906 ** Return positive if the result is a valid real number (or integer) and
36907 ** zero or negative if the string is empty or contains extraneous text.
36908 ** Lower bits of the return value contain addition information about the
36909 ** parse:
36910 **
36911 ** bit 0 => Set for any valid input
36912 ** bit 1 => Input contains a decimal point or eNNN clause
36913 ** This bit is zero if the input is an integer
 
 
36914 ** bit 2 => The input is exactly 0.0, not an underflow from
36915 ** some value near zero
36916 ** bit 3 => More than 19 significant digits in the input
 
36917 **
36918 ** If the input contains a syntax error but begins with text that might
36919 ** be a valid number of some kind, then the result is negative. The
36920 ** result is only zero if no prefix of the input could be interpreted as
36921 ** a number.
@@ -37077,10 +37333,73 @@
37077 "70717273747576777879"
37078 "80818283848586878889"
37079 "90919293949596979899"
37080 };
37081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37082
37083 /*
37084 ** Render an signed 64-bit integer as text. Store the result in zOut[] and
37085 ** return the length of the string that was stored, in bytes. The value
37086 ** returned does not include the zero terminator at the end of the output
@@ -37090,11 +37409,11 @@
37090 */
37091 SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){
37092 int i;
37093 u64 x;
37094 union {
37095 char a[23];
37096 u16 forceAlignment;
37097 } u;
37098 if( v>0 ){
37099 x = v;
37100 }else if( v==0 ){
@@ -37102,10 +37421,13 @@
37102 zOut[1] = 0;
37103 return 1;
37104 }else{
37105 x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : (u64)-v;
37106 }
 
 
 
37107 i = sizeof(u.a)-1;
37108 u.a[i] = 0;
37109 while( x>=10 ){
37110 int kk = (x%100)*2;
37111 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
@@ -37115,10 +37437,11 @@
37115 x /= 100;
37116 }
37117 if( x ){
37118 u.a[--i] = x + '0';
37119 }
 
37120 if( v<0 ) u.a[--i] = '-';
37121 memcpy(zOut, &u.a[i], sizeof(u.a)-i);
37122 return sizeof(u.a)-1-i;
37123 }
37124
@@ -37434,41 +37757,47 @@
37434 sqlite3Fp2Convert10(v, e, (iRound<=0||iRound>=18)?18:iRound+1, &v, &exp);
37435
37436 /* Extract significant digits, start at the right-most slot in p->zBuf
37437 ** and working back to the right. "i" keeps track of the next slot in
37438 ** which to store a digit. */
37439 i = sizeof(p->zBuf)-1;
 
37440 zBuf = p->zBuf;
37441 assert( v>0 );
 
 
 
37442 while( v>=10 ){
37443 int kk = (v%100)*2;
37444 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
37445 assert( TWO_BYTE_ALIGNMENT(&zBuf[i-1]) );
37446 *(u16*)(&zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk];
 
37447 i -= 2;
37448 v /= 100;
37449 }
37450 if( v ){
37451 assert( v<10 );
37452 zBuf[i--] = v + '0';
 
37453 }
37454 assert( i>=0 && i<sizeof(p->zBuf)-1 );
37455 n = sizeof(p->zBuf) - 1 - i; /* Total number of digits extracted */
 
37456 assert( n>0 );
37457 assert( n<sizeof(p->zBuf) );
37458 testcase( n==sizeof(p->zBuf)-1 );
37459 p->iDP = n + exp;
37460 if( iRound<=0 ){
37461 iRound = p->iDP - iRound;
37462 if( iRound==0 && zBuf[i+1]>='5' ){
37463 iRound = 1;
37464 zBuf[i--] = '0';
37465 n++;
37466 p->iDP++;
37467 }
37468 }
37469 z = &zBuf[i+1]; /* z points to the first digit */
37470 if( iRound>0 && (iRound<n || n>mxRound) ){
37471 if( iRound>mxRound ) iRound = mxRound;
37472 if( iRound==17 ){
37473 /* If the precision is exactly 17, which only happens with the "!"
37474 ** flag (ex: "%!.17g") then try to reduce the precision if that
@@ -85833,11 +86162,11 @@
85833 ** rc>0 => All of the input is well-formed
85834 ** (rc&2)==0 => The number is expressed as an integer, with no
85835 ** decimal point or eNNN suffix.
85836 */
85837 SQLITE_PRIVATE int sqlite3MemRealValueRC(Mem *pMem, double *pValue){
85838 assert( pMem->db!=0 );
85839 assert( pMem->flags & (MEM_Str|MEM_Blob) );
85840 if( pMem->z==0 ){
85841 *pValue = 0.0;
85842 return 0;
85843 }else if( pMem->enc==SQLITE_UTF8
@@ -131514,11 +131843,10 @@
131514 ** forms 2 through 5, then rebuild the union of all matching indexes,
131515 ** taken care to avoid rebuilding the same index more than once.
131516 */
131517 #ifndef SQLITE_OMIT_REINDEX
131518 SQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){
131519 CollSeq *pColl; /* Collating sequence to be reindexed, or NULL */
131520 char *z = 0; /* Name of a table or index or collation */
131521 const char *zDb = 0; /* Name of the database */
131522 int iReDb = -1; /* The database index number */
131523 sqlite3 *db = pParse->db; /* The database connection */
131524 Token *pObjName; /* Name of the table or index to be reindexed */
@@ -131553,11 +131881,11 @@
131553 if( !bAll ){
131554 if( zDb==0 && sqlite3StrICmp(z, "expressions")==0 ){
131555 isExprIdx = 1;
131556 bMatch = 1;
131557 }
131558 if( zDb==0 && (pColl = sqlite3FindCollSeq(db, ENC(db), z, 0))!=0 ){
131559 zColl = z;
131560 bMatch = 1;
131561 }
131562 if( zColl==0 && (pReTab = sqlite3FindTable(db, z, zDb))!=0 ){
131563 bMatch = 1;
@@ -134449,22 +134777,15 @@
134449 ** require enhancements to the implementation. */
134450 assert( pStr!=0 && pStr->nChar==0 );
134451
134452 switch( sqlite3_value_type(pValue) ){
134453 case SQLITE_FLOAT: {
134454 double r1, r2;
134455 const char *zVal;
134456 r1 = sqlite3_value_double(pValue);
134457 sqlite3_str_appendf(pStr, "%!0.15g", r1);
134458 zVal = sqlite3_str_value(pStr);
134459 if( zVal ){
134460 sqlite3AtoF(zVal, &r2);
134461 if( r1!=r2 ){
134462 sqlite3_str_reset(pStr);
134463 sqlite3_str_appendf(pStr, "%!0.20e", r1);
134464 }
134465 }
134466 break;
134467 }
134468 case SQLITE_INTEGER: {
134469 sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
134470 break;
@@ -186195,11 +186516,11 @@
186195 if( db->mallocFailed ){
186196 pParse->rc = SQLITE_NOMEM_BKPT;
186197 }
186198 if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){
186199 if( pParse->zErrMsg==0 ){
186200 pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
186201 }
186202 if( (pParse->prepFlags & SQLITE_PREPARE_DONT_LOG)==0 ){
186203 sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
186204 }
186205 nErr++;
@@ -233377,10 +233698,23 @@
233377 aBuf[4] = (i>>24) & 0xFF;
233378 aBuf[5] = (i>>16) & 0xFF;
233379 aBuf[6] = (i>> 8) & 0xFF;
233380 aBuf[7] = (i>> 0) & 0xFF;
233381 }
 
 
 
 
 
 
 
 
 
 
 
 
 
233382
233383 /*
233384 ** This function is used to serialize the contents of value pValue (see
233385 ** comment titled "RECORD FORMAT" above).
233386 **
@@ -233415,20 +233749,17 @@
233415 case SQLITE_FLOAT:
233416 if( aBuf ){
233417 /* TODO: SQLite does something special to deal with mixed-endian
233418 ** floating point values (e.g. ARM7). This code probably should
233419 ** too. */
233420 u64 i;
233421 if( eType==SQLITE_INTEGER ){
233422 i = (u64)sqlite3_value_int64(pValue);
 
233423 }else{
233424 double r;
233425 assert( sizeof(double)==8 && sizeof(u64)==8 );
233426 r = sqlite3_value_double(pValue);
233427 memcpy(&i, &r, 8);
233428 }
233429 sessionPutI64(&aBuf[1], i);
233430 }
233431 nByte = 9;
233432 break;
233433
233434 default: {
@@ -234356,13 +234687,11 @@
234356 break;
234357 }
234358
234359 case SQLITE_FLOAT: {
234360 double rVal = sqlite3_column_double(pDflt, iField);
234361 i64 iVal = 0;
234362 memcpy(&iVal, &rVal, sizeof(rVal));
234363 sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal);
234364 pNew->nRecord += 8;
234365 break;
234366 }
234367
234368 case SQLITE_TEXT: {
@@ -235615,19 +235944,18 @@
235615 ){
235616 if( *pRc==SQLITE_OK ){
235617 int eType = sqlite3_column_type(pStmt, iCol);
235618 sessionAppendByte(p, (u8)eType, pRc);
235619 if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
235620 sqlite3_int64 i;
235621 u8 aBuf[8];
235622 if( eType==SQLITE_INTEGER ){
235623 i = sqlite3_column_int64(pStmt, iCol);
 
235624 }else{
235625 double r = sqlite3_column_double(pStmt, iCol);
235626 memcpy(&i, &r, 8);
235627 }
235628 sessionPutI64(aBuf, i);
235629 sessionAppendBlob(p, aBuf, 8, pRc);
235630 }
235631 if( eType==SQLITE_BLOB || eType==SQLITE_TEXT ){
235632 u8 *z;
235633 int nByte;
@@ -238664,10 +238992,25 @@
238664 xFilter, 0, xConflict, pCtx,
238665 0, 0, 0
238666 );
238667 }
238668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238669 /*
238670 ** sqlite3_changegroup handle.
238671 */
238672 struct sqlite3_changegroup {
238673 int rc; /* Error code */
@@ -238675,10 +239018,11 @@
238675 SessionTable *pList; /* List of tables in current patch */
238676 SessionBuffer rec;
238677
238678 sqlite3 *db; /* Configured by changegroup_schema() */
238679 char *zDb; /* Configured by changegroup_schema() */
 
238680 };
238681
238682 /*
238683 ** This function is called to merge two changes to the same row together as
238684 ** part of an sqlite3changeset_concat() operation. A new change object is
@@ -238914,19 +239258,18 @@
238914 int eType = sqlite3_column_type(pTab->pDfltStmt, ii);
238915 sessionAppendByte(pOut, eType, &rc);
238916 switch( eType ){
238917 case SQLITE_FLOAT:
238918 case SQLITE_INTEGER: {
238919 i64 iVal;
238920 if( eType==SQLITE_INTEGER ){
238921 iVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
238922 }else{
238923 double rVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
238924 memcpy(&iVal, &rVal, sizeof(i64));
238925 }
238926 if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){
238927 sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal);
 
 
 
 
 
 
238928 pOut->nBuf += 8;
238929 }
238930 break;
238931 }
238932
@@ -238993,17 +239336,23 @@
238993 int nTab = (int)strlen(zTab);
238994 u8 *abPK = 0;
238995 int nCol = 0;
238996
238997 *ppTab = 0;
238998 sqlite3changeset_pk(pIter, &abPK, &nCol);
238999
239000 /* Search the list for an existing table */
239001 for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){
239002 if( 0==sqlite3_strnicmp(pTab->zName, zTab, nTab+1) ) break;
239003 }
239004
 
 
 
 
 
 
 
239005 /* If one was not found above, create a new table now */
239006 if( !pTab ){
239007 SessionTable **ppNew;
239008
239009 pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nTab+1);
@@ -239018,12 +239367,12 @@
239018 memcpy(pTab->zName, zTab, nTab+1);
239019
239020 if( pGrp->db ){
239021 pTab->nCol = 0;
239022 rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb);
239023 if( rc ){
239024 assert( pTab->azCol==0 );
239025 sqlite3_free(pTab);
239026 return rc;
239027 }
239028 }
239029
@@ -239034,78 +239383,61 @@
239034 for(ppNew=&pGrp->pList; *ppNew; ppNew=&(*ppNew)->pNext);
239035 *ppNew = pTab;
239036 }
239037
239038 /* Check that the table is compatible. */
239039 if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){
239040 rc = SQLITE_SCHEMA;
239041 }
239042
239043 *ppTab = pTab;
239044 return rc;
239045 }
239046
239047 /*
239048 ** Add the change currently indicated by iterator pIter to the hash table
239049 ** belonging to changegroup pGrp.
239050 */
239051 static int sessionOneChangeToHash(
239052 sqlite3_changegroup *pGrp,
239053 sqlite3_changeset_iter *pIter,
239054 int bRebase
 
 
 
 
 
239055 ){
239056 int rc = SQLITE_OK;
239057 int nCol = 0;
239058 int op = 0;
239059 int iHash = 0;
239060 int bIndirect = 0;
239061 SessionChange *pChange = 0;
239062 SessionChange *pExist = 0;
239063 SessionChange **pp = 0;
239064 SessionTable *pTab = 0;
239065 u8 *aRec = &pIter->in.aData[pIter->in.iCurrent + 2];
239066 int nRec = (pIter->in.iNext - pIter->in.iCurrent) - 2;
239067
239068 assert( nRec>0 );
239069
239070 /* Ensure that only changesets, or only patchsets, but not a mixture
239071 ** of both, are being combined. It is an error to try to combine a
239072 ** changeset and a patchset. */
239073 if( pGrp->pList==0 ){
239074 pGrp->bPatch = pIter->bPatchset;
239075 }else if( pIter->bPatchset!=pGrp->bPatch ){
239076 rc = SQLITE_ERROR;
239077 }
239078
239079 if( rc==SQLITE_OK ){
239080 const char *zTab = 0;
239081 sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
239082 rc = sessionChangesetFindTable(pGrp, zTab, pIter, &pTab);
239083 }
239084
239085 if( rc==SQLITE_OK && nCol<pTab->nCol ){
239086 SessionBuffer *pBuf = &pGrp->rec;
239087 rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, pBuf);
239088 aRec = pBuf->aBuf;
239089 nRec = pBuf->nBuf;
239090 assert( pGrp->db );
239091 }
239092
239093 if( rc==SQLITE_OK && sessionGrowHash(0, pIter->bPatchset, pTab) ){
239094 rc = SQLITE_NOMEM;
239095 }
239096
239097 if( rc==SQLITE_OK ){
239098 /* Search for existing entry. If found, remove it from the hash table.
239099 ** Code below may link it back in. */
239100 iHash = sessionChangeHash(
239101 pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange
239102 );
239103 for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){
239104 int bPkOnly1 = 0;
239105 int bPkOnly2 = 0;
239106 if( pIter->bPatchset ){
239107 bPkOnly1 = (*pp)->op==SQLITE_DELETE;
239108 bPkOnly2 = op==SQLITE_DELETE;
239109 }
239110 if( sessionChangeEqual(pTab, bPkOnly1, (*pp)->aRecord, bPkOnly2, aRec) ){
239111 pExist = *pp;
@@ -239116,18 +239448,59 @@
239116 }
239117 }
239118
239119 if( rc==SQLITE_OK ){
239120 rc = sessionChangeMerge(pTab, bRebase,
239121 pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange
239122 );
239123 }
239124 if( rc==SQLITE_OK && pChange ){
239125 pChange->pNext = pTab->apChange[iHash];
239126 pTab->apChange[iHash] = pChange;
239127 pTab->nEntry++;
239128 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239129
239130 if( rc==SQLITE_OK ) rc = pIter->rc;
239131 return rc;
239132 }
239133
@@ -239144,11 +239517,11 @@
239144 int nRec;
239145 int rc = SQLITE_OK;
239146
239147 pIter->in.bNoDiscard = 1;
239148 while( SQLITE_ROW==(sessionChangesetNext(pIter, &aRec, &nRec, 0)) ){
239149 rc = sessionOneChangeToHash(pGrp, pIter, bRebase);
239150 if( rc!=SQLITE_OK ) break;
239151 }
239152
239153 if( rc==SQLITE_OK ) rc = pIter->rc;
239154 return rc;
@@ -239233,10 +239606,37 @@
239233 memset(p, 0, sizeof(sqlite3_changegroup));
239234 }
239235 *pp = p;
239236 return rc;
239237 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239238
239239 /*
239240 ** Provide a database schema to the changegroup object.
239241 */
239242 SQLITE_API int sqlite3changegroup_schema(
@@ -239292,11 +239692,11 @@
239292 ){
239293 /* Iterator does not point to any valid entry or is an INVERT iterator. */
239294 rc = SQLITE_ERROR;
239295 }else{
239296 pIter->in.bNoDiscard = 1;
239297 rc = sessionOneChangeToHash(pGrp, pIter, 0);
239298 }
239299 return rc;
239300 }
239301
239302 /*
@@ -239344,10 +239744,16 @@
239344 /*
239345 ** Delete a changegroup object.
239346 */
239347 SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){
239348 if( pGrp ){
 
 
 
 
 
 
239349 sqlite3_free(pGrp->zDb);
239350 sessionDeleteTable(0, pGrp->pList);
239351 sqlite3_free(pGrp->rec.aBuf);
239352 sqlite3_free(pGrp);
239353 }
@@ -239771,10 +240177,332 @@
239771 }
239772 default:
239773 rc = SQLITE_MISUSE;
239774 break;
239775 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239776 return rc;
239777 }
239778
239779 #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */
239780
@@ -262478,11 +263206,11 @@
262478 int nArg, /* Number of args */
262479 sqlite3_value **apUnused /* Function arguments */
262480 ){
262481 assert( nArg==0 );
262482 UNUSED_PARAM2(nArg, apUnused);
262483 sqlite3_result_text(pCtx, "fts5: 2026-03-26 14:19:34 97ee48b6ef65fb55633196282c9e75b3b0a3b81ba9755f63493a38e3f1a5610c", -1, SQLITE_TRANSIENT);
262484 }
262485
262486 /*
262487 ** Implementation of fts5_locale(LOCALE, TEXT) function.
262488 **
262489
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 7bc1d0c4572f126cfe68fa51fe992d2bd46b with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.53.0"
471 #define SQLITE_VERSION_NUMBER 3053000
472 #define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -897,11 +897,11 @@
897 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
898 #define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
899 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
900 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
901 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
902 #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal only */
903
904 /*
905 ** CAPI3REF: Flags For File Open Operations
906 **
907 ** These bit values are intended for use in the
@@ -1609,10 +1609,16 @@
1609 /* deprecated names */
1610 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1611 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1612 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
1613
1614 /* reserved file-control numbers:
1615 ** 101
1616 ** 102
1617 ** 103
1618 */
1619
1620
1621 /*
1622 ** CAPI3REF: Mutex Handle
1623 **
1624 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
@@ -2030,11 +2036,12 @@
2036 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
2037 ** The exceptional configuration options that may be invoked at any time
2038 ** are called "anytime configuration options".
2039 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
2040 ** [sqlite3_shutdown()] with a first argument that is not an anytime
2041 ** configuration option, then the sqlite3_config() call will
2042 ** return SQLITE_MISUSE.
2043 ** Note, however, that ^sqlite3_config() can be called as part of the
2044 ** implementation of an application-defined [sqlite3_os_init()].
2045 **
2046 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
2047 ** ^If the option is unknown or SQLite is unable to set the option
@@ -2596,13 +2603,14 @@
2603 ** <li><P>The second argument ("sz") is the
2604 ** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2605 ** is less than 8. The "sz" argument should be a multiple of 8 less than
2606 ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2607 ** it does.
2608 ** <li><p>The third argument ("cnt") is the number of slots.
2609 ** Lookaside is disabled if "cnt"is less than 1.
2610 * The "cnt" value will be reduced, if necessary, so
2611 ** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2612 ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2613 ** than 1,000,000.
2614 ** </ol>
2615 ** <p>If the "buf" argument is not NULL, then it must
2616 ** point to a memory buffer with a size that is greater than
@@ -2977,11 +2985,11 @@
2985 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2986 ** prior versions.<p>
2987 ** This option takes two arguments which are an integer and a pointer
2988 ** to an integer. The first argument is a small integer, between 3 and 23, or
2989 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2990 ** unaltered if the first argument is zero or out of range. The second argument
2991 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2992 ** the FP_DIGITS setting, after possibly being modified by the first
2993 ** arguments, is written into the integer to which the second argument points.
2994 ** </dd>
2995 **
@@ -2989,14 +2997,16 @@
2997 **
2998 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2999 **
3000 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
3001 ** overall call to [sqlite3_db_config()] has a total of four parameters.
3002 ** The first argument (the third parameter to sqlite3_db_config()) is
3003 ** an integer.
3004 ** The second argument is a pointer to an integer. If the first argument is 1,
3005 ** then the option becomes enabled. If the first integer argument is 0,
3006 ** then the option is disabled.
3007 ** If the first argument is -1, then the option setting
3008 ** is unchanged. The second argument, the pointer to an integer, may be NULL.
3009 ** If the second argument is not NULL, then a value of 0 or 1 is written into
3010 ** the integer to which the second argument points, depending on whether the
3011 ** setting is disabled or enabled after applying any changes specified by
3012 ** the first argument.
@@ -6169,12 +6179,13 @@
6179 ** that the application-defined collating sequence created expects its
6180 ** input strings to be in UTF16 in native byte order, and that the start
6181 ** of the strings must be aligned to a 2-byte boundary.
6182 **
6183 ** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
6184 ** used to specify the text encoding to strings input to
6185 ** [sqlite3_result_text64()] and [sqlite3_bind_text64()].
6186 ** The SQLITE_UTF8_ZT encoding means that the input string (call it "z")
6187 ** is UTF-8 encoded and that it is zero-terminated. If the length parameter
6188 ** (call it "n") is non-negative, this encoding option means that the caller
6189 ** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
6190 ** byte has a value of zero.
6191 ** This option gives the same output as SQLITE_UTF8, but can be more efficient
@@ -6422,30 +6433,26 @@
6433 **
6434 ** These routines must be called from the same thread as
6435 ** the SQL function that supplied the [sqlite3_value*] parameters.
6436 **
6437 ** As long as the input parameter is correct, these routines can only
6438 ** fail if an out-of-memory error occurs while trying to do a
6439 ** UTF8&rarr;UTF16 or UTF16&rarr;UTF8 conversion.
 
 
 
 
 
 
 
 
 
 
 
 
6440 ** If an out-of-memory error occurs, then the return value from these
6441 ** routines is the same as if the column had contained an SQL NULL value.
6442 ** If the input sqlite3_value was not obtained from [sqlite3_value_dup()],
6443 ** then valid SQL NULL returns can also be distinguished from
6444 ** out-of-memory errors after extracting the value
6445 ** by invoking the [sqlite3_errcode()] immediately after the suspicious
6446 ** return value is obtained and before any
6447 ** other SQLite interface is called on the same [database connection].
6448 ** If the input sqlite3_value was obtained from sqlite3_value_dup() then
6449 ** it is disconnected from the database connection and so sqlite3_errcode()
6450 ** will not work.
6451 ** In that case, the only way to distinguish an out-of-memory
6452 ** condition from a true SQL NULL is to invoke sqlite3_value_type() on the
6453 ** input to see if it is NULL prior to trying to extract the value.
6454 */
6455 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
6456 SQLITE_API double sqlite3_value_double(sqlite3_value*);
6457 SQLITE_API int sqlite3_value_int(sqlite3_value*);
6458 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -6468,11 +6475,12 @@
6475 ** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
6476 ** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding
6477 ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
6478 ** returns something other than SQLITE_TEXT, then the return value from
6479 ** sqlite3_value_encoding(X) is meaningless. ^Calls to
6480 ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)],
6481 ** [sqlite3_value_text16be(X)],
6482 ** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
6483 ** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
6484 ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
6485 **
6486 ** This routine is intended for used by applications that test and validate
@@ -6599,21 +6607,21 @@
6607 ** associate auxiliary data with argument values. If the same argument
6608 ** value is passed to multiple invocations of the same SQL function during
6609 ** query execution, under some circumstances the associated auxiliary data
6610 ** might be preserved. An example of where this might be useful is in a
6611 ** regular-expression matching function. The compiled version of the regular
6612 ** expression can be stored as auxiliary data associated with the pattern
6613 ** string. Then as long as the pattern string remains the same,
6614 ** the compiled regular expression can be reused on multiple
6615 ** invocations of the same function.
6616 **
6617 ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary
6618 ** data associated by the sqlite3_set_auxdata(C,N,P,X) function with the
6619 ** Nth argument value to the application-defined function. ^N is zero
6620 ** for the left-most function argument. ^If there is no auxiliary data
6621 ** associated with the function argument, the sqlite3_get_auxdata(C,N)
6622 ** interface returns a NULL pointer.
6623 **
6624 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6625 ** N-th argument of the application-defined function. ^Subsequent
6626 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
6627 ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
@@ -10722,21 +10730,22 @@
10730 **
10731 ** <table border=1 cellspacing=0 cellpadding=10 width="90%">
10732 ** <tr>
10733 ** <td valign="top">sqlite3_vtab_distinct() return value
10734 ** <td valign="top">Rows are returned in aOrderBy order
10735 ** <td valign="top">Rows with the same value in all aOrderBy columns are
10736 ** adjacent
10737 ** <td valign="top">Duplicates over all colUsed columns may be omitted
10738 ** <tr><td>0<td>yes<td>yes<td>no
10739 ** <tr><td>1<td>no<td>yes<td>no
10740 ** <tr><td>2<td>no<td>yes<td>yes
10741 ** <tr><td>3<td>yes<td>yes<td>yes
10742 ** </table>
10743 **
10744 ** ^For the purposes of comparing virtual table output values to see if the
10745 ** values are the same value for sorting purposes, two NULL values are
10746 ** considered to be the same. In other words, the comparison operator is "IS"
10747 ** (or "IS NOT DISTINCT FROM") and not "==".
10748 **
10749 ** If a virtual table implementation is unable to meet the requirements
10750 ** specified above, then it must not set the "orderByConsumed" flag in the
10751 ** [sqlite3_index_info] object or an incorrect answer may result.
@@ -11586,16 +11595,17 @@
11595 /*
11596 ** CAPI3REF: Bind array values to the CARRAY table-valued function
11597 **
11598 ** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
11599 ** parameter that is the first argument of the [carray() table-valued function].
11600 ** The S parameter is a pointer to the [prepared statement] that uses the
11601 ** carray() functions. I is the parameter index to be bound. I must be the
11602 ** index of the parameter that is the first argument to the carray()
11603 ** table-valued function. P is a pointer to the array to be bound, and N
11604 ** is the number of elements in the array. The F argument is one of
11605 ** constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64],
11606 ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
11607 ** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
11608 **
11609 ** If the X argument is not a NULL pointer or one of the special
11610 ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11611 ** the function X with argument D when it is finished using the data in P.
@@ -13648,10 +13658,236 @@
13658
13659 /*
13660 ** CAPI3REF: Values for sqlite3session_config().
13661 */
13662 #define SQLITE_SESSION_CONFIG_STRMSIZE 1
13663
13664 /*
13665 ** CAPI3REF: Configure a changegroup object
13666 **
13667 ** Configure the changegroup object passed as the first argument.
13668 ** At present the only valid value for the second parameter is
13669 ** [SQLITE_CHANGEGROUP_CONFIG_PATCHSET].
13670 */
13671 SQLITE_API int sqlite3changegroup_config(sqlite3_changegroup*, int, void *pArg);
13672
13673 /*
13674 ** CAPI3REF: Options for sqlite3changegroup_config().
13675 **
13676 ** The following values may be passed as the 2nd parameter to
13677 ** sqlite3changegroup_config().
13678 **
13679 ** <dt>SQLITE_CHANGEGROUP_CONFIG_PATCHSET <dd>
13680 ** A changegroup object generates either a changeset or patchset. Usually,
13681 ** this is determined by whether the first call to sqlite3changegroup_add()
13682 ** is passed a changeset or a patchset. Or, if the first changes are added
13683 ** to the changegroup object using the sqlite3changegroup_change_xxx()
13684 ** APIs, then this option may be used to configure whether the changegroup
13685 ** object generates a changeset or patchset.
13686 **
13687 ** When this option is invoked, parameter pArg must point to a value of
13688 ** type int. If the changegroup currently contains zero changes, and the
13689 ** value of the int variable is zero or greater than zero, then the
13690 ** changegroup is configured to generate a changeset or patchset,
13691 ** respectively. It is a no-op, not an error, if the changegroup is not
13692 ** configured because it has already started accumulating changes.
13693 **
13694 ** Before returning, the int variable is set to 0 if the changegroup is
13695 ** configured to generate a changeset, or 1 if it is configured to generate
13696 ** a patchset.
13697 */
13698 #define SQLITE_CHANGEGROUP_CONFIG_PATCHSET 1
13699
13700
13701 /*
13702 ** CAPI3REF: Begin adding a change to a changegroup
13703 **
13704 ** This API is used, in concert with other sqlite3changegroup_change_xxx()
13705 ** APIs, to add changes to a changegroup object one at a time. To add a
13706 ** single change, the caller must:
13707 **
13708 ** 1. Invoke sqlite3changegroup_change_begin() to indicate the type of
13709 ** change (INSERT, UPDATE or DELETE), the affected table and whether
13710 ** or not the change should be marked as indirect.
13711 **
13712 ** 2. Invoke sqlite3changegroup_change_int64() or one of the other four
13713 ** value functions - _null(), _double(), _text() or _blob() - one or
13714 ** more times to specify old.* and new.* values for the change being
13715 ** constructed.
13716 **
13717 ** 3. Invoke sqlite3changegroup_change_finish() to either finish adding
13718 ** the change to the group, or to discard the change altogether.
13719 **
13720 ** The first argument to this function must be a pointer to the existing
13721 ** changegroup object that the change will be added to. The second argument
13722 ** must be SQLITE_INSERT, SQLITE_UPDATE or SQLITE_DELETE. The third is the
13723 ** name of the table that the change affects, and the fourth is a boolean
13724 ** flag specifying whether the change should be marked as "indirect" (if
13725 ** bIndirect is non-zero) or not indirect (if bIndirect is zero).
13726 **
13727 ** Following a successful call to this function, this function may not be
13728 ** called again on the same changegroup object until after
13729 ** sqlite3changegroup_change_finish() has been called. Doing so is an
13730 ** SQLITE_MISUSE error.
13731 **
13732 ** The changegroup object passed as the first argument must be already
13733 ** configured with schema data for the specified table. It may be configured
13734 ** either by calling sqlite3changegroup_schema() with a database that contains
13735 ** the table, or sqlite3changegroup_add() with a changeset that contains the
13736 ** table. If the changegroup object has not been configured with a schema for
13737 ** the specified table when this function is called, SQLITE_ERROR is returned.
13738 **
13739 ** If successful, SQLITE_OK is returned. Otherwise, if an error occurs, an
13740 ** SQLite error code is returned. In this case, if argument pzErr is non-NULL,
13741 ** then (*pzErr) may be set to point to a buffer containing a utf-8 formated,
13742 ** nul-terminated, English language error message. It is the responsibility
13743 ** of the caller to eventually free this buffer using sqlite3_free().
13744 */
13745 SQLITE_API int sqlite3changegroup_change_begin(
13746 sqlite3_changegroup*,
13747 int eOp,
13748 const char *zTab,
13749 int bIndirect,
13750 char **pzErr
13751 );
13752
13753 /*
13754 ** CAPI3REF: Add a 64-bit integer to a changegroup
13755 **
13756 ** This function may only be called between a successful call to
13757 ** sqlite3changegroup_change_begin() and its matching
13758 ** sqlite3changegroup_change_finish() call. If it is called at any
13759 ** other time, it is an SQLITE_MISUSE error. Calling this function
13760 ** specifies a 64-bit integer value to be used in the change currently being
13761 ** added to the changegroup object passed as the first argument.
13762 **
13763 ** The second parameter, bNew, specifies whether the value is to be part of
13764 ** the new.* (if bNew is non-zero) or old.* (if bNew is zero) record of
13765 ** the change under construction. If this does not match the type of change
13766 ** specified by the preceding call to sqlite3changegroup_change_begin() (i.e.
13767 ** an old.* value for an SQLITE_INSERT change, or a new.* value for an
13768 ** SQLITE_DELETE), then SQLITE_ERROR is returned.
13769 **
13770 ** The third parameter specifies the column of the old.* or new.* record that
13771 ** the value will be a part of. If the specified table has an explicit primary
13772 ** key, then this is the index of the table column, numbered from 0 in the order
13773 ** specified within the CREATE TABLE statement. Or, if the table uses an
13774 ** implicit rowid key, then the column 0 is the rowid and the explicit columns
13775 ** are numbered starting from 1. If the iCol parameter is less than 0 or greater
13776 ** than the index of the last column in the table, SQLITE_RANGE is returned.
13777 **
13778 ** The fourth parameter is the integer value to use as part of the old.* or
13779 ** new.* record.
13780 **
13781 ** If this call is successful, SQLITE_OK is returned. Otherwise, if an
13782 ** error occurs, an SQLite error code is returned.
13783 */
13784 SQLITE_API int sqlite3changegroup_change_int64(
13785 sqlite3_changegroup*,
13786 int bNew,
13787 int iCol,
13788 sqlite3_int64 iVal
13789 );
13790
13791 /*
13792 ** CAPI3REF: Add a NULL to a changegroup
13793 **
13794 ** This function is similar to sqlite3changegroup_change_int64(). Except that
13795 ** it configures the change currently under construction with a NULL value
13796 ** instead of a 64-bit integer.
13797 */
13798 SQLITE_API int sqlite3changegroup_change_null(sqlite3_changegroup*, int, int);
13799
13800 /*
13801 ** CAPI3REF: Add an double to a changegroup
13802 **
13803 ** This function is similar to sqlite3changegroup_change_int64(). Except that
13804 ** it configures the change currently being constructed with a real value
13805 ** instead of a 64-bit integer.
13806 */
13807 SQLITE_API int sqlite3changegroup_change_double(sqlite3_changegroup*, int, int, double);
13808
13809 /*
13810 ** CAPI3REF: Add a text value to a changegroup
13811 **
13812 ** This function is similar to sqlite3changegroup_change_int64(). It configures
13813 ** the currently accumulated change with a text value instead of a 64-bit
13814 ** integer. Parameter pVal points to a buffer containing the text encoded using
13815 ** utf-8. Parameter nVal may either be the size of the text value in bytes, or
13816 ** else a negative value, in which case the buffer pVal points to is assumed to
13817 ** be nul-terminated.
13818 */
13819 SQLITE_API int sqlite3changegroup_change_text(
13820 sqlite3_changegroup*, int, int, const char *pVal, int nVal
13821 );
13822
13823 /*
13824 ** CAPI3REF: Add a blob to a changegroup
13825 **
13826 ** This function is similar to sqlite3changegroup_change_int64(). It configures
13827 ** the currently accumulated change with a blob value instead of a 64-bit
13828 ** integer. Parameter pVal points to a buffer containing the blob. Parameter
13829 ** nVal is the size of the blob in bytes.
13830 */
13831 SQLITE_API int sqlite3changegroup_change_blob(
13832 sqlite3_changegroup*, int, int, const void *pVal, int nVal
13833 );
13834
13835 /*
13836 ** CAPI3REF: Finish adding one-at-at-time changes to a changegroup
13837 **
13838 ** This function may only be called following a successful call to
13839 ** sqlite3changegroup_change_begin(). Otherwise, it is an SQLITE_MISUSE error.
13840 **
13841 ** If parameter bDiscard is non-zero, then the current change is simply
13842 ** discarded. In this case this function is always successful and SQLITE_OK
13843 ** returned.
13844 **
13845 ** If parameter bDiscard is zero, then an attempt is made to add the current
13846 ** change to the changegroup. Assuming the changegroup is configured to
13847 ** produce a changeset (not a patchset), this requires that:
13848 **
13849 ** * If the change is an INSERT or DELETE, then a value must be specified
13850 ** for all columns of the new.* or old.* record, respectively.
13851 **
13852 ** * If the change is an UPDATE record, then values must be provided for
13853 ** the PRIMARY KEY columns of the old.* record, but must not be provided
13854 ** for PRIMARY KEY columns of the new.* record.
13855 **
13856 ** * If the change is an UPDATE record, then for each non-PRIMARY KEY
13857 ** column in the old.* record for which a value has been provided, a
13858 ** value must also be provided for the same column in the new.* record.
13859 ** Similarly, for each non-PK column in the old.* record for which
13860 ** a value is not provided, a value must not be provided for the same
13861 ** column in the new.* record.
13862 **
13863 ** * All values specified for PRIMARY KEY columns must be non-NULL.
13864 **
13865 ** Otherwise, it is an error.
13866 **
13867 ** If the changegroup already contains a change for the same row (identified
13868 ** by PRIMARY KEY columns), then the current change is combined with the
13869 ** existing change in the same way as for sqlite3changegroup_add().
13870 **
13871 ** For a patchset, all of the above rules apply except that it doesn't matter
13872 ** whether or not values are provided for the non-PK old.* record columns
13873 ** for an UPDATE or DELETE change. This means that code used to produce
13874 ** a changeset using the sqlite3changegroup_change_xxx() APIs may also
13875 ** be used to produce patchsets.
13876 **
13877 ** If the call is successful, SQLITE_OK is returned. Otherwise, if an error
13878 ** occurs, an SQLite error code is returned. If an error is returned and
13879 ** parameter pzErr is not NULL, then (*pzErr) may be set to point to a buffer
13880 ** containing a nul-terminated, utf-8 encoded, English language error message.
13881 ** It is the responsibility of the caller to eventually free any such error
13882 ** message buffer using sqlite3_free().
13883 */
13884 SQLITE_API int sqlite3changegroup_change_finish(
13885 sqlite3_changegroup*,
13886 int bDiscard,
13887 char **pzErr
13888 );
13889
13890 /*
13891 ** Make sure we can call this stuff from C++.
13892 */
13893 #if 0
@@ -21585,21 +21821,26 @@
21821 int nArg; /* Total number of arguments */
21822 int nUsed; /* Number of arguments used so far */
21823 sqlite3_value **apArg; /* The argument values */
21824 };
21825
21826 /*
21827 ** Maxium number of base-10 digits in an unsigned 64-bit integer
21828 */
21829 #define SQLITE_U64_DIGITS 20
21830
21831 /*
21832 ** An instance of this object receives the decoding of a floating point
21833 ** value into an approximate decimal representation.
21834 */
21835 struct FpDecode {
21836 int n; /* Significant digits in the decode */
21837 int iDP; /* Location of the decimal point */
21838 char *z; /* Start of significant digits */
21839 char zBuf[SQLITE_U64_DIGITS+1]; /* Storage for significant digits */
21840 char sign; /* '+' or '-' */
21841 char isSpecial; /* 1: Infinity 2: NaN */
21842 };
21843
21844 SQLITE_PRIVATE void sqlite3FpDecode(FpDecode*,double,int,int);
21845 SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
21846 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
@@ -22283,10 +22524,11 @@
22524 SQLITE_PRIVATE char *sqlite3RCStrNew(u64);
22525 SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64);
22526
22527 SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
22528 SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, i64);
22529 SQLITE_PRIVATE int sqlite3StrAccumEnlargeIfNeeded(StrAccum*, i64);
22530 SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
22531 SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum*, u8);
22532 SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
22533 SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
22534 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
@@ -32635,10 +32877,11 @@
32877 case etEXP:
32878 case etGENERIC: {
32879 FpDecode s;
32880 int iRound;
32881 int j;
32882 i64 szBufNeeded; /* Size needed to hold the output */
32883
32884 if( bArgList ){
32885 realvalue = getDoubleArg(pArgList);
32886 }else{
32887 realvalue = va_arg(ap,double);
@@ -32723,21 +32966,19 @@
32966 if( xtype==etEXP ){
32967 e2 = 0;
32968 }else{
32969 e2 = s.iDP - 1;
32970 }
32971
32972 szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+8;
32973 if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32974 if( sqlite3StrAccumEnlargeIfNeeded(pAccum, szBufNeeded) ){
32975 width = length = 0;
32976 break;
32977 }
32978 bufpt = zOut = pAccum->zText + pAccum->nChar;
32979
 
 
32980 flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
32981 /* The sign in front of the number */
32982 if( prefix ){
32983 *(bufpt++) = prefix;
32984 }
@@ -32781,17 +33022,15 @@
33022 int nn = s.n - j;
33023 if( NEVER(nn>precision) ) nn = precision;
33024 if( nn>0 ){
33025 memcpy(bufpt, s.z+j, nn);
33026 bufpt += nn;
 
33027 precision -= nn;
33028 }
33029 if( precision>0 && !flag_rtz ){
33030 memset(bufpt, '0', precision);
33031 bufpt += precision;
 
33032 }
33033 }
33034 /* Remove trailing zeros and the "." if no digits follow the "." */
33035 if( flag_rtz && flag_dp ){
33036 while( bufpt[-1]=='0' ) *(--bufpt) = 0;
@@ -32818,31 +33057,35 @@
33057 exp %= 100;
33058 }
33059 *(bufpt++) = (char)(exp/10+'0'); /* 10's digit */
33060 *(bufpt++) = (char)(exp%10+'0'); /* 1's digit */
33061 }
 
33062
 
 
 
33063 length = (int)(bufpt-zOut);
33064 assert( length <= szBufNeeded );
33065 if( length<width ){
33066 i64 nPad = width - length;
33067 if( flag_leftjustify ){
33068 memset(bufpt, ' ', nPad);
33069 }else if( !flag_zeropad ){
33070 memmove(zOut+nPad, zOut, length);
33071 memset(zOut, ' ', nPad);
33072 }else{
33073 int adj = prefix!=0;
33074 memmove(zOut+nPad+adj, zOut+adj, length-adj);
33075 memset(zOut+adj, '0', nPad);
33076 }
33077 length = width;
33078 }
33079 pAccum->nChar += length;
33080 zOut[length] = 0;
33081
33082 /* Floating point conversions render directly into the output
33083 ** buffer. Hence, don't just break out of the switch(). Bypass the
33084 ** output buffer writing that occurs after the switch() by continuing
33085 ** to the next character in the format string. */
33086 continue;
33087 }
33088 case etSIZE:
33089 if( !bArgList ){
33090 *(va_arg(ap,int*)) = pAccum->nChar;
33091 }
@@ -32882,15 +33125,14 @@
33125 precision--;
33126 while( precision > 1 ){
33127 i64 nCopyBytes;
33128 if( nPrior > precision-1 ) nPrior = precision - 1;
33129 nCopyBytes = length*nPrior;
33130 if( sqlite3StrAccumEnlargeIfNeeded(pAccum, nCopyBytes) ){
33131 break;
33132 }
33133 sqlite3_str_append(pAccum,
 
33134 &pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
33135 precision -= nPrior;
33136 nPrior *= 2;
33137 }
33138 }
@@ -33231,10 +33473,17 @@
33473 }
33474 }
33475 assert( N>=0 && N<=0x7fffffff );
33476 return (int)N;
33477 }
33478
33479 SQLITE_PRIVATE int sqlite3StrAccumEnlargeIfNeeded(StrAccum *p, i64 N){
33480 if( N + p->nChar >= p->nAlloc ){
33481 sqlite3StrAccumEnlarge(p, N);
33482 }
33483 return p->accError;
33484 }
33485
33486 /*
33487 ** Append N copies of character c to the given string buffer.
33488 */
33489 SQLITE_API void sqlite3_str_appendchar(sqlite3_str *p, int N, char c){
@@ -36548,15 +36797,16 @@
36797 ** lower 64-bits of the result into *pLo, and return the high-order
36798 ** 64 bits.
36799 */
36800 static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
36801 #if (defined(__GNUC__) || defined(__clang__)) \
36802 && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36803 && !defined(SQLITE_DISABLE_INTRINSIC)
36804 __uint128_t r = (__uint128_t)a * b;
36805 *pLo = (u64)r;
36806 return (u64)(r>>64);
36807 #elif defined(_WIN64) && !defined(SQLITE_DISABLE_INTRINSIC)
36808 *pLo = a*b;
36809 return __umulh(a, b);
36810 #else
36811 u64 a0 = (u32)a;
36812 u64 a1 = a >> 32;
@@ -36583,21 +36833,23 @@
36833 **
36834 ** The lower 64 bits of A*B are discarded.
36835 */
36836 static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36837 #if (defined(__GNUC__) || defined(__clang__)) \
36838 && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36839 && !defined(SQLITE_DISABLE_INTRINSIC)
36840 __uint128_t r = (__uint128_t)a * b;
36841 r += ((__uint128_t)aLo * b) >> 32;
36842 *pLo = (r>>32)&0xffffffff;
36843 return r>>64;
36844 #elif defined(_WIN64) && !defined(SQLITE_DISABLE_INTRINSIC)
36845 u64 r1_hi = __umulh(a,b);
36846 u64 r1_lo = a*b;
36847 u64 r2 = (__umulh((u64)aLo,b)<<32) + ((aLo*b)>>32);
36848 u64 t = r1_lo + r2;
36849 if( t<r1_lo ) r1_hi++;
36850 *pLo = t>>32;
36851 return r1_hi;
36852 #else
36853 u64 x2 = a>>32;
36854 u64 x1 = a&0xffffffff;
36855 u64 x0 = aLo;
@@ -36805,11 +37057,12 @@
37057
37058 /*
37059 ** Count leading zeros for a 64-bit unsigned integer.
37060 */
37061 static int countLeadingZeros(u64 m){
37062 #if (defined(__GNUC__) || defined(__clang__)) \
37063 && !defined(SQLITE_DISABLE_INTRINSIC)
37064 return __builtin_clzll(m);
37065 #else
37066 int n = 0;
37067 if( m <= 0x00000000ffffffffULL) { n += 32; m <<= 32; }
37068 if( m <= 0x0000ffffffffffffULL) { n += 16; m <<= 16; }
@@ -36906,16 +37159,19 @@
37159 ** Return positive if the result is a valid real number (or integer) and
37160 ** zero or negative if the string is empty or contains extraneous text.
37161 ** Lower bits of the return value contain addition information about the
37162 ** parse:
37163 **
37164 ** bit 0 => Set if any prefix of the input is valid. Clear if
37165 ** there is no prefix of the input that can be seen as
37166 ** a valid floating point number.
37167 ** bit 1 => Set if the input contains a decimal point or eNNN
37168 ** clause. Zero if the input is an integer.
37169 ** bit 2 => The input is exactly 0.0, not an underflow from
37170 ** some value near zero.
37171 ** bit 3 => Set if there are more than about 19 significant
37172 ** digits in the input.
37173 **
37174 ** If the input contains a syntax error but begins with text that might
37175 ** be a valid number of some kind, then the result is negative. The
37176 ** result is only zero if no prefix of the input could be interpreted as
37177 ** a number.
@@ -37077,10 +37333,73 @@
37333 "70717273747576777879"
37334 "80818283848586878889"
37335 "90919293949596979899"
37336 };
37337
37338 /*
37339 ** ARMv6, ARMv7, PPC32 are known to not support hardware u64 division.
37340 */
37341 #if (defined(__arm__) && !defined(__aarch64__)) || \
37342 (defined(__ppc__) && !defined(__ppc64__))
37343 # define SQLITE_AVOID_U64_DIVIDE 1
37344 #endif
37345
37346 #ifdef SQLITE_AVOID_U64_DIVIDE
37347 /*
37348 ** Render an unsigned 64-bit integer as text onto the end of a 2-byte
37349 ** aligned buffer that is SQLITE_U64_DIGIT+1 bytes long. The last byte
37350 ** of the buffer will be filled with a \000 byte.
37351 **
37352 ** Return the index into the buffer of the first byte.
37353 **
37354 ** This routine is used on platforms where u64-division is slow because
37355 ** it is not available in hardware and has to be emulated in software.
37356 ** It seeks to minimize the number of u64 divisions and use u32 divisions
37357 ** instead. It is slower on platforms that have hardware u64 division,
37358 ** but much faster on platforms that do not.
37359 */
37360 static int sqlite3UInt64ToText(u64 v, char *zOut){
37361 u32 x32, kk;
37362 int i;
37363 zOut[SQLITE_U64_DIGITS] = 0;
37364 i = SQLITE_U64_DIGITS;
37365 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[0]) );
37366 assert( TWO_BYTE_ALIGNMENT(zOut) );
37367 while( (v>>32)!=0 ){
37368 u32 y, x0, x1, y0, y1;
37369 x32 = v % 100000000;
37370 v = v / 100000000;
37371 y = x32 % 10000;
37372 x32 /= 10000;
37373 x1 = x32 / 100;
37374 x0 = x32 % 100;
37375 y1 = y / 100;
37376 y0 = y % 100;
37377 assert( i>=8 );
37378 i -= 8;
37379 *(u16*)(&zOut[i]) = *(u16*)&sqlite3DigitPairs.a[x1*2];
37380 *(u16*)(&zOut[i+2]) = *(u16*)&sqlite3DigitPairs.a[x0*2];
37381 *(u16*)(&zOut[i+4]) = *(u16*)&sqlite3DigitPairs.a[y1*2];
37382 *(u16*)(&zOut[i+6]) = *(u16*)&sqlite3DigitPairs.a[y0*2];
37383 }
37384 x32 = v;
37385 while( x32>=10 ){
37386 kk = x32 % 100;
37387 x32 = x32 / 100;
37388 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk*2]) );
37389 assert( i>=2 );
37390 i -= 2;
37391 assert( TWO_BYTE_ALIGNMENT(&zOut[i]) );
37392 *(u16*)(&zOut[i]) = *(u16*)&sqlite3DigitPairs.a[kk*2];
37393 }
37394 if( x32 ){
37395 assert( i>0 );
37396 zOut[--i] = x32 + '0';
37397 }
37398 return i;
37399 }
37400 #endif /* defined(SQLITE_AVOID_U64_DIVIDE) */
37401
37402 /*
37403 ** Render an signed 64-bit integer as text. Store the result in zOut[] and
37404 ** return the length of the string that was stored, in bytes. The value
37405 ** returned does not include the zero terminator at the end of the output
@@ -37090,11 +37409,11 @@
37409 */
37410 SQLITE_PRIVATE int sqlite3Int64ToText(i64 v, char *zOut){
37411 int i;
37412 u64 x;
37413 union {
37414 char a[SQLITE_U64_DIGITS+1];
37415 u16 forceAlignment;
37416 } u;
37417 if( v>0 ){
37418 x = v;
37419 }else if( v==0 ){
@@ -37102,10 +37421,13 @@
37421 zOut[1] = 0;
37422 return 1;
37423 }else{
37424 x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : (u64)-v;
37425 }
37426 #ifdef SQLITE_AVOID_U64_DIVIDE
37427 i = sqlite3UInt64ToText(x, u.a);
37428 #else
37429 i = sizeof(u.a)-1;
37430 u.a[i] = 0;
37431 while( x>=10 ){
37432 int kk = (x%100)*2;
37433 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
@@ -37115,10 +37437,11 @@
37437 x /= 100;
37438 }
37439 if( x ){
37440 u.a[--i] = x + '0';
37441 }
37442 #endif /* SQLITE_AVOID_U64_DIVIDE */
37443 if( v<0 ) u.a[--i] = '-';
37444 memcpy(zOut, &u.a[i], sizeof(u.a)-i);
37445 return sizeof(u.a)-1-i;
37446 }
37447
@@ -37434,41 +37757,47 @@
37757 sqlite3Fp2Convert10(v, e, (iRound<=0||iRound>=18)?18:iRound+1, &v, &exp);
37758
37759 /* Extract significant digits, start at the right-most slot in p->zBuf
37760 ** and working back to the right. "i" keeps track of the next slot in
37761 ** which to store a digit. */
37762 assert( sizeof(p->zBuf)==SQLITE_U64_DIGITS+1 );
37763 assert( v>0 );
37764 zBuf = p->zBuf;
37765 #ifdef SQLITE_AVOID_U64_DIVIDE
37766 i = sqlite3UInt64ToText(v, zBuf);
37767 #else
37768 i = SQLITE_U64_DIGITS;
37769 while( v>=10 ){
37770 int kk = (v%100)*2;
37771 assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) );
37772 assert( TWO_BYTE_ALIGNMENT(&zBuf[i]) );
37773 assert( i-2>=0 );
37774 *(u16*)(&zBuf[i-2]) = *(u16*)&sqlite3DigitPairs.a[kk];
37775 i -= 2;
37776 v /= 100;
37777 }
37778 if( v ){
37779 assert( v<10 );
37780 assert( i>0 );
37781 zBuf[--i] = v + '0';
37782 }
37783 #endif /* SQLITE_AVOID_U64_DIVIDE */
37784 assert( i>=0 && i<SQLITE_U64_DIGITS );
37785 n = SQLITE_U64_DIGITS - i; /* Total number of digits extracted */
37786 assert( n>0 );
37787 assert( n<=SQLITE_U64_DIGITS );
 
37788 p->iDP = n + exp;
37789 if( iRound<=0 ){
37790 iRound = p->iDP - iRound;
37791 if( iRound==0 && zBuf[i]>='5' ){
37792 iRound = 1;
37793 zBuf[--i] = '0';
37794 n++;
37795 p->iDP++;
37796 }
37797 }
37798 z = &zBuf[i]; /* z points to the first digit */
37799 if( iRound>0 && (iRound<n || n>mxRound) ){
37800 if( iRound>mxRound ) iRound = mxRound;
37801 if( iRound==17 ){
37802 /* If the precision is exactly 17, which only happens with the "!"
37803 ** flag (ex: "%!.17g") then try to reduce the precision if that
@@ -85833,11 +86162,11 @@
86162 ** rc>0 => All of the input is well-formed
86163 ** (rc&2)==0 => The number is expressed as an integer, with no
86164 ** decimal point or eNNN suffix.
86165 */
86166 SQLITE_PRIVATE int sqlite3MemRealValueRC(Mem *pMem, double *pValue){
86167 testcase( pMem->db==0 );
86168 assert( pMem->flags & (MEM_Str|MEM_Blob) );
86169 if( pMem->z==0 ){
86170 *pValue = 0.0;
86171 return 0;
86172 }else if( pMem->enc==SQLITE_UTF8
@@ -131514,11 +131843,10 @@
131843 ** forms 2 through 5, then rebuild the union of all matching indexes,
131844 ** taken care to avoid rebuilding the same index more than once.
131845 */
131846 #ifndef SQLITE_OMIT_REINDEX
131847 SQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){
 
131848 char *z = 0; /* Name of a table or index or collation */
131849 const char *zDb = 0; /* Name of the database */
131850 int iReDb = -1; /* The database index number */
131851 sqlite3 *db = pParse->db; /* The database connection */
131852 Token *pObjName; /* Name of the table or index to be reindexed */
@@ -131553,11 +131881,11 @@
131881 if( !bAll ){
131882 if( zDb==0 && sqlite3StrICmp(z, "expressions")==0 ){
131883 isExprIdx = 1;
131884 bMatch = 1;
131885 }
131886 if( zDb==0 && sqlite3FindCollSeq(db, ENC(db), z, 0)!=0 ){
131887 zColl = z;
131888 bMatch = 1;
131889 }
131890 if( zColl==0 && (pReTab = sqlite3FindTable(db, z, zDb))!=0 ){
131891 bMatch = 1;
@@ -134449,22 +134777,15 @@
134777 ** require enhancements to the implementation. */
134778 assert( pStr!=0 && pStr->nChar==0 );
134779
134780 switch( sqlite3_value_type(pValue) ){
134781 case SQLITE_FLOAT: {
134782 /* ,--- Show infinity as 9.0e+999
134783 ** |
134784 ** | ,--- 17 precision guarantees round-trip
134785 ** v v */
134786 sqlite3_str_appendf(pStr, "%!0.17g", sqlite3_value_double(pValue));
 
 
 
 
 
 
 
134787 break;
134788 }
134789 case SQLITE_INTEGER: {
134790 sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
134791 break;
@@ -186195,11 +186516,11 @@
186516 if( db->mallocFailed ){
186517 pParse->rc = SQLITE_NOMEM_BKPT;
186518 }
186519 if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){
186520 if( pParse->zErrMsg==0 ){
186521 pParse->zErrMsg = sqlite3DbStrDup(db, sqlite3ErrStr(pParse->rc));
186522 }
186523 if( (pParse->prepFlags & SQLITE_PREPARE_DONT_LOG)==0 ){
186524 sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
186525 }
186526 nErr++;
@@ -233377,10 +233698,23 @@
233698 aBuf[4] = (i>>24) & 0xFF;
233699 aBuf[5] = (i>>16) & 0xFF;
233700 aBuf[6] = (i>> 8) & 0xFF;
233701 aBuf[7] = (i>> 0) & 0xFF;
233702 }
233703
233704 /*
233705 ** Write a double value to the buffer aBuf[].
233706 */
233707 static void sessionPutDouble(u8 *aBuf, double r){
233708 /* TODO: SQLite does something special to deal with mixed-endian
233709 ** floating point values (e.g. ARM7). This code probably should
233710 ** too. */
233711 u64 i;
233712 assert( sizeof(double)==8 && sizeof(u64)==8 );
233713 memcpy(&i, &r, 8);
233714 sessionPutI64(aBuf, i);
233715 }
233716
233717 /*
233718 ** This function is used to serialize the contents of value pValue (see
233719 ** comment titled "RECORD FORMAT" above).
233720 **
@@ -233415,20 +233749,17 @@
233749 case SQLITE_FLOAT:
233750 if( aBuf ){
233751 /* TODO: SQLite does something special to deal with mixed-endian
233752 ** floating point values (e.g. ARM7). This code probably should
233753 ** too. */
 
233754 if( eType==SQLITE_INTEGER ){
233755 u64 i = (u64)sqlite3_value_int64(pValue);
233756 sessionPutI64(&aBuf[1], i);
233757 }else{
233758 double r = sqlite3_value_double(pValue);
233759 sessionPutDouble(&aBuf[1], r);
 
 
233760 }
 
233761 }
233762 nByte = 9;
233763 break;
233764
233765 default: {
@@ -234356,13 +234687,11 @@
234687 break;
234688 }
234689
234690 case SQLITE_FLOAT: {
234691 double rVal = sqlite3_column_double(pDflt, iField);
234692 sessionPutDouble(&pNew->aRecord[pNew->nRecord], rVal);
 
 
234693 pNew->nRecord += 8;
234694 break;
234695 }
234696
234697 case SQLITE_TEXT: {
@@ -235615,19 +235944,18 @@
235944 ){
235945 if( *pRc==SQLITE_OK ){
235946 int eType = sqlite3_column_type(pStmt, iCol);
235947 sessionAppendByte(p, (u8)eType, pRc);
235948 if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
 
235949 u8 aBuf[8];
235950 if( eType==SQLITE_INTEGER ){
235951 sqlite3_int64 i = sqlite3_column_int64(pStmt, iCol);
235952 sessionPutI64(aBuf, i);
235953 }else{
235954 double r = sqlite3_column_double(pStmt, iCol);
235955 sessionPutDouble(aBuf, r);
235956 }
 
235957 sessionAppendBlob(p, aBuf, 8, pRc);
235958 }
235959 if( eType==SQLITE_BLOB || eType==SQLITE_TEXT ){
235960 u8 *z;
235961 int nByte;
@@ -238664,10 +238992,25 @@
238992 xFilter, 0, xConflict, pCtx,
238993 0, 0, 0
238994 );
238995 }
238996
238997 /*
238998 ** The parts of the sqlite3_changegroup structure used by the
238999 ** sqlite3changegroup_change_xxx() APIs.
239000 */
239001 typedef struct ChangeData ChangeData;
239002 struct ChangeData {
239003 SessionTable *pTab;
239004 int bIndirect;
239005 int eOp;
239006
239007 int nBufAlloc;
239008 SessionBuffer *aBuf;
239009 SessionBuffer record;
239010 };
239011
239012 /*
239013 ** sqlite3_changegroup handle.
239014 */
239015 struct sqlite3_changegroup {
239016 int rc; /* Error code */
@@ -238675,10 +239018,11 @@
239018 SessionTable *pList; /* List of tables in current patch */
239019 SessionBuffer rec;
239020
239021 sqlite3 *db; /* Configured by changegroup_schema() */
239022 char *zDb; /* Configured by changegroup_schema() */
239023 ChangeData cd; /* Used by changegroup_change_xxx() APIs. */
239024 };
239025
239026 /*
239027 ** This function is called to merge two changes to the same row together as
239028 ** part of an sqlite3changeset_concat() operation. A new change object is
@@ -238914,19 +239258,18 @@
239258 int eType = sqlite3_column_type(pTab->pDfltStmt, ii);
239259 sessionAppendByte(pOut, eType, &rc);
239260 switch( eType ){
239261 case SQLITE_FLOAT:
239262 case SQLITE_INTEGER: {
 
 
 
 
 
 
 
239263 if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){
239264 if( eType==SQLITE_INTEGER ){
239265 sqlite3_int64 iVal = sqlite3_column_int64(pTab->pDfltStmt, ii);
239266 sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal);
239267 }else{
239268 double rVal = sqlite3_column_double(pTab->pDfltStmt, ii);
239269 sessionPutDouble(&pOut->aBuf[pOut->nBuf], rVal);
239270 }
239271 pOut->nBuf += 8;
239272 }
239273 break;
239274 }
239275
@@ -238993,17 +239336,23 @@
239336 int nTab = (int)strlen(zTab);
239337 u8 *abPK = 0;
239338 int nCol = 0;
239339
239340 *ppTab = 0;
 
239341
239342 /* Search the list for an existing table */
239343 for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){
239344 if( 0==sqlite3_strnicmp(pTab->zName, zTab, nTab+1) ) break;
239345 }
239346
239347
239348 if( pIter ){
239349 sqlite3changeset_pk(pIter, &abPK, &nCol);
239350 }else if( !pTab && !pGrp->db ){
239351 return SQLITE_OK;
239352 }
239353
239354 /* If one was not found above, create a new table now */
239355 if( !pTab ){
239356 SessionTable **ppNew;
239357
239358 pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nTab+1);
@@ -239018,12 +239367,12 @@
239367 memcpy(pTab->zName, zTab, nTab+1);
239368
239369 if( pGrp->db ){
239370 pTab->nCol = 0;
239371 rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb);
239372 if( rc || pTab->nCol==0 ){
239373 sqlite3_free(pTab->azCol);
239374 sqlite3_free(pTab);
239375 return rc;
239376 }
239377 }
239378
@@ -239034,78 +239383,61 @@
239383 for(ppNew=&pGrp->pList; *ppNew; ppNew=&(*ppNew)->pNext);
239384 *ppNew = pTab;
239385 }
239386
239387 /* Check that the table is compatible. */
239388 if( pIter && !sessionChangesetCheckCompat(pTab, nCol, abPK) ){
239389 rc = SQLITE_SCHEMA;
239390 }
239391
239392 *ppTab = pTab;
239393 return rc;
239394 }
239395
239396 /*
239397 ** Add a single change to the changegroup pGrp.
 
239398 */
239399 static int sessionOneChangeToHash(
239400 sqlite3_changegroup *pGrp, /* Changegroup to update */
239401 SessionTable *pTab, /* Table change pertains to */
239402 int op, /* One of SQLITE_INSERT, UPDATE, DELETE */
239403 int bIndirect, /* True to flag change as "indirect" */
239404 int nCol, /* Number of columns in record(s) */
239405 u8 *aRec, /* Serialized change record(s) */
239406 int nRec, /* Size of aRec[] in bytes */
239407 int bRebase /* True if this is a rebase blob */
239408 ){
239409 int rc = SQLITE_OK;
 
 
239410 int iHash = 0;
 
239411 SessionChange *pChange = 0;
239412 SessionChange *pExist = 0;
239413 SessionChange **pp = 0;
 
 
 
239414
239415 assert( nRec>0 );
239416
239417 if( nCol<pTab->nCol ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239418 SessionBuffer *pBuf = &pGrp->rec;
239419 rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, pBuf);
239420 aRec = pBuf->aBuf;
239421 nRec = pBuf->nBuf;
239422 assert( pGrp->db );
239423 }
239424
239425 if( rc==SQLITE_OK && sessionGrowHash(0, pGrp->bPatch, pTab) ){
239426 rc = SQLITE_NOMEM;
239427 }
239428
239429 if( rc==SQLITE_OK ){
239430 /* Search for existing entry. If found, remove it from the hash table.
239431 ** Code below may link it back in. */
239432 iHash = sessionChangeHash(
239433 pTab, (pGrp->bPatch && op==SQLITE_DELETE), aRec, pTab->nChange
239434 );
239435 for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){
239436 int bPkOnly1 = 0;
239437 int bPkOnly2 = 0;
239438 if( pGrp->bPatch ){
239439 bPkOnly1 = (*pp)->op==SQLITE_DELETE;
239440 bPkOnly2 = op==SQLITE_DELETE;
239441 }
239442 if( sessionChangeEqual(pTab, bPkOnly1, (*pp)->aRecord, bPkOnly2, aRec) ){
239443 pExist = *pp;
@@ -239116,18 +239448,59 @@
239448 }
239449 }
239450
239451 if( rc==SQLITE_OK ){
239452 rc = sessionChangeMerge(pTab, bRebase,
239453 pGrp->bPatch, pExist, op, bIndirect, aRec, nRec, &pChange
239454 );
239455 }
239456 if( rc==SQLITE_OK && pChange ){
239457 pChange->pNext = pTab->apChange[iHash];
239458 pTab->apChange[iHash] = pChange;
239459 pTab->nEntry++;
239460 }
239461
239462 return rc;
239463 }
239464
239465 /*
239466 ** Add the change currently indicated by iterator pIter to the hash table
239467 ** belonging to changegroup pGrp.
239468 */
239469 static int sessionOneChangeIterToHash(
239470 sqlite3_changegroup *pGrp,
239471 sqlite3_changeset_iter *pIter,
239472 int bRebase
239473 ){
239474 u8 *aRec = &pIter->in.aData[pIter->in.iCurrent + 2];
239475 int nRec = (pIter->in.iNext - pIter->in.iCurrent) - 2;
239476 const char *zTab = 0;
239477 int nCol = 0;
239478 int op = 0;
239479 int bIndirect = 0;
239480 int rc = SQLITE_OK;
239481 SessionTable *pTab = 0;
239482
239483 /* Ensure that only changesets, or only patchsets, but not a mixture
239484 ** of both, are being combined. It is an error to try to combine a
239485 ** changeset and a patchset. */
239486 if( pGrp->pList==0 ){
239487 pGrp->bPatch = pIter->bPatchset;
239488 }else if( pIter->bPatchset!=pGrp->bPatch ){
239489 rc = SQLITE_ERROR;
239490 }
239491
239492 if( rc==SQLITE_OK ){
239493 sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);
239494 rc = sessionChangesetFindTable(pGrp, zTab, pIter, &pTab);
239495 }
239496
239497 if( rc==SQLITE_OK ){
239498 rc = sessionOneChangeToHash(
239499 pGrp, pTab, op, bIndirect, nCol, aRec, nRec, bRebase
239500 );
239501 }
239502
239503 if( rc==SQLITE_OK ) rc = pIter->rc;
239504 return rc;
239505 }
239506
@@ -239144,11 +239517,11 @@
239517 int nRec;
239518 int rc = SQLITE_OK;
239519
239520 pIter->in.bNoDiscard = 1;
239521 while( SQLITE_ROW==(sessionChangesetNext(pIter, &aRec, &nRec, 0)) ){
239522 rc = sessionOneChangeIterToHash(pGrp, pIter, bRebase);
239523 if( rc!=SQLITE_OK ) break;
239524 }
239525
239526 if( rc==SQLITE_OK ) rc = pIter->rc;
239527 return rc;
@@ -239233,10 +239606,37 @@
239606 memset(p, 0, sizeof(sqlite3_changegroup));
239607 }
239608 *pp = p;
239609 return rc;
239610 }
239611
239612 /*
239613 ** Configure a changegroup object.
239614 */
239615 SQLITE_API int sqlite3changegroup_config(
239616 sqlite3_changegroup *pGrp,
239617 int op,
239618 void *pArg
239619 ){
239620 int rc = SQLITE_OK;
239621
239622 switch( op ){
239623 case SQLITE_CHANGEGROUP_CONFIG_PATCHSET: {
239624 int arg = *(int*)pArg;
239625 if( pGrp->pList==0 && arg>=0 ){
239626 pGrp->bPatch = (arg>0);
239627 }
239628 *(int*)pArg = pGrp->bPatch;
239629 break;
239630 }
239631 default:
239632 rc = SQLITE_MISUSE;
239633 break;
239634 }
239635
239636 return rc;
239637 }
239638
239639 /*
239640 ** Provide a database schema to the changegroup object.
239641 */
239642 SQLITE_API int sqlite3changegroup_schema(
@@ -239292,11 +239692,11 @@
239692 ){
239693 /* Iterator does not point to any valid entry or is an INVERT iterator. */
239694 rc = SQLITE_ERROR;
239695 }else{
239696 pIter->in.bNoDiscard = 1;
239697 rc = sessionOneChangeIterToHash(pGrp, pIter, 0);
239698 }
239699 return rc;
239700 }
239701
239702 /*
@@ -239344,10 +239744,16 @@
239744 /*
239745 ** Delete a changegroup object.
239746 */
239747 SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){
239748 if( pGrp ){
239749 int ii;
239750 for(ii=0; ii<pGrp->cd.nBufAlloc; ii++){
239751 sqlite3_free(pGrp->cd.aBuf[ii].aBuf);
239752 }
239753 sqlite3_free(pGrp->cd.record.aBuf);
239754 sqlite3_free(pGrp->cd.aBuf);
239755 sqlite3_free(pGrp->zDb);
239756 sessionDeleteTable(0, pGrp->pList);
239757 sqlite3_free(pGrp->rec.aBuf);
239758 sqlite3_free(pGrp);
239759 }
@@ -239771,10 +240177,332 @@
240177 }
240178 default:
240179 rc = SQLITE_MISUSE;
240180 break;
240181 }
240182 return rc;
240183 }
240184
240185 /*
240186 ** Begin adding a change to a changegroup object.
240187 */
240188 SQLITE_API int sqlite3changegroup_change_begin(
240189 sqlite3_changegroup *pGrp,
240190 int eOp,
240191 const char *zTab,
240192 int bIndirect,
240193 char **pzErr
240194 ){
240195 SessionTable *pTab = 0;
240196 int rc = SQLITE_OK;
240197
240198 if( pGrp->cd.pTab ){
240199 rc = SQLITE_MISUSE;
240200 }else if( eOp!=SQLITE_INSERT && eOp!=SQLITE_UPDATE && eOp!=SQLITE_DELETE ){
240201 rc = SQLITE_ERROR;
240202 }else{
240203 rc = sessionChangesetFindTable(pGrp, zTab, 0, &pTab);
240204 }
240205 if( rc==SQLITE_OK ){
240206 if( pTab==0 ){
240207 if( pzErr ){
240208 *pzErr = sqlite3_mprintf("no such table: %s", zTab);
240209 }
240210 rc = SQLITE_ERROR;
240211 }else{
240212 int nReq = pTab->nCol * (eOp==SQLITE_UPDATE ? 2 : 1);
240213 pGrp->cd.pTab = pTab;
240214 pGrp->cd.eOp = eOp;
240215 pGrp->cd.bIndirect = bIndirect;
240216
240217 if( pGrp->cd.nBufAlloc<nReq ){
240218 SessionBuffer *aBuf = (SessionBuffer*)sqlite3_realloc(
240219 pGrp->cd.aBuf, nReq * sizeof(SessionBuffer)
240220 );
240221 if( aBuf==0 ){
240222 rc = SQLITE_NOMEM;
240223 }else{
240224 memset(&aBuf[pGrp->cd.nBufAlloc], 0,
240225 sizeof(SessionBuffer) * (nReq - pGrp->cd.nBufAlloc)
240226 );
240227 pGrp->cd.aBuf = aBuf;
240228 pGrp->cd.nBufAlloc = nReq;
240229 }
240230 }
240231
240232 #ifdef SQLITE_DEBUG
240233 {
240234 /* Assert that all column values are currently undefined */
240235 int ii;
240236 for(ii=0; ii<pGrp->cd.nBufAlloc; ii++){
240237 assert( pGrp->cd.aBuf[ii].nBuf==0 );
240238 }
240239 }
240240 #endif
240241 }
240242 }
240243
240244 return rc;
240245 }
240246
240247 /*
240248 ** This function does processing common to the _change_int64(), _change_text()
240249 ** and other similar APIs.
240250 */
240251 static int checkChangeParams(
240252 sqlite3_changegroup *pGrp,
240253 int bNew,
240254 int iCol,
240255 sqlite3_int64 nReq,
240256 SessionBuffer **ppBuf
240257 ){
240258 int rc = SQLITE_OK;
240259 if( pGrp->cd.pTab==0 ){
240260 rc = SQLITE_MISUSE;
240261 }else if( iCol<0 || iCol>=pGrp->cd.pTab->nCol ){
240262 rc = SQLITE_RANGE;
240263 }else if(
240264 (bNew && pGrp->cd.eOp==SQLITE_DELETE)
240265 || (!bNew && pGrp->cd.eOp==SQLITE_INSERT)
240266 ){
240267 rc = SQLITE_ERROR;
240268 }else{
240269 SessionBuffer *pBuf = &pGrp->cd.aBuf[iCol];
240270 if( pGrp->cd.eOp==SQLITE_UPDATE && bNew ){
240271 pBuf += pGrp->cd.pTab->nCol;
240272 }
240273 pBuf->nBuf = 0;
240274 sessionBufferGrow(pBuf, nReq, &rc);
240275 pBuf->nBuf = nReq;
240276 *ppBuf = pBuf;
240277 }
240278 return rc;
240279 }
240280
240281 /*
240282 ** Configure the change currently under construction with an integer value.
240283 */
240284 SQLITE_API int sqlite3changegroup_change_int64(
240285 sqlite3_changegroup *pGrp,
240286 int bNew,
240287 int iCol,
240288 sqlite3_int64 iVal
240289 ){
240290 int rc = SQLITE_OK;
240291 SessionBuffer *pBuf = 0;
240292
240293 if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, 9, &pBuf)) ){
240294 return rc;
240295 }
240296
240297 pBuf->aBuf[0] = SQLITE_INTEGER;
240298 sessionPutI64(&pBuf->aBuf[1], iVal);
240299 return SQLITE_OK;
240300 }
240301
240302 /*
240303 ** Configure the change currently under construction with a null value.
240304 */
240305 SQLITE_API int sqlite3changegroup_change_null(
240306 sqlite3_changegroup *pGrp,
240307 int bNew,
240308 int iCol
240309 ){
240310 int rc = SQLITE_OK;
240311 SessionBuffer *pBuf = 0;
240312
240313 if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, 1, &pBuf)) ){
240314 return rc;
240315 }
240316
240317 pBuf->aBuf[0] = SQLITE_NULL;
240318 return SQLITE_OK;
240319 }
240320
240321 /*
240322 ** Configure the change currently under construction with a real value.
240323 */
240324 SQLITE_API int sqlite3changegroup_change_double(
240325 sqlite3_changegroup *pGrp,
240326 int bNew,
240327 int iCol,
240328 double fVal
240329 ){
240330 int rc = SQLITE_OK;
240331 SessionBuffer *pBuf = 0;
240332
240333 if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, 9, &pBuf)) ){
240334 return rc;
240335 }
240336
240337 pBuf->aBuf[0] = SQLITE_FLOAT;
240338 sessionPutDouble(&pBuf->aBuf[1], fVal);
240339 return SQLITE_OK;
240340 }
240341
240342 /*
240343 ** Configure the change currently under construction with a text value.
240344 */
240345 SQLITE_API int sqlite3changegroup_change_text(
240346 sqlite3_changegroup *pGrp,
240347 int bNew,
240348 int iCol,
240349 const char *pVal,
240350 int nVal
240351 ){
240352 int nText = nVal>=0 ? nVal : strlen(pVal);
240353 sqlite3_int64 nByte = 1 + sessionVarintLen(nText) + nText;
240354 int rc = SQLITE_OK;
240355 SessionBuffer *pBuf = 0;
240356
240357 if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, nByte, &pBuf)) ){
240358 return rc;
240359 }
240360
240361 pBuf->aBuf[0] = SQLITE_TEXT;
240362 pBuf->nBuf = (1 + sessionVarintPut(&pBuf->aBuf[1], nText));
240363 memcpy(&pBuf->aBuf[pBuf->nBuf], pVal, nText);
240364 pBuf->nBuf += nText;
240365
240366 return SQLITE_OK;
240367 }
240368
240369 /*
240370 ** Configure the change currently under construction with a blob value.
240371 */
240372 SQLITE_API int sqlite3changegroup_change_blob(
240373 sqlite3_changegroup *pGrp,
240374 int bNew,
240375 int iCol,
240376 const void *pVal,
240377 int nVal
240378 ){
240379 sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) + nVal;
240380 int rc = SQLITE_OK;
240381 SessionBuffer *pBuf = 0;
240382
240383 if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, nByte, &pBuf)) ){
240384 return rc;
240385 }
240386
240387 pBuf->aBuf[0] = SQLITE_BLOB;
240388 pBuf->nBuf = (1 + sessionVarintPut(&pBuf->aBuf[1], nVal));
240389 memcpy(&pBuf->aBuf[pBuf->nBuf], pVal, nVal);
240390 pBuf->nBuf += nVal;
240391
240392 return SQLITE_OK;
240393 }
240394
240395 /*
240396 ** Finish any change currently being constructed by the changegroup object.
240397 */
240398 SQLITE_API int sqlite3changegroup_change_finish(
240399 sqlite3_changegroup *pGrp,
240400 int bDiscard,
240401 char **pzErr
240402 ){
240403 int rc = SQLITE_OK;
240404 if( pGrp->cd.pTab ){
240405 SessionBuffer *aBuf = pGrp->cd.aBuf;
240406 int ii;
240407
240408 if( bDiscard==0 ){
240409 int nBuf = pGrp->cd.pTab->nCol;
240410 u8 eUndef = SQLITE_NULL;
240411 if( pGrp->cd.eOp==SQLITE_UPDATE ){
240412 for(ii=0; ii<nBuf; ii++){
240413 if( pGrp->cd.pTab->abPK[ii] ){
240414 if( aBuf[ii].nBuf<=1 ){
240415 *pzErr = sqlite3_mprintf(
240416 "invalid change: %s value in PK of old.* record",
240417 aBuf[ii].nBuf==1 ? "null" : "undefined"
240418 );
240419 rc = SQLITE_ERROR;
240420 break;
240421 }else if( aBuf[ii + nBuf].nBuf>0 ){
240422 *pzErr = sqlite3_mprintf(
240423 "invalid change: defined value in PK of new.* record"
240424 );
240425 rc = SQLITE_ERROR;
240426 break;
240427 }
240428 }else
240429 if( pGrp->bPatch==0 && (aBuf[ii].nBuf>0)!=(aBuf[ii+nBuf].nBuf>0) ){
240430 *pzErr = sqlite3_mprintf(
240431 "invalid change: column %d "
240432 "- old.* value is %sdefined but new.* is %sdefined",
240433 ii, aBuf[ii].nBuf ? "" : "un", aBuf[ii+nBuf].nBuf ? "" : "un"
240434 );
240435 rc = SQLITE_ERROR;
240436 break;
240437 }
240438 }
240439 eUndef = 0x00;
240440 if( pGrp->bPatch==0 ) nBuf = nBuf * 2;
240441 }else{
240442 for(ii=0; ii<nBuf; ii++){
240443 int isPK = pGrp->cd.pTab->abPK[ii];
240444 if( (pGrp->cd.eOp==SQLITE_INSERT || pGrp->bPatch==0 || isPK)
240445 && aBuf[ii].nBuf==0
240446 ){
240447 *pzErr = sqlite3_mprintf(
240448 "invalid change: column %d is undefined", ii
240449 );
240450 rc = SQLITE_ERROR;
240451 break;
240452 }
240453 if( aBuf[ii].nBuf==1 && isPK ){
240454 *pzErr = sqlite3_mprintf(
240455 "invalid change: null value in PK"
240456 );
240457 rc = SQLITE_ERROR;
240458 break;
240459 }
240460 }
240461 }
240462
240463 pGrp->cd.record.nBuf = 0;
240464 for(ii=0; ii<nBuf; ii++){
240465 SessionBuffer *p = &pGrp->cd.aBuf[ii];
240466 if( pGrp->bPatch ){
240467 if( pGrp->cd.pTab->abPK[ii]==0 ){
240468 if( pGrp->cd.eOp==SQLITE_UPDATE ){
240469 p += pGrp->cd.pTab->nCol;
240470 }else if( pGrp->cd.eOp==SQLITE_DELETE ){
240471 continue;
240472 }
240473 }
240474 }
240475 if( 0==sessionBufferGrow(&pGrp->cd.record, p->nBuf?p->nBuf:1, &rc) ){
240476 if( p->nBuf ){
240477 memcpy(&pGrp->cd.record.aBuf[pGrp->cd.record.nBuf],p->aBuf,p->nBuf);
240478 pGrp->cd.record.nBuf += p->nBuf;
240479 }else{
240480 pGrp->cd.record.aBuf[pGrp->cd.record.nBuf++] = eUndef;
240481 }
240482 }
240483 }
240484 if( rc==SQLITE_OK ){
240485 rc = sessionOneChangeToHash(
240486 pGrp, pGrp->cd.pTab,
240487 pGrp->cd.eOp, pGrp->cd.bIndirect, pGrp->cd.pTab->nCol,
240488 pGrp->cd.record.aBuf, pGrp->cd.record.nBuf, 0
240489 );
240490 }
240491 }
240492
240493 /* Reset all aBuf[] entries to "undefined". */
240494 {
240495 int nZero = pGrp->cd.pTab->nCol;
240496 if( pGrp->cd.eOp==SQLITE_UPDATE ) nZero += nZero;
240497 for(ii=0; ii<nZero; ii++){
240498 pGrp->cd.aBuf[ii].nBuf = 0;
240499 }
240500 }
240501 pGrp->cd.pTab = 0;
240502 }
240503
240504 return rc;
240505 }
240506
240507 #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */
240508
@@ -262478,11 +263206,11 @@
263206 int nArg, /* Number of args */
263207 sqlite3_value **apUnused /* Function arguments */
263208 ){
263209 assert( nArg==0 );
263210 UNUSED_PARAM2(nArg, apUnused);
263211 sqlite3_result_text(pCtx, "fts5: 2026-04-01 11:39:13 009b576dcd5fccaaa52459dbfaa1b2a6fcf6d372e4b8d63553dfa88aab9a759c", -1, SQLITE_TRANSIENT);
263212 }
263213
263214 /*
263215 ** Implementation of fts5_locale(LOCALE, TEXT) function.
263216 **
263217
+284 -48
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.53.0"
150150
#define SQLITE_VERSION_NUMBER 3053000
151
-#define SQLITE_SOURCE_ID "2026-03-26 19:11:57 c5af6a10245b6b847d30002806c1577b020c36ab27f7b1cf202ade136aa4779c"
151
+#define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2026-03-26T19:11:57.079Z"
154
+#define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
@@ -576,11 +576,11 @@
576576
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
577577
#define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
578578
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
579579
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
580580
#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 */
582582
583583
/*
584584
** CAPI3REF: Flags For File Open Operations
585585
**
586586
** These bit values are intended for use in the
@@ -1288,10 +1288,16 @@
12881288
/* deprecated names */
12891289
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
12901290
#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
12911291
#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
12921292
1293
+/* reserved file-control numbers:
1294
+** 101
1295
+** 102
1296
+** 103
1297
+*/
1298
+
12931299
12941300
/*
12951301
** CAPI3REF: Mutex Handle
12961302
**
12971303
** The mutex module within SQLite defines [sqlite3_mutex] to be an
@@ -1709,11 +1715,12 @@
17091715
** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
17101716
** The exceptional configuration options that may be invoked at any time
17111717
** are called "anytime configuration options".
17121718
** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
17131719
** [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.
17151722
** Note, however, that ^sqlite3_config() can be called as part of the
17161723
** implementation of an application-defined [sqlite3_os_init()].
17171724
**
17181725
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
17191726
** ^If the option is unknown or SQLite is unable to set the option
@@ -2275,13 +2282,14 @@
22752282
** <li><P>The second argument ("sz") is the
22762283
** size of each lookaside buffer slot. Lookaside is disabled if "sz"
22772284
** is less than 8. The "sz" argument should be a multiple of 8 less than
22782285
** 65536. If "sz" does not meet this constraint, it is reduced in size until
22792286
** 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"
22832291
** parameter is usually chosen so that the product of "sz" and "cnt" is less
22842292
** than 1,000,000.
22852293
** </ol>
22862294
** <p>If the "buf" argument is not NULL, then it must
22872295
** point to a memory buffer with a size that is greater than
@@ -2656,11 +2664,11 @@
26562664
** default value 17, as of SQLite version 3.52.0. The value was 15 in all
26572665
** prior versions.<p>
26582666
** This option takes two arguments which are an integer and a pointer
26592667
** to an integer. The first argument is a small integer, between 3 and 23, or
26602668
** zero. The FP_DIGITS setting is changed to that small integer, or left
2661
-** unaltered if the first argument is zero or out of range. The second argument
2669
+** unaltered if the first argument is zero or out of range. The second argument
26622670
** is a pointer to an integer. If the pointer is not NULL, then the value of
26632671
** the FP_DIGITS setting, after possibly being modified by the first
26642672
** arguments, is written into the integer to which the second argument points.
26652673
** </dd>
26662674
**
@@ -2668,14 +2676,16 @@
26682676
**
26692677
** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
26702678
**
26712679
** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
26722680
** overall call to [sqlite3_db_config()] has a total of four parameters.
2673
-** The first argument (the third parameter to sqlite3_db_config()) is an integer.
2674
-** The second argument is a pointer to an integer. If the first argument is 1,
2675
-** then the option becomes enabled. If the first integer argument is 0, then the
2676
-** 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
26772687
** is unchanged. The second argument, the pointer to an integer, may be NULL.
26782688
** If the second argument is not NULL, then a value of 0 or 1 is written into
26792689
** the integer to which the second argument points, depending on whether the
26802690
** setting is disabled or enabled after applying any changes specified by
26812691
** the first argument.
@@ -5848,12 +5858,13 @@
58485858
** that the application-defined collating sequence created expects its
58495859
** input strings to be in UTF16 in native byte order, and that the start
58505860
** of the strings must be aligned to a 2-byte boundary.
58515861
**
58525862
** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
5853
-** used to specify the text encoding to strings input to [sqlite3_result_text64()]
5854
-** and [sqlite3_bind_text64()]. It means that the input string (call it "z")
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")
58555866
** is UTF-8 encoded and that it is zero-terminated. If the length parameter
58565867
** (call it "n") is non-negative, this encoding option means that the caller
58575868
** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
58585869
** byte has a value of zero.
58595870
** This option gives the same output as SQLITE_UTF8, but can be more efficient
@@ -6101,30 +6112,26 @@
61016112
**
61026113
** These routines must be called from the same thread as
61036114
** the SQL function that supplied the [sqlite3_value*] parameters.
61046115
**
61056116
** As long as the input parameter is correct, these routines can only
6106
-** fail if an out-of-memory error occurs during a format conversion.
6107
-** Only the following subset of interfaces are subject to out-of-memory
6108
-** errors:
6109
-**
6110
-** <ul>
6111
-** <li> sqlite3_value_blob()
6112
-** <li> sqlite3_value_text()
6113
-** <li> sqlite3_value_text16()
6114
-** <li> sqlite3_value_text16le()
6115
-** <li> sqlite3_value_text16be()
6116
-** <li> sqlite3_value_bytes()
6117
-** <li> sqlite3_value_bytes16()
6118
-** </ul>
6119
-**
6117
+** fail if an out-of-memory error occurs while trying to do a
6118
+** UTF8&rarr;UTF16 or UTF16&rarr;UTF8 conversion.
61206119
** If an out-of-memory error occurs, then the return value from these
61216120
** routines is the same as if the column had contained an SQL NULL value.
6122
-** Valid SQL NULL returns can be distinguished from out-of-memory errors
6123
-** 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
61246125
** return value is obtained and before any
61256126
** 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.
61266133
*/
61276134
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
61286135
SQLITE_API double sqlite3_value_double(sqlite3_value*);
61296136
SQLITE_API int sqlite3_value_int(sqlite3_value*);
61306137
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -6147,11 +6154,12 @@
61476154
** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
61486155
** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding
61496156
** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
61506157
** returns something other than SQLITE_TEXT, then the return value from
61516158
** sqlite3_value_encoding(X) is meaningless. ^Calls to
6152
-** [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)],
61536161
** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
61546162
** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
61556163
** thus change the return from subsequent calls to sqlite3_value_encoding(X).
61566164
**
61576165
** This routine is intended for used by applications that test and validate
@@ -6278,21 +6286,21 @@
62786286
** associate auxiliary data with argument values. If the same argument
62796287
** value is passed to multiple invocations of the same SQL function during
62806288
** query execution, under some circumstances the associated auxiliary data
62816289
** might be preserved. An example of where this might be useful is in a
62826290
** regular-expression matching function. The compiled version of the regular
6283
-** expression can be stored as auxiliary data associated with the pattern string.
6284
-** 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,
62856293
** the compiled regular expression can be reused on multiple
62866294
** invocations of the same function.
62876295
**
6288
-** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
6289
-** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
6290
-** value to the application-defined function. ^N is zero for the left-most
6291
-** function argument. ^If there is no auxiliary data
6292
-** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
6293
-** 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.
62946302
**
62956303
** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
62966304
** N-th argument of the application-defined function. ^Subsequent
62976305
** calls to sqlite3_get_auxdata(C,N) return P from the most recent
62986306
** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
@@ -10401,21 +10409,22 @@
1040110409
**
1040210410
** <table border=1 cellspacing=0 cellpadding=10 width="90%">
1040310411
** <tr>
1040410412
** <td valign="top">sqlite3_vtab_distinct() return value
1040510413
** <td valign="top">Rows are returned in aOrderBy order
10406
-** <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
1040710416
** <td valign="top">Duplicates over all colUsed columns may be omitted
1040810417
** <tr><td>0<td>yes<td>yes<td>no
1040910418
** <tr><td>1<td>no<td>yes<td>no
1041010419
** <tr><td>2<td>no<td>yes<td>yes
1041110420
** <tr><td>3<td>yes<td>yes<td>yes
1041210421
** </table>
1041310422
**
1041410423
** ^For the purposes of comparing virtual table output values to see if the
10415
-** values are the same value for sorting purposes, two NULL values are considered
10416
-** 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"
1041710426
** (or "IS NOT DISTINCT FROM") and not "==".
1041810427
**
1041910428
** If a virtual table implementation is unable to meet the requirements
1042010429
** specified above, then it must not set the "orderByConsumed" flag in the
1042110430
** [sqlite3_index_info] object or an incorrect answer may result.
@@ -11265,16 +11274,17 @@
1126511274
/*
1126611275
** CAPI3REF: Bind array values to the CARRAY table-valued function
1126711276
**
1126811277
** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
1126911278
** parameter that is the first argument of the [carray() table-valued function].
11270
-** The S parameter is a pointer to the [prepared statement] that uses the carray()
11271
-** functions. I is the parameter index to be bound. I must be the index of the
11272
-** parameter that is the first argument to the carray() table-valued function.
11273
-** P is a pointer to the array to be bound, and N is the number of elements in
11274
-** the array. The F argument is one of constants [SQLITE_CARRAY_INT32],
11275
-** [SQLITE_CARRAY_INT64], [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
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],
1127611286
** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
1127711287
**
1127811288
** If the X argument is not a NULL pointer or one of the special
1127911289
** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
1128011290
** the function X with argument D when it is finished using the data in P.
@@ -13327,10 +13337,236 @@
1332713337
1332813338
/*
1332913339
** CAPI3REF: Values for sqlite3session_config().
1333013340
*/
1333113341
#define SQLITE_SESSION_CONFIG_STRMSIZE 1
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
+);
1333213568
1333313569
/*
1333413570
** Make sure we can call this stuff from C++.
1333513571
*/
1333613572
#ifdef __cplusplus
1333713573
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.53.0"
150 #define SQLITE_VERSION_NUMBER 3053000
151 #define SQLITE_SOURCE_ID "2026-03-26 19:11:57 c5af6a10245b6b847d30002806c1577b020c36ab27f7b1cf202ade136aa4779c"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-03-26T19:11:57.079Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -576,11 +576,11 @@
576 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
577 #define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
578 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
579 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
580 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
581 #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
582
583 /*
584 ** CAPI3REF: Flags For File Open Operations
585 **
586 ** These bit values are intended for use in the
@@ -1288,10 +1288,16 @@
1288 /* deprecated names */
1289 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1290 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1291 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
1292
 
 
 
 
 
 
1293
1294 /*
1295 ** CAPI3REF: Mutex Handle
1296 **
1297 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
@@ -1709,11 +1715,12 @@
1709 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1710 ** The exceptional configuration options that may be invoked at any time
1711 ** are called "anytime configuration options".
1712 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1713 ** [sqlite3_shutdown()] with a first argument that is not an anytime
1714 ** configuration option, then the sqlite3_config() call will return SQLITE_MISUSE.
 
1715 ** Note, however, that ^sqlite3_config() can be called as part of the
1716 ** implementation of an application-defined [sqlite3_os_init()].
1717 **
1718 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1719 ** ^If the option is unknown or SQLite is unable to set the option
@@ -2275,13 +2282,14 @@
2275 ** <li><P>The second argument ("sz") is the
2276 ** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2277 ** is less than 8. The "sz" argument should be a multiple of 8 less than
2278 ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2279 ** 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"
 
2283 ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2284 ** than 1,000,000.
2285 ** </ol>
2286 ** <p>If the "buf" argument is not NULL, then it must
2287 ** point to a memory buffer with a size that is greater than
@@ -2656,11 +2664,11 @@
2656 ** default value 17, as of SQLite version 3.52.0. The value was 15 in all
2657 ** prior versions.<p>
2658 ** This option takes two arguments which are an integer and a pointer
2659 ** to an integer. The first argument is a small integer, between 3 and 23, or
2660 ** zero. The FP_DIGITS setting is changed to that small integer, or left
2661 ** unaltered if the first argument is zero or out of range. The second argument
2662 ** is a pointer to an integer. If the pointer is not NULL, then the value of
2663 ** the FP_DIGITS setting, after possibly being modified by the first
2664 ** arguments, is written into the integer to which the second argument points.
2665 ** </dd>
2666 **
@@ -2668,14 +2676,16 @@
2668 **
2669 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2670 **
2671 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2672 ** overall call to [sqlite3_db_config()] has a total of four parameters.
2673 ** The first argument (the third parameter to sqlite3_db_config()) is an integer.
2674 ** The second argument is a pointer to an integer. If the first argument is 1,
2675 ** then the option becomes enabled. If the first integer argument is 0, then the
2676 ** option is disabled. If the first argument is -1, then the option setting
 
 
2677 ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2678 ** If the second argument is not NULL, then a value of 0 or 1 is written into
2679 ** the integer to which the second argument points, depending on whether the
2680 ** setting is disabled or enabled after applying any changes specified by
2681 ** the first argument.
@@ -5848,12 +5858,13 @@
5848 ** that the application-defined collating sequence created expects its
5849 ** input strings to be in UTF16 in native byte order, and that the start
5850 ** of the strings must be aligned to a 2-byte boundary.
5851 **
5852 ** [[SQLITE_UTF8_ZT]] <dt>SQLITE_UTF8_ZT</dt><dd>This option can only be
5853 ** used to specify the text encoding to strings input to [sqlite3_result_text64()]
5854 ** and [sqlite3_bind_text64()]. It means that the input string (call it "z")
 
5855 ** is UTF-8 encoded and that it is zero-terminated. If the length parameter
5856 ** (call it "n") is non-negative, this encoding option means that the caller
5857 ** guarantees that z array contains at least n+1 bytes and that the z&#91;n&#93;
5858 ** byte has a value of zero.
5859 ** This option gives the same output as SQLITE_UTF8, but can be more efficient
@@ -6101,30 +6112,26 @@
6101 **
6102 ** These routines must be called from the same thread as
6103 ** the SQL function that supplied the [sqlite3_value*] parameters.
6104 **
6105 ** As long as the input parameter is correct, these routines can only
6106 ** fail if an out-of-memory error occurs during a format conversion.
6107 ** Only the following subset of interfaces are subject to out-of-memory
6108 ** errors:
6109 **
6110 ** <ul>
6111 ** <li> sqlite3_value_blob()
6112 ** <li> sqlite3_value_text()
6113 ** <li> sqlite3_value_text16()
6114 ** <li> sqlite3_value_text16le()
6115 ** <li> sqlite3_value_text16be()
6116 ** <li> sqlite3_value_bytes()
6117 ** <li> sqlite3_value_bytes16()
6118 ** </ul>
6119 **
6120 ** If an out-of-memory error occurs, then the return value from these
6121 ** routines is the same as if the column had contained an SQL NULL value.
6122 ** Valid SQL NULL returns can be distinguished from out-of-memory errors
6123 ** by invoking the [sqlite3_errcode()] immediately after the suspect
 
 
6124 ** return value is obtained and before any
6125 ** other SQLite interface is called on the same [database connection].
 
 
 
 
 
 
6126 */
6127 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
6128 SQLITE_API double sqlite3_value_double(sqlite3_value*);
6129 SQLITE_API int sqlite3_value_int(sqlite3_value*);
6130 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -6147,11 +6154,12 @@
6147 ** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
6148 ** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding
6149 ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
6150 ** returns something other than SQLITE_TEXT, then the return value from
6151 ** sqlite3_value_encoding(X) is meaningless. ^Calls to
6152 ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)], [sqlite3_value_text16be(X)],
 
6153 ** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
6154 ** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
6155 ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
6156 **
6157 ** This routine is intended for used by applications that test and validate
@@ -6278,21 +6286,21 @@
6278 ** associate auxiliary data with argument values. If the same argument
6279 ** value is passed to multiple invocations of the same SQL function during
6280 ** query execution, under some circumstances the associated auxiliary data
6281 ** might be preserved. An example of where this might be useful is in a
6282 ** regular-expression matching function. The compiled version of the regular
6283 ** expression can be stored as auxiliary data associated with the pattern string.
6284 ** Then as long as the pattern string remains the same,
6285 ** the compiled regular expression can be reused on multiple
6286 ** invocations of the same function.
6287 **
6288 ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
6289 ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
6290 ** value to the application-defined function. ^N is zero for the left-most
6291 ** function argument. ^If there is no auxiliary data
6292 ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
6293 ** returns a NULL pointer.
6294 **
6295 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6296 ** N-th argument of the application-defined function. ^Subsequent
6297 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
6298 ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
@@ -10401,21 +10409,22 @@
10401 **
10402 ** <table border=1 cellspacing=0 cellpadding=10 width="90%">
10403 ** <tr>
10404 ** <td valign="top">sqlite3_vtab_distinct() return value
10405 ** <td valign="top">Rows are returned in aOrderBy order
10406 ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
 
10407 ** <td valign="top">Duplicates over all colUsed columns may be omitted
10408 ** <tr><td>0<td>yes<td>yes<td>no
10409 ** <tr><td>1<td>no<td>yes<td>no
10410 ** <tr><td>2<td>no<td>yes<td>yes
10411 ** <tr><td>3<td>yes<td>yes<td>yes
10412 ** </table>
10413 **
10414 ** ^For the purposes of comparing virtual table output values to see if the
10415 ** values are the same value for sorting purposes, two NULL values are considered
10416 ** to be the same. In other words, the comparison operator is "IS"
10417 ** (or "IS NOT DISTINCT FROM") and not "==".
10418 **
10419 ** If a virtual table implementation is unable to meet the requirements
10420 ** specified above, then it must not set the "orderByConsumed" flag in the
10421 ** [sqlite3_index_info] object or an incorrect answer may result.
@@ -11265,16 +11274,17 @@
11265 /*
11266 ** CAPI3REF: Bind array values to the CARRAY table-valued function
11267 **
11268 ** The sqlite3_carray_bind_v2(S,I,P,N,F,X,D) interface binds an array value to
11269 ** parameter that is the first argument of the [carray() table-valued function].
11270 ** The S parameter is a pointer to the [prepared statement] that uses the carray()
11271 ** functions. I is the parameter index to be bound. I must be the index of the
11272 ** parameter that is the first argument to the carray() table-valued function.
11273 ** P is a pointer to the array to be bound, and N is the number of elements in
11274 ** the array. The F argument is one of constants [SQLITE_CARRAY_INT32],
11275 ** [SQLITE_CARRAY_INT64], [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT],
 
11276 ** or [SQLITE_CARRAY_BLOB] to indicate the datatype of the array P.
11277 **
11278 ** If the X argument is not a NULL pointer or one of the special
11279 ** values [SQLITE_STATIC] or [SQLITE_TRANSIENT], then SQLite will invoke
11280 ** the function X with argument D when it is finished using the data in P.
@@ -13327,10 +13337,236 @@
13327
13328 /*
13329 ** CAPI3REF: Values for sqlite3session_config().
13330 */
13331 #define SQLITE_SESSION_CONFIG_STRMSIZE 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13332
13333 /*
13334 ** Make sure we can call this stuff from C++.
13335 */
13336 #ifdef __cplusplus
13337
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.53.0"
150 #define SQLITE_VERSION_NUMBER 3053000
151 #define SQLITE_SOURCE_ID "2026-04-01 11:54:20 7bc1d0c4572f126cfe68fa51fe992d2bd46b1e57c04721991bd5fad36dd795c5"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-04-01T11:54:20.065Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -576,11 +576,11 @@
576 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
577 #define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
578 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
579 #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
580 #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
581 #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal only */
582
583 /*
584 ** CAPI3REF: Flags For File Open Operations
585 **
586 ** These bit values are intended for use in the
@@ -1288,10 +1288,16 @@
1288 /* deprecated names */
1289 #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
1290 #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
1291 #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
1292
1293 /* reserved file-control numbers:
1294 ** 101
1295 ** 102
1296 ** 103
1297 */
1298
1299
1300 /*
1301 ** CAPI3REF: Mutex Handle
1302 **
1303 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
@@ -1709,11 +1715,12 @@
1715 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1716 ** The exceptional configuration options that may be invoked at any time
1717 ** are called "anytime configuration options".
1718 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1719 ** [sqlite3_shutdown()] with a first argument that is not an anytime
1720 ** configuration option, then the sqlite3_config() call will
1721 ** return SQLITE_MISUSE.
1722 ** Note, however, that ^sqlite3_config() can be called as part of the
1723 ** implementation of an application-defined [sqlite3_os_init()].
1724 **
1725 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1726 ** ^If the option is unknown or SQLite is unable to set the option
@@ -2275,13 +2282,14 @@
2282 ** <li><P>The second argument ("sz") is the
2283 ** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2284 ** is less than 8. The "sz" argument should be a multiple of 8 less than
2285 ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2286 ** it does.
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"
2291 ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2292 ** than 1,000,000.
2293 ** </ol>
2294 ** <p>If the "buf" argument is not NULL, then it must
2295 ** point to a memory buffer with a size that is greater than
@@ -2656,11 +2664,11 @@
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 **
@@ -2668,14 +2676,16 @@
2676 **
2677 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2678 **
2679 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2680 ** overall call to [sqlite3_db_config()] has a total of four parameters.
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
2687 ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2688 ** If the second argument is not NULL, then a value of 0 or 1 is written into
2689 ** the integer to which the second argument points, depending on whether the
2690 ** setting is disabled or enabled after applying any changes specified by
2691 ** the first argument.
@@ -5848,12 +5858,13 @@
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
@@ -6101,30 +6112,26 @@
6112 **
6113 ** These routines must be called from the same thread as
6114 ** the SQL function that supplied the [sqlite3_value*] parameters.
6115 **
6116 ** As long as the input parameter is correct, these routines can only
6117 ** fail if an out-of-memory error occurs while trying to do a
6118 ** UTF8&rarr;UTF16 or UTF16&rarr;UTF8 conversion.
 
 
 
 
 
 
 
 
 
 
 
 
6119 ** If an out-of-memory error occurs, then the return value from these
6120 ** routines is the same as if the column had contained an SQL NULL value.
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
6125 ** return value is obtained and before any
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.
6133 */
6134 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
6135 SQLITE_API double sqlite3_value_double(sqlite3_value*);
6136 SQLITE_API int sqlite3_value_int(sqlite3_value*);
6137 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
@@ -6147,11 +6154,12 @@
6154 ** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
6155 ** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current text encoding
6156 ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
6157 ** returns something other than SQLITE_TEXT, then the return value from
6158 ** sqlite3_value_encoding(X) is meaningless. ^Calls to
6159 ** [sqlite3_value_text(X)], [sqlite3_value_text16(X)],
6160 ** [sqlite3_value_text16be(X)],
6161 ** [sqlite3_value_text16le(X)], [sqlite3_value_bytes(X)], or
6162 ** [sqlite3_value_bytes16(X)] might change the encoding of the value X and
6163 ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
6164 **
6165 ** This routine is intended for used by applications that test and validate
@@ -6278,21 +6286,21 @@
6286 ** associate auxiliary data with argument values. If the same argument
6287 ** value is passed to multiple invocations of the same SQL function during
6288 ** query execution, under some circumstances the associated auxiliary data
6289 ** might be preserved. An example of where this might be useful is in a
6290 ** regular-expression matching function. The compiled version of the regular
6291 ** expression can be stored as auxiliary data associated with the pattern
6292 ** string. Then as long as the pattern string remains the same,
6293 ** the compiled regular expression can be reused on multiple
6294 ** invocations of the same function.
6295 **
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.
6302 **
6303 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
6304 ** N-th argument of the application-defined function. ^Subsequent
6305 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
6306 ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
@@ -10401,21 +10409,22 @@
10409 **
10410 ** <table border=1 cellspacing=0 cellpadding=10 width="90%">
10411 ** <tr>
10412 ** <td valign="top">sqlite3_vtab_distinct() return value
10413 ** <td valign="top">Rows are returned in aOrderBy order
10414 ** <td valign="top">Rows with the same value in all aOrderBy columns are
10415 ** adjacent
10416 ** <td valign="top">Duplicates over all colUsed columns may be omitted
10417 ** <tr><td>0<td>yes<td>yes<td>no
10418 ** <tr><td>1<td>no<td>yes<td>no
10419 ** <tr><td>2<td>no<td>yes<td>yes
10420 ** <tr><td>3<td>yes<td>yes<td>yes
10421 ** </table>
10422 **
10423 ** ^For the purposes of comparing virtual table output values to see if the
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"
10426 ** (or "IS NOT DISTINCT FROM") and not "==".
10427 **
10428 ** If a virtual table implementation is unable to meet the requirements
10429 ** specified above, then it must not set the "orderByConsumed" flag in the
10430 ** [sqlite3_index_info] object or an incorrect answer may result.
@@ -11265,16 +11274,17 @@
11274 /*
11275 ** CAPI3REF: Bind array values to the CARRAY table-valued function
11276 **
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.
@@ -13327,10 +13337,236 @@
13337
13338 /*
13339 ** CAPI3REF: Values for sqlite3session_config().
13340 */
13341 #define SQLITE_SESSION_CONFIG_STRMSIZE 1
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
13569 /*
13570 ** Make sure we can call this stuff from C++.
13571 */
13572 #ifdef __cplusplus
13573

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button