@@ -149,9 +149,9 @@ extern "C" {
149
149
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
150
150
** [sqlite_version()] and [sqlite_source_id()].
151
151
*/
152
- #define SQLITE_VERSION "3.44.0 "
153
- #define SQLITE_VERSION_NUMBER 3044000
154
- #define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad8alt1 "
152
+ #define SQLITE_VERSION "3.45.1 "
153
+ #define SQLITE_VERSION_NUMBER 3045001
154
+ #define SQLITE_SOURCE_ID "2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1 "
155
155
156
156
#define LIBSQL_VERSION "0.2.3"
157
157
@@ -4015,15 +4015,17 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
4015
4015
** </ul>
4016
4016
**
4017
4017
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
4018
- ** text that describes the error, as either UTF-8 or UTF-16 respectively.
4018
+ ** text that describes the error, as either UTF-8 or UTF-16 respectively,
4019
+ ** or NULL if no error message is available.
4019
4020
** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
4020
4021
** ^(Memory to hold the error message string is managed internally.
4021
4022
** The application does not need to worry about freeing the result.
4022
4023
** However, the error string might be overwritten or deallocated by
4023
4024
** subsequent calls to other SQLite interface functions.)^
4024
4025
**
4025
- ** ^The sqlite3_errstr() interface returns the English-language text
4026
- ** that describes the [result code], as UTF-8.
4026
+ ** ^The sqlite3_errstr(E) interface returns the English-language text
4027
+ ** that describes the [result code] E, as UTF-8, or NULL if E is not an
4028
+ ** result code for which a text error message is available.
4027
4029
** ^(Memory to hold the error message string is managed internally
4028
4030
** and must not be freed by the application)^.
4029
4031
**
@@ -5634,20 +5636,35 @@ SQLITE_API int sqlite3_create_window_function(
5634
5636
** </dd>
5635
5637
**
5636
5638
** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd>
5637
- ** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call
5639
+ ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
5638
5640
** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
5639
- ** Specifying this flag makes no difference for scalar or aggregate user
5640
- ** functions. However, if it is not specified for a user-defined window
5641
- ** function, then any sub-types belonging to arguments passed to the window
5642
- ** function may be discarded before the window function is called (i.e.
5643
- ** sqlite3_value_subtype() will always return 0).
5641
+ ** This flag instructs SQLite to omit some corner-case optimizations that
5642
+ ** might disrupt the operation of the [sqlite3_value_subtype()] function,
5643
+ ** causing it to return zero rather than the correct subtype().
5644
+ ** SQL functions that invokes [sqlite3_value_subtype()] should have this
5645
+ ** property. If the SQLITE_SUBTYPE property is omitted, then the return
5646
+ ** value from [sqlite3_value_subtype()] might sometimes be zero even though
5647
+ ** a non-zero subtype was specified by the function argument expression.
5648
+ **
5649
+ ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
5650
+ ** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call
5651
+ ** [sqlite3_result_subtype()] to cause a sub-type to be associated with its
5652
+ ** result.
5653
+ ** Every function that invokes [sqlite3_result_subtype()] should have this
5654
+ ** property. If it does not, then the call to [sqlite3_result_subtype()]
5655
+ ** might become a no-op if the function is used as term in an
5656
+ ** [expression index]. On the other hand, SQL functions that never invoke
5657
+ ** [sqlite3_result_subtype()] should avoid setting this property, as the
5658
+ ** purpose of this property is to disable certain optimizations that are
5659
+ ** incompatible with subtypes.
5644
5660
** </dd>
5645
5661
** </dl>
5646
5662
*/
5647
5663
#define SQLITE_DETERMINISTIC 0x000000800
5648
5664
#define SQLITE_DIRECTONLY 0x000080000
5649
5665
#define SQLITE_SUBTYPE 0x000100000
5650
5666
#define SQLITE_INNOCUOUS 0x000200000
5667
+ #define SQLITE_RESULT_SUBTYPE 0x001000000
5651
5668
5652
5669
/*
5653
5670
** CAPI3REF: Deprecated Functions
@@ -5844,6 +5861,12 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
5844
5861
** information can be used to pass a limited amount of context from
5845
5862
** one SQL function to another. Use the [sqlite3_result_subtype()]
5846
5863
** routine to set the subtype for the return value of an SQL function.
5864
+ **
5865
+ ** Every [application-defined SQL function] that invoke this interface
5866
+ ** should include the [SQLITE_SUBTYPE] property in the text
5867
+ ** encoding argument when the function is [sqlite3_create_function|registered].
5868
+ ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
5869
+ ** might return zero instead of the upstream subtype in some corner cases.
5847
5870
*/
5848
5871
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
5849
5872
@@ -5974,14 +5997,22 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
5974
5997
** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
5975
5998
** parameter)^, or
5976
5999
** <li> ^(during the original sqlite3_set_auxdata() call when a memory
5977
- ** allocation error occurs.)^ </ul>
6000
+ ** allocation error occurs.)^
6001
+ ** <li> ^(during the original sqlite3_set_auxdata() call if the function
6002
+ ** is evaluated during query planning instead of during query execution,
6003
+ ** as sometimes happens with [SQLITE_ENABLE_STAT4].)^ </ul>
5978
6004
**
5979
- ** Note the last bullet in particular. The destructor X in
6005
+ ** Note the last two bullets in particular. The destructor X in
5980
6006
** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
5981
6007
** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
5982
6008
** should be called near the end of the function implementation and the
5983
6009
** function implementation should not make any use of P after
5984
- ** sqlite3_set_auxdata() has been called.
6010
+ ** sqlite3_set_auxdata() has been called. Furthermore, a call to
6011
+ ** sqlite3_get_auxdata() that occurs immediately after a corresponding call
6012
+ ** to sqlite3_set_auxdata() might still return NULL if an out-of-memory
6013
+ ** condition occurred during the sqlite3_set_auxdata() call or if the
6014
+ ** function is being evaluated during query planning rather than during
6015
+ ** query execution.
5985
6016
**
5986
6017
** ^(In practice, auxiliary data is preserved between function calls for
5987
6018
** function parameters that are compile-time constants, including literal
@@ -6255,6 +6286,20 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
6255
6286
** higher order bits are discarded.
6256
6287
** The number of subtype bytes preserved by SQLite might increase
6257
6288
** in future releases of SQLite.
6289
+ **
6290
+ ** Every [application-defined SQL function] that invokes this interface
6291
+ ** should include the [SQLITE_RESULT_SUBTYPE] property in its
6292
+ ** text encoding argument when the SQL function is
6293
+ ** [sqlite3_create_function|registered]. If the [SQLITE_RESULT_SUBTYPE]
6294
+ ** property is omitted from the function that invokes sqlite3_result_subtype(),
6295
+ ** then in some cases the sqlite3_result_subtype() might fail to set
6296
+ ** the result subtype.
6297
+ **
6298
+ ** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any
6299
+ ** SQL function that invokes the sqlite3_result_subtype() interface
6300
+ ** and that does not have the SQLITE_RESULT_SUBTYPE property will raise
6301
+ ** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1
6302
+ ** by default.
6258
6303
*/
6259
6304
SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);
6260
6305
@@ -8082,9 +8127,11 @@ typedef struct libsql_wal_methods libsql_wal_methods;
8082
8127
**
8083
8128
** ^(Some systems (for example, Windows 95) do not support the operation
8084
8129
** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
8085
- ** will always return SQLITE_BUSY. The SQLite core only ever uses
8086
- ** sqlite3_mutex_try() as an optimization so this is acceptable
8087
- ** behavior.)^
8130
+ ** will always return SQLITE_BUSY. In most cases the SQLite core only uses
8131
+ ** sqlite3_mutex_try() as an optimization, so this is acceptable
8132
+ ** behavior. The exceptions are unix builds that set the
8133
+ ** SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working
8134
+ ** sqlite3_mutex_try() is required.)^
8088
8135
**
8089
8136
** ^The sqlite3_mutex_leave() routine exits a mutex that was
8090
8137
** previously entered by the same thread. The behavior
@@ -8343,6 +8390,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8343
8390
#define SQLITE_TESTCTRL_ASSERT 12
8344
8391
#define SQLITE_TESTCTRL_ALWAYS 13
8345
8392
#define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */
8393
+ #define SQLITE_TESTCTRL_JSON_SELFCHECK 14
8346
8394
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
8347
8395
#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
8348
8396
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
@@ -12889,8 +12937,11 @@ struct Fts5PhraseIter {
12889
12937
** created with the "columnsize=0" option.
12890
12938
**
12891
12939
** xColumnText:
12892
- ** This function attempts to retrieve the text of column iCol of the
12893
- ** current document. If successful, (*pz) is set to point to a buffer
12940
+ ** If parameter iCol is less than zero, or greater than or equal to the
12941
+ ** number of columns in the table, SQLITE_RANGE is returned.
12942
+ **
12943
+ ** Otherwise, this function attempts to retrieve the text of column iCol of
12944
+ ** the current document. If successful, (*pz) is set to point to a buffer
12894
12945
** containing the text in utf-8 encoding, (*pn) is set to the size in bytes
12895
12946
** (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
12896
12947
** if an error occurs, an SQLite error code is returned and the final values
@@ -12900,8 +12951,10 @@ struct Fts5PhraseIter {
12900
12951
** Returns the number of phrases in the current query expression.
12901
12952
**
12902
12953
** xPhraseSize:
12903
- ** Returns the number of tokens in phrase iPhrase of the query. Phrases
12904
- ** are numbered starting from zero.
12954
+ ** If parameter iCol is less than zero, or greater than or equal to the
12955
+ ** number of phrases in the current query, as returned by xPhraseCount,
12956
+ ** 0 is returned. Otherwise, this function returns the number of tokens in
12957
+ ** phrase iPhrase of the query. Phrases are numbered starting from zero.
12905
12958
**
12906
12959
** xInstCount:
12907
12960
** Set *pnInst to the total number of occurrences of all phrases within
@@ -12917,12 +12970,13 @@ struct Fts5PhraseIter {
12917
12970
** Query for the details of phrase match iIdx within the current row.
12918
12971
** Phrase matches are numbered starting from zero, so the iIdx argument
12919
12972
** should be greater than or equal to zero and smaller than the value
12920
- ** output by xInstCount().
12973
+ ** output by xInstCount(). If iIdx is less than zero or greater than
12974
+ ** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned.
12921
12975
**
12922
- ** Usually , output parameter *piPhrase is set to the phrase number, *piCol
12976
+ ** Otherwise , output parameter *piPhrase is set to the phrase number, *piCol
12923
12977
** to the column in which it occurs and *piOff the token offset of the
12924
- ** first token of the phrase. Returns SQLITE_OK if successful, or an error
12925
- ** code (i.e. SQLITE_NOMEM) if an error occurs.
12978
+ ** first token of the phrase. SQLITE_OK is returned if successful, or an
12979
+ ** error code (i.e. SQLITE_NOMEM) if an error occurs.
12926
12980
**
12927
12981
** This API can be quite slow if used with an FTS5 table created with the
12928
12982
** "detail=none" or "detail=column" option.
@@ -12948,6 +13002,10 @@ struct Fts5PhraseIter {
12948
13002
** Invoking Api.xUserData() returns a copy of the pointer passed as
12949
13003
** the third argument to pUserData.
12950
13004
**
13005
+ ** If parameter iPhrase is less than zero, or greater than or equal to
13006
+ ** the number of phrases in the query, as returned by xPhraseCount(),
13007
+ ** this function returns SQLITE_RANGE.
13008
+ **
12951
13009
** If the callback function returns any value other than SQLITE_OK, the
12952
13010
** query is abandoned and the xQueryPhrase function returns immediately.
12953
13011
** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
@@ -13062,9 +13120,42 @@ struct Fts5PhraseIter {
13062
13120
**
13063
13121
** xPhraseNextColumn()
13064
13122
** See xPhraseFirstColumn above.
13123
+ **
13124
+ ** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken)
13125
+ ** This is used to access token iToken of phrase iPhrase of the current
13126
+ ** query. Before returning, output parameter *ppToken is set to point
13127
+ ** to a buffer containing the requested token, and *pnToken to the
13128
+ ** size of this buffer in bytes.
13129
+ **
13130
+ ** If iPhrase or iToken are less than zero, or if iPhrase is greater than
13131
+ ** or equal to the number of phrases in the query as reported by
13132
+ ** xPhraseCount(), or if iToken is equal to or greater than the number of
13133
+ ** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken
13134
+ are both zeroed.
13135
+ **
13136
+ ** The output text is not a copy of the query text that specified the
13137
+ ** token. It is the output of the tokenizer module. For tokendata=1
13138
+ ** tables, this includes any embedded 0x00 and trailing data.
13139
+ **
13140
+ ** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken)
13141
+ ** This is used to access token iToken of phrase hit iIdx within the
13142
+ ** current row. If iIdx is less than zero or greater than or equal to the
13143
+ ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise,
13144
+ ** output variable (*ppToken) is set to point to a buffer containing the
13145
+ ** matching document token, and (*pnToken) to the size of that buffer in
13146
+ ** bytes. This API is not available if the specified token matches a
13147
+ ** prefix query term. In that case both output variables are always set
13148
+ ** to 0.
13149
+ **
13150
+ ** The output text is not a copy of the document text that was tokenized.
13151
+ ** It is the output of the tokenizer module. For tokendata=1 tables, this
13152
+ ** includes any embedded 0x00 and trailing data.
13153
+ **
13154
+ ** This API can be quite slow if used with an FTS5 table created with the
13155
+ ** "detail=none" or "detail=column" option.
13065
13156
*/
13066
13157
struct Fts5ExtensionApi {
13067
- int iVersion; /* Currently always set to 2 */
13158
+ int iVersion; /* Currently always set to 3 */
13068
13159
13069
13160
void *(*xUserData)(Fts5Context*);
13070
13161
@@ -13099,6 +13190,13 @@ struct Fts5ExtensionApi {
13099
13190
13100
13191
int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
13101
13192
void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
13193
+
13194
+ /* Below this point are iVersion>=3 only */
13195
+ int (*xQueryToken)(Fts5Context*,
13196
+ int iPhrase, int iToken,
13197
+ const char **ppToken, int *pnToken
13198
+ );
13199
+ int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*);
13102
13200
};
13103
13201
13104
13202
/*
0 commit comments