@@ -146,9 +146,9 @@ extern "C" {
146
146
** [sqlite_nio_sqlite3_libversion_number()], [sqlite_nio_sqlite3_sourceid()],
147
147
** [sqlite_version()] and [sqlite_source_id()].
148
148
*/
149
- #define SQLITE_VERSION "3.46.1 "
150
- #define SQLITE_VERSION_NUMBER 3046001
151
- #define SQLITE_SOURCE_ID "2024-08-13 09: 16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33 "
149
+ #define SQLITE_VERSION "3.47.0 "
150
+ #define SQLITE_VERSION_NUMBER 3047000
151
+ #define SQLITE_SOURCE_ID "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e "
152
152
153
153
/*
154
154
** CAPI3REF: Run-Time Library Version Numbers
@@ -772,8 +772,8 @@ struct sqlite3_file {
772
772
** to xUnlock() is a no-op.
773
773
** The xCheckReservedLock() method checks whether any database connection,
774
774
** either in this process or in some other process, is holding a RESERVED,
775
- ** PENDING, or EXCLUSIVE lock on the file. It returns true
776
- ** if such a lock exists and false otherwise.
775
+ ** PENDING, or EXCLUSIVE lock on the file. It returns, via its output
776
+ ** pointer parameter, true if such a lock exists and false otherwise.
777
777
**
778
778
** The xFileControl() method is a generic interface that allows custom
779
779
** VFS implementations to directly control an open file using the
@@ -3570,8 +3570,8 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3570
3570
**
3571
3571
** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt>
3572
3572
** <dd>The database connection comes up in "extended result code mode".
3573
- ** In other words, the database behaves has if
3574
- ** [sqlite_nio_sqlite3_extended_result_codes(db,1)] where called on the database
3573
+ ** In other words, the database behaves as if
3574
+ ** [sqlite_nio_sqlite3_extended_result_codes(db,1)] were called on the database
3575
3575
** connection as soon as the connection is created. In addition to setting
3576
3576
** the extended result code mode, this flag also causes [sqlite_nio_sqlite3_open_v2()]
3577
3577
** to return an extended result code.</dd>
@@ -4222,13 +4222,17 @@ SQLITE_API int sqlite_nio_sqlite3_limit(sqlite3*, int id, int newVal);
4222
4222
** and sqlite_nio_sqlite3_prepare16_v3() use UTF-16.
4223
4223
**
4224
4224
** ^If the nByte argument is negative, then zSql is read up to the
4225
- ** first zero terminator. ^If nByte is positive, then it is the
4226
- ** number of bytes read from zSql. ^If nByte is zero, then no prepared
4225
+ ** first zero terminator. ^If nByte is positive, then it is the maximum
4226
+ ** number of bytes read from zSql. When nByte is positive, zSql is read
4227
+ ** up to the first zero terminator or until the nByte bytes have been read,
4228
+ ** whichever comes first. ^If nByte is zero, then no prepared
4227
4229
** statement is generated.
4228
4230
** If the caller knows that the supplied string is nul-terminated, then
4229
4231
** there is a small performance advantage to passing an nByte parameter that
4230
4232
** is the number of bytes in the input string <i>including</i>
4231
4233
** the nul-terminator.
4234
+ ** Note that nByte measure the length of the input in bytes, not
4235
+ ** characters, even for the UTF-16 interfaces.
4232
4236
**
4233
4237
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
4234
4238
** past the end of the first SQL statement in zSql. These routines only
@@ -5599,7 +5603,7 @@ SQLITE_API int sqlite_nio_sqlite3_create_window_function(
5599
5603
** This flag instructs SQLite to omit some corner-case optimizations that
5600
5604
** might disrupt the operation of the [sqlite_nio_sqlite3_value_subtype()] function,
5601
5605
** causing it to return zero rather than the correct subtype().
5602
- ** SQL functions that invokes [sqlite_nio_sqlite3_value_subtype()] should have this
5606
+ ** All SQL functions that invoke [sqlite_nio_sqlite3_value_subtype()] should have this
5603
5607
** property. If the SQLITE_SUBTYPE property is omitted, then the return
5604
5608
** value from [sqlite_nio_sqlite3_value_subtype()] might sometimes be zero even though
5605
5609
** a non-zero subtype was specified by the function argument expression.
@@ -5615,6 +5619,15 @@ SQLITE_API int sqlite_nio_sqlite3_create_window_function(
5615
5619
** [sqlite_nio_sqlite3_result_subtype()] should avoid setting this property, as the
5616
5620
** purpose of this property is to disable certain optimizations that are
5617
5621
** incompatible with subtypes.
5622
+ **
5623
+ ** [[SQLITE_SELFORDER1]] <dt>SQLITE_SELFORDER1</dt><dd>
5624
+ ** The SQLITE_SELFORDER1 flag indicates that the function is an aggregate
5625
+ ** that internally orders the values provided to the first argument. The
5626
+ ** ordered-set aggregate SQL notation with a single ORDER BY term can be
5627
+ ** used to invoke this function. If the ordered-set aggregate notation is
5628
+ ** used on a function that lacks this flag, then an error is raised. Note
5629
+ ** that the ordered-set aggregate syntax is only available if SQLite is
5630
+ ** built using the -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES compile-time option.
5618
5631
** </dd>
5619
5632
** </dl>
5620
5633
*/
@@ -5623,6 +5636,7 @@ SQLITE_API int sqlite_nio_sqlite3_create_window_function(
5623
5636
#define SQLITE_SUBTYPE 0x000100000
5624
5637
#define SQLITE_INNOCUOUS 0x000200000
5625
5638
#define SQLITE_RESULT_SUBTYPE 0x001000000
5639
+ #define SQLITE_SELFORDER1 0x002000000
5626
5640
5627
5641
/*
5628
5642
** CAPI3REF: Deprecated Functions
@@ -5820,7 +5834,7 @@ SQLITE_API int sqlite_nio_sqlite3_value_encoding(sqlite3_value*);
5820
5834
** one SQL function to another. Use the [sqlite_nio_sqlite3_result_subtype()]
5821
5835
** routine to set the subtype for the return value of an SQL function.
5822
5836
**
5823
- ** Every [application-defined SQL function] that invoke this interface
5837
+ ** Every [application-defined SQL function] that invokes this interface
5824
5838
** should include the [SQLITE_SUBTYPE] property in the text
5825
5839
** encoding argument when the function is [sqlite_nio_sqlite3_create_function|registered].
5826
5840
** If the [SQLITE_SUBTYPE] property is omitted, then sqlite_nio_sqlite3_value_subtype()
@@ -7427,9 +7441,11 @@ struct sqlite3_module {
7427
7441
** will be returned by the strategy.
7428
7442
**
7429
7443
** The xBestIndex method may optionally populate the idxFlags field with a
7430
- ** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -
7431
- ** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite
7432
- ** assumes that the strategy may visit at most one row.
7444
+ ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
7445
+ ** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN]
7446
+ ** output to show the idxNum has hex instead of as decimal. Another flag is
7447
+ ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
7448
+ ** return at most one row.
7433
7449
**
7434
7450
** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
7435
7451
** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -7493,7 +7509,9 @@ struct sqlite3_index_info {
7493
7509
** [sqlite3_index_info].idxFlags field to some combination of
7494
7510
** these bits.
7495
7511
*/
7496
- #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */
7512
+ #define SQLITE_INDEX_SCAN_UNIQUE 0x00000001 /* Scan visits at most 1 row */
7513
+ #define SQLITE_INDEX_SCAN_HEX 0x00000002 /* Display idxNum as hex */
7514
+ /* in EXPLAIN QUERY PLAN */
7497
7515
7498
7516
/*
7499
7517
** CAPI3REF: Virtual Table Constraint Operator Codes
@@ -8330,6 +8348,7 @@ SQLITE_API int sqlite_nio_sqlite3_test_control(int op, ...);
8330
8348
#define SQLITE_TESTCTRL_JSON_SELFCHECK 14
8331
8349
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
8332
8350
#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
8351
+ #define SQLITE_TESTCTRL_GETOPT 16
8333
8352
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
8334
8353
#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17
8335
8354
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
@@ -8349,7 +8368,7 @@ SQLITE_API int sqlite_nio_sqlite3_test_control(int op, ...);
8349
8368
#define SQLITE_TESTCTRL_TRACEFLAGS 31
8350
8369
#define SQLITE_TESTCTRL_TUNE 32
8351
8370
#define SQLITE_TESTCTRL_LOGEST 33
8352
- #define SQLITE_TESTCTRL_USELONGDOUBLE 34
8371
+ #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
8353
8372
#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8354
8373
8355
8374
/*
@@ -9325,6 +9344,16 @@ typedef struct sqlite3_backup sqlite3_backup;
9325
9344
** APIs are not strictly speaking threadsafe. If they are invoked at the
9326
9345
** same time as another thread is invoking sqlite_nio_sqlite3_backup_step() it is
9327
9346
** possible that they return invalid values.
9347
+ **
9348
+ ** <b>Alternatives To Using The Backup API</b>
9349
+ **
9350
+ ** Other techniques for safely creating a consistent backup of an SQLite
9351
+ ** database include:
9352
+ **
9353
+ ** <ul>
9354
+ ** <li> The [VACUUM INTO] command.
9355
+ ** <li> The [sqlite3_rsync] utility program.
9356
+ ** </ul>
9328
9357
*/
9329
9358
SQLITE_API sqlite3_backup *sqlite_nio_sqlite3_backup_init(
9330
9359
sqlite3 *pDest, /* Destination database handle */
@@ -10524,6 +10553,14 @@ typedef struct sqlite3_snapshot {
10524
10553
** If there is not already a read-transaction open on schema S when
10525
10554
** this function is called, one is opened automatically.
10526
10555
**
10556
+ ** If a read-transaction is opened by this function, then it is guaranteed
10557
+ ** that the returned snapshot object may not be invalidated by a database
10558
+ ** writer or checkpointer until after the read-transaction is closed. This
10559
+ ** is not guaranteed if a read-transaction is already open when this
10560
+ ** function is called. In that case, any subsequent write or checkpoint
10561
+ ** operation on the database may invalidate the returned snapshot handle,
10562
+ ** even while the read-transaction remains open.
10563
+ **
10527
10564
** The following must be true for this function to succeed. If any of
10528
10565
** the following statements are false when sqlite3_snapshot_get() is
10529
10566
** called, SQLITE_ERROR is returned. The final value of *P is undefined
@@ -10832,8 +10869,6 @@ SQLITE_API int sqlite3_deserialize(
10832
10869
#if defined(__wasi__)
10833
10870
# undef SQLITE_WASI
10834
10871
# define SQLITE_WASI 1
10835
- # undef SQLITE_OMIT_WAL
10836
- # define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
10837
10872
# ifndef SQLITE_OMIT_LOAD_EXTENSION
10838
10873
# define SQLITE_OMIT_LOAD_EXTENSION
10839
10874
# endif
@@ -13036,6 +13071,10 @@ struct Fts5PhraseIter {
13036
13071
** (i.e. if it is a contentless table), then this API always iterates
13037
13072
** through an empty set (all calls to xPhraseFirst() set iCol to -1).
13038
13073
**
13074
+ ** In all cases, matches are visited in (column ASC, offset ASC) order.
13075
+ ** i.e. all those in column 0, sorted by offset, followed by those in
13076
+ ** column 1, etc.
13077
+ **
13039
13078
** xPhraseNext()
13040
13079
** See xPhraseFirst above.
13041
13080
**
@@ -13102,9 +13141,32 @@ struct Fts5PhraseIter {
13102
13141
**
13103
13142
** This API can be quite slow if used with an FTS5 table created with the
13104
13143
** "detail=none" or "detail=column" option.
13144
+ **
13145
+ ** xColumnLocale(pFts5, iIdx, pzLocale, pnLocale)
13146
+ ** If parameter iCol is less than zero, or greater than or equal to the
13147
+ ** number of columns in the table, SQLITE_RANGE is returned.
13148
+ **
13149
+ ** Otherwise, this function attempts to retrieve the locale associated
13150
+ ** with column iCol of the current row. Usually, there is no associated
13151
+ ** locale, and output parameters (*pzLocale) and (*pnLocale) are set
13152
+ ** to NULL and 0, respectively. However, if the fts5_locale() function
13153
+ ** was used to associate a locale with the value when it was inserted
13154
+ ** into the fts5 table, then (*pzLocale) is set to point to a nul-terminated
13155
+ ** buffer containing the name of the locale in utf-8 encoding. (*pnLocale)
13156
+ ** is set to the size in bytes of the buffer, not including the
13157
+ ** nul-terminator.
13158
+ **
13159
+ ** If successful, SQLITE_OK is returned. Or, if an error occurs, an
13160
+ ** SQLite error code is returned. The final value of the output parameters
13161
+ ** is undefined in this case.
13162
+ **
13163
+ ** xTokenize_v2:
13164
+ ** Tokenize text using the tokenizer belonging to the FTS5 table. This
13165
+ ** API is the same as the xTokenize() API, except that it allows a tokenizer
13166
+ ** locale to be specified.
13105
13167
*/
13106
13168
struct Fts5ExtensionApi {
13107
- int iVersion; /* Currently always set to 3 */
13169
+ int iVersion; /* Currently always set to 4 */
13108
13170
13109
13171
void *(*xUserData)(Fts5Context*);
13110
13172
@@ -13146,6 +13208,15 @@ struct Fts5ExtensionApi {
13146
13208
const char **ppToken, int *pnToken
13147
13209
);
13148
13210
int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*);
13211
+
13212
+ /* Below this point are iVersion>=4 only */
13213
+ int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn);
13214
+ int (*xTokenize_v2)(Fts5Context*,
13215
+ const char *pText, int nText, /* Text to tokenize */
13216
+ const char *pLocale, int nLocale, /* Locale to pass to tokenizer */
13217
+ void *pCtx, /* Context passed to xToken() */
13218
+ int (*xToken)(void*, int, const char*, int, int, int) /* Callback */
13219
+ );
13149
13220
};
13150
13221
13151
13222
/*
@@ -13166,7 +13237,7 @@ struct Fts5ExtensionApi {
13166
13237
** A tokenizer instance is required to actually tokenize text.
13167
13238
**
13168
13239
** The first argument passed to this function is a copy of the (void*)
13169
- ** pointer provided by the application when the fts5_tokenizer object
13240
+ ** pointer provided by the application when the fts5_tokenizer_v2 object
13170
13241
** was registered with FTS5 (the third argument to xCreateTokenizer()).
13171
13242
** The second and third arguments are an array of nul-terminated strings
13172
13243
** containing the tokenizer arguments, if any, specified following the
@@ -13190,7 +13261,7 @@ struct Fts5ExtensionApi {
13190
13261
** argument passed to this function is a pointer to an Fts5Tokenizer object
13191
13262
** returned by an earlier call to xCreate().
13192
13263
**
13193
- ** The second argument indicates the reason that FTS5 is requesting
13264
+ ** The third argument indicates the reason that FTS5 is requesting
13194
13265
** tokenization of the supplied text. This is always one of the following
13195
13266
** four values:
13196
13267
**
@@ -13214,6 +13285,13 @@ struct Fts5ExtensionApi {
13214
13285
** on a columnsize=0 database.
13215
13286
** </ul>
13216
13287
**
13288
+ ** The sixth and seventh arguments passed to xTokenize() - pLocale and
13289
+ ** nLocale - are a pointer to a buffer containing the locale to use for
13290
+ ** tokenization (e.g. "en_US") and its size in bytes, respectively. The
13291
+ ** pLocale buffer is not nul-terminated. pLocale may be passed NULL (in
13292
+ ** which case nLocale is always 0) to indicate that the tokenizer should
13293
+ ** use its default locale.
13294
+ **
13217
13295
** For each token in the input string, the supplied callback xToken() must
13218
13296
** be invoked. The first argument to it should be a copy of the pointer
13219
13297
** passed as the second argument to xTokenize(). The third and fourth
@@ -13237,6 +13315,30 @@ struct Fts5ExtensionApi {
13237
13315
** may abandon the tokenization and return any error code other than
13238
13316
** SQLITE_OK or SQLITE_DONE.
13239
13317
**
13318
+ ** If the tokenizer is registered using an fts5_tokenizer_v2 object,
13319
+ ** then the xTokenize() method has two additional arguments - pLocale
13320
+ ** and nLocale. These specify the locale that the tokenizer should use
13321
+ ** for the current request. If pLocale and nLocale are both 0, then the
13322
+ ** tokenizer should use its default locale. Otherwise, pLocale points to
13323
+ ** an nLocale byte buffer containing the name of the locale to use as utf-8
13324
+ ** text. pLocale is not nul-terminated.
13325
+ **
13326
+ ** FTS5_TOKENIZER
13327
+ **
13328
+ ** There is also an fts5_tokenizer object. This is an older, deprecated,
13329
+ ** version of fts5_tokenizer_v2. It is similar except that:
13330
+ **
13331
+ ** <ul>
13332
+ ** <li> There is no "iVersion" field, and
13333
+ ** <li> The xTokenize() method does not take a locale argument.
13334
+ ** </ul>
13335
+ **
13336
+ ** Legacy fts5_tokenizer tokenizers must be registered using the
13337
+ ** legacy xCreateTokenizer() function, instead of xCreateTokenizer_v2().
13338
+ **
13339
+ ** Tokenizer implementations registered using either API may be retrieved
13340
+ ** using both xFindTokenizer() and xFindTokenizer_v2().
13341
+ **
13240
13342
** SYNONYM SUPPORT
13241
13343
**
13242
13344
** Custom tokenizers may also support synonyms. Consider a case in which a
@@ -13345,6 +13447,33 @@ struct Fts5ExtensionApi {
13345
13447
** inefficient.
13346
13448
*/
13347
13449
typedef struct Fts5Tokenizer Fts5Tokenizer;
13450
+ typedef struct fts5_tokenizer_v2 fts5_tokenizer_v2;
13451
+ struct fts5_tokenizer_v2 {
13452
+ int iVersion; /* Currently always 2 */
13453
+
13454
+ int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
13455
+ void (*xDelete)(Fts5Tokenizer*);
13456
+ int (*xTokenize)(Fts5Tokenizer*,
13457
+ void *pCtx,
13458
+ int flags, /* Mask of FTS5_TOKENIZE_* flags */
13459
+ const char *pText, int nText,
13460
+ const char *pLocale, int nLocale,
13461
+ int (*xToken)(
13462
+ void *pCtx, /* Copy of 2nd argument to xTokenize() */
13463
+ int tflags, /* Mask of FTS5_TOKEN_* flags */
13464
+ const char *pToken, /* Pointer to buffer containing token */
13465
+ int nToken, /* Size of token in bytes */
13466
+ int iStart, /* Byte offset of token within input text */
13467
+ int iEnd /* Byte offset of end of token within input text */
13468
+ )
13469
+ );
13470
+ };
13471
+
13472
+ /*
13473
+ ** New code should use the fts5_tokenizer_v2 type to define tokenizer
13474
+ ** implementations. The following type is included for legacy applications
13475
+ ** that still use it.
13476
+ */
13348
13477
typedef struct fts5_tokenizer fts5_tokenizer;
13349
13478
struct fts5_tokenizer {
13350
13479
int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
@@ -13364,6 +13493,7 @@ struct fts5_tokenizer {
13364
13493
);
13365
13494
};
13366
13495
13496
+
13367
13497
/* Flags that may be passed as the third argument to xTokenize() */
13368
13498
#define FTS5_TOKENIZE_QUERY 0x0001
13369
13499
#define FTS5_TOKENIZE_PREFIX 0x0002
@@ -13383,7 +13513,7 @@ struct fts5_tokenizer {
13383
13513
*/
13384
13514
typedef struct fts5_api fts5_api;
13385
13515
struct fts5_api {
13386
- int iVersion; /* Currently always set to 2 */
13516
+ int iVersion; /* Currently always set to 3 */
13387
13517
13388
13518
/* Create a new tokenizer */
13389
13519
int (*xCreateTokenizer)(
@@ -13410,6 +13540,25 @@ struct fts5_api {
13410
13540
fts5_extension_function xFunction,
13411
13541
void (*xDestroy)(void*)
13412
13542
);
13543
+
13544
+ /* APIs below this point are only available if iVersion>=3 */
13545
+
13546
+ /* Create a new tokenizer */
13547
+ int (*xCreateTokenizer_v2)(
13548
+ fts5_api *pApi,
13549
+ const char *zName,
13550
+ void *pUserData,
13551
+ fts5_tokenizer_v2 *pTokenizer,
13552
+ void (*xDestroy)(void*)
13553
+ );
13554
+
13555
+ /* Find an existing tokenizer */
13556
+ int (*xFindTokenizer_v2)(
13557
+ fts5_api *pApi,
13558
+ const char *zName,
13559
+ void **ppUserData,
13560
+ fts5_tokenizer_v2 **ppTokenizer
13561
+ );
13413
13562
};
13414
13563
13415
13564
/*
0 commit comments