@@ -149,9 +149,9 @@ extern "C" {
149149** [sqlite3_libversion_number()], [sqlite3_sourceid()],
150150** [sqlite_version()] and [sqlite_source_id()].
151151*/
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 "
155155
156156#define LIBSQL_VERSION "0.2.3"
157157
@@ -4015,15 +4015,17 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
40154015** </ul>
40164016**
40174017** ^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.
40194020** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
40204021** ^(Memory to hold the error message string is managed internally.
40214022** The application does not need to worry about freeing the result.
40224023** However, the error string might be overwritten or deallocated by
40234024** subsequent calls to other SQLite interface functions.)^
40244025**
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.
40274029** ^(Memory to hold the error message string is managed internally
40284030** and must not be freed by the application)^.
40294031**
@@ -5634,20 +5636,35 @@ SQLITE_API int sqlite3_create_window_function(
56345636** </dd>
56355637**
56365638** [[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
56385640** [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.
56445660** </dd>
56455661** </dl>
56465662*/
56475663#define SQLITE_DETERMINISTIC 0x000000800
56485664#define SQLITE_DIRECTONLY 0x000080000
56495665#define SQLITE_SUBTYPE 0x000100000
56505666#define SQLITE_INNOCUOUS 0x000200000
5667+ #define SQLITE_RESULT_SUBTYPE 0x001000000
56515668
56525669/*
56535670** CAPI3REF: Deprecated Functions
@@ -5844,6 +5861,12 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
58445861** information can be used to pass a limited amount of context from
58455862** one SQL function to another. Use the [sqlite3_result_subtype()]
58465863** 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.
58475870*/
58485871SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
58495872
@@ -5974,14 +5997,22 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
59745997** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
59755998** parameter)^, or
59765999** <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>
59786004**
5979- ** Note the last bullet in particular. The destructor X in
6005+ ** Note the last two bullets in particular. The destructor X in
59806006** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
59816007** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
59826008** should be called near the end of the function implementation and the
59836009** 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.
59856016**
59866017** ^(In practice, auxiliary data is preserved between function calls for
59876018** function parameters that are compile-time constants, including literal
@@ -6255,6 +6286,20 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
62556286** higher order bits are discarded.
62566287** The number of subtype bytes preserved by SQLite might increase
62576288** 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.
62586303*/
62596304SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);
62606305
@@ -8082,9 +8127,11 @@ typedef struct libsql_wal_methods libsql_wal_methods;
80828127**
80838128** ^(Some systems (for example, Windows 95) do not support the operation
80848129** 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.)^
80888135**
80898136** ^The sqlite3_mutex_leave() routine exits a mutex that was
80908137** previously entered by the same thread. The behavior
@@ -8343,6 +8390,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
83438390#define SQLITE_TESTCTRL_ASSERT 12
83448391#define SQLITE_TESTCTRL_ALWAYS 13
83458392#define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */
8393+ #define SQLITE_TESTCTRL_JSON_SELFCHECK 14
83468394#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
83478395#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
83488396#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
@@ -12889,8 +12937,11 @@ struct Fts5PhraseIter {
1288912937** created with the "columnsize=0" option.
1289012938**
1289112939** 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
1289412945** containing the text in utf-8 encoding, (*pn) is set to the size in bytes
1289512946** (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
1289612947** if an error occurs, an SQLite error code is returned and the final values
@@ -12900,8 +12951,10 @@ struct Fts5PhraseIter {
1290012951** Returns the number of phrases in the current query expression.
1290112952**
1290212953** 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.
1290512958**
1290612959** xInstCount:
1290712960** Set *pnInst to the total number of occurrences of all phrases within
@@ -12917,12 +12970,13 @@ struct Fts5PhraseIter {
1291712970** Query for the details of phrase match iIdx within the current row.
1291812971** Phrase matches are numbered starting from zero, so the iIdx argument
1291912972** 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.
1292112975**
12922- ** Usually , output parameter *piPhrase is set to the phrase number, *piCol
12976+ ** Otherwise , output parameter *piPhrase is set to the phrase number, *piCol
1292312977** 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.
1292612980**
1292712981** This API can be quite slow if used with an FTS5 table created with the
1292812982** "detail=none" or "detail=column" option.
@@ -12948,6 +13002,10 @@ struct Fts5PhraseIter {
1294813002** Invoking Api.xUserData() returns a copy of the pointer passed as
1294913003** the third argument to pUserData.
1295013004**
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+ **
1295113009** If the callback function returns any value other than SQLITE_OK, the
1295213010** query is abandoned and the xQueryPhrase function returns immediately.
1295313011** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
@@ -13062,9 +13120,42 @@ struct Fts5PhraseIter {
1306213120**
1306313121** xPhraseNextColumn()
1306413122** 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.
1306513156*/
1306613157struct Fts5ExtensionApi {
13067- int iVersion; /* Currently always set to 2 */
13158+ int iVersion; /* Currently always set to 3 */
1306813159
1306913160 void *(*xUserData)(Fts5Context*);
1307013161
@@ -13099,6 +13190,13 @@ struct Fts5ExtensionApi {
1309913190
1310013191 int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
1310113192 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*);
1310213200};
1310313201
1310413202/*
0 commit comments