@@ -146,9 +146,9 @@ extern "C" {
146146** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147** [sqlite_version()] and [sqlite_source_id()].
148148*/
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 "
152152
153153/*
154154** CAPI3REF: Run-Time Library Version Numbers
@@ -772,8 +772,8 @@ struct sqlite3_file {
772772** to xUnlock() is a no-op.
773773** The xCheckReservedLock() method checks whether any database connection,
774774** 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.
777777**
778778** The xFileControl() method is a generic interface that allows custom
779779** 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*);
35703570**
35713571** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt>
35723572** <dd>The database connection comes up in "extended result code mode".
3573- ** In other words, the database behaves has if
3574- ** [sqlite3_extended_result_codes(db,1)] where called on the database
3573+ ** In other words, the database behaves as if
3574+ ** [sqlite3_extended_result_codes(db,1)] were called on the database
35753575** connection as soon as the connection is created. In addition to setting
35763576** the extended result code mode, this flag also causes [sqlite3_open_v2()]
35773577** to return an extended result code.</dd>
@@ -4222,13 +4222,17 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
42224222** and sqlite3_prepare16_v3() use UTF-16.
42234223**
42244224** ^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
42274229** statement is generated.
42284230** If the caller knows that the supplied string is nul-terminated, then
42294231** there is a small performance advantage to passing an nByte parameter that
42304232** is the number of bytes in the input string <i>including</i>
42314233** the nul-terminator.
4234+ ** Note that nByte measure the length of the input in bytes, not
4235+ ** characters, even for the UTF-16 interfaces.
42324236**
42334237** ^If pzTail is not NULL then *pzTail is made to point to the first byte
42344238** past the end of the first SQL statement in zSql. These routines only
@@ -5599,7 +5603,7 @@ SQLITE_API int sqlite3_create_window_function(
55995603** This flag instructs SQLite to omit some corner-case optimizations that
56005604** might disrupt the operation of the [sqlite3_value_subtype()] function,
56015605** causing it to return zero rather than the correct subtype().
5602- ** SQL functions that invokes [sqlite3_value_subtype()] should have this
5606+ ** All SQL functions that invoke [sqlite3_value_subtype()] should have this
56035607** property. If the SQLITE_SUBTYPE property is omitted, then the return
56045608** value from [sqlite3_value_subtype()] might sometimes be zero even though
56055609** a non-zero subtype was specified by the function argument expression.
@@ -5615,6 +5619,15 @@ SQLITE_API int sqlite3_create_window_function(
56155619** [sqlite3_result_subtype()] should avoid setting this property, as the
56165620** purpose of this property is to disable certain optimizations that are
56175621** 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.
56185631** </dd>
56195632** </dl>
56205633*/
@@ -5623,6 +5636,7 @@ SQLITE_API int sqlite3_create_window_function(
56235636#define SQLITE_SUBTYPE 0x000100000
56245637#define SQLITE_INNOCUOUS 0x000200000
56255638#define SQLITE_RESULT_SUBTYPE 0x001000000
5639+ #define SQLITE_SELFORDER1 0x002000000
56265640
56275641/*
56285642** CAPI3REF: Deprecated Functions
@@ -5820,7 +5834,7 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
58205834** one SQL function to another. Use the [sqlite3_result_subtype()]
58215835** routine to set the subtype for the return value of an SQL function.
58225836**
5823- ** Every [application-defined SQL function] that invoke this interface
5837+ ** Every [application-defined SQL function] that invokes this interface
58245838** should include the [SQLITE_SUBTYPE] property in the text
58255839** encoding argument when the function is [sqlite3_create_function|registered].
58265840** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
@@ -7427,9 +7441,11 @@ struct sqlite3_module {
74277441** will be returned by the strategy.
74287442**
74297443** 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.
74337449**
74347450** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
74357451** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -7493,7 +7509,9 @@ struct sqlite3_index_info {
74937509** [sqlite3_index_info].idxFlags field to some combination of
74947510** these bits.
74957511*/
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 */
74977515
74987516/*
74997517** CAPI3REF: Virtual Table Constraint Operator Codes
@@ -8330,6 +8348,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
83308348#define SQLITE_TESTCTRL_JSON_SELFCHECK 14
83318349#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
83328350#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
8351+ #define SQLITE_TESTCTRL_GETOPT 16
83338352#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
83348353#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17
83358354#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
@@ -8349,7 +8368,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
83498368#define SQLITE_TESTCTRL_TRACEFLAGS 31
83508369#define SQLITE_TESTCTRL_TUNE 32
83518370#define SQLITE_TESTCTRL_LOGEST 33
8352- #define SQLITE_TESTCTRL_USELONGDOUBLE 34
8371+ #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
83538372#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
83548373
83558374/*
@@ -9325,6 +9344,16 @@ typedef struct sqlite3_backup sqlite3_backup;
93259344** APIs are not strictly speaking threadsafe. If they are invoked at the
93269345** same time as another thread is invoking sqlite3_backup_step() it is
93279346** 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>
93289357*/
93299358SQLITE_API sqlite3_backup *sqlite3_backup_init(
93309359 sqlite3 *pDest, /* Destination database handle */
@@ -10524,6 +10553,14 @@ typedef struct sqlite3_snapshot {
1052410553** If there is not already a read-transaction open on schema S when
1052510554** this function is called, one is opened automatically.
1052610555**
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+ **
1052710564** The following must be true for this function to succeed. If any of
1052810565** the following statements are false when sqlite3_snapshot_get() is
1052910566** called, SQLITE_ERROR is returned. The final value of *P is undefined
@@ -10832,8 +10869,6 @@ SQLITE_API int sqlite3_deserialize(
1083210869#if defined(__wasi__)
1083310870# undef SQLITE_WASI
1083410871# define SQLITE_WASI 1
10835- # undef SQLITE_OMIT_WAL
10836- # define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
1083710872# ifndef SQLITE_OMIT_LOAD_EXTENSION
1083810873# define SQLITE_OMIT_LOAD_EXTENSION
1083910874# endif
@@ -13036,6 +13071,10 @@ struct Fts5PhraseIter {
1303613071** (i.e. if it is a contentless table), then this API always iterates
1303713072** through an empty set (all calls to xPhraseFirst() set iCol to -1).
1303813073**
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+ **
1303913078** xPhraseNext()
1304013079** See xPhraseFirst above.
1304113080**
@@ -13102,9 +13141,32 @@ struct Fts5PhraseIter {
1310213141**
1310313142** This API can be quite slow if used with an FTS5 table created with the
1310413143** "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.
1310513167*/
1310613168struct Fts5ExtensionApi {
13107- int iVersion; /* Currently always set to 3 */
13169+ int iVersion; /* Currently always set to 4 */
1310813170
1310913171 void *(*xUserData)(Fts5Context*);
1311013172
@@ -13146,6 +13208,15 @@ struct Fts5ExtensionApi {
1314613208 const char **ppToken, int *pnToken
1314713209 );
1314813210 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+ );
1314913220};
1315013221
1315113222/*
@@ -13166,7 +13237,7 @@ struct Fts5ExtensionApi {
1316613237** A tokenizer instance is required to actually tokenize text.
1316713238**
1316813239** 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
1317013241** was registered with FTS5 (the third argument to xCreateTokenizer()).
1317113242** The second and third arguments are an array of nul-terminated strings
1317213243** containing the tokenizer arguments, if any, specified following the
@@ -13190,7 +13261,7 @@ struct Fts5ExtensionApi {
1319013261** argument passed to this function is a pointer to an Fts5Tokenizer object
1319113262** returned by an earlier call to xCreate().
1319213263**
13193- ** The second argument indicates the reason that FTS5 is requesting
13264+ ** The third argument indicates the reason that FTS5 is requesting
1319413265** tokenization of the supplied text. This is always one of the following
1319513266** four values:
1319613267**
@@ -13214,6 +13285,13 @@ struct Fts5ExtensionApi {
1321413285** on a columnsize=0 database.
1321513286** </ul>
1321613287**
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+ **
1321713295** For each token in the input string, the supplied callback xToken() must
1321813296** be invoked. The first argument to it should be a copy of the pointer
1321913297** passed as the second argument to xTokenize(). The third and fourth
@@ -13237,6 +13315,30 @@ struct Fts5ExtensionApi {
1323713315** may abandon the tokenization and return any error code other than
1323813316** SQLITE_OK or SQLITE_DONE.
1323913317**
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+ **
1324013342** SYNONYM SUPPORT
1324113343**
1324213344** Custom tokenizers may also support synonyms. Consider a case in which a
@@ -13345,6 +13447,33 @@ struct Fts5ExtensionApi {
1334513447** inefficient.
1334613448*/
1334713449typedef 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+ */
1334813477typedef struct fts5_tokenizer fts5_tokenizer;
1334913478struct fts5_tokenizer {
1335013479 int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
@@ -13364,6 +13493,7 @@ struct fts5_tokenizer {
1336413493 );
1336513494};
1336613495
13496+
1336713497/* Flags that may be passed as the third argument to xTokenize() */
1336813498#define FTS5_TOKENIZE_QUERY 0x0001
1336913499#define FTS5_TOKENIZE_PREFIX 0x0002
@@ -13383,7 +13513,7 @@ struct fts5_tokenizer {
1338313513*/
1338413514typedef struct fts5_api fts5_api;
1338513515struct fts5_api {
13386- int iVersion; /* Currently always set to 2 */
13516+ int iVersion; /* Currently always set to 3 */
1338713517
1338813518 /* Create a new tokenizer */
1338913519 int (*xCreateTokenizer)(
@@ -13410,6 +13540,25 @@ struct fts5_api {
1341013540 fts5_extension_function xFunction,
1341113541 void (*xDestroy)(void*)
1341213542 );
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+ );
1341313562};
1341413563
1341513564/*
0 commit comments