summaryrefslogtreecommitdiff
path: root/c/sqlite3.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--c/sqlite3.h202
1 files changed, 180 insertions, 22 deletions
diff --git a/c/sqlite3.h b/c/sqlite3.h
index f64ca01..dbecc3f 100644
--- a/c/sqlite3.h
+++ b/c/sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
146** [sqlite3_libversion_number()], [sqlite3_sourceid()], 146** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147** [sqlite_version()] and [sqlite_source_id()]. 147** [sqlite_version()] and [sqlite_source_id()].
148*/ 148*/
149#define SQLITE_VERSION "3.46.1" 149#define SQLITE_VERSION "3.47.1"
150#define SQLITE_VERSION_NUMBER 3046001 150#define SQLITE_VERSION_NUMBER 3047001
151#define SQLITE_SOURCE_ID "2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33" 151#define SQLITE_SOURCE_ID "2024-11-25 12:07:48 b95d11e958643b969c47a8e5857f3793b9e69700b8f1469371386369a26e577e"
152 152
153/* 153/*
154** CAPI3REF: Run-Time Library Version Numbers 154** CAPI3REF: Run-Time Library Version Numbers
@@ -652,6 +652,13 @@ SQLITE_API int sqlite3_exec(
652** filesystem supports doing multiple write operations atomically when those 652** filesystem supports doing multiple write operations atomically when those
653** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and 653** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
654** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. 654** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
655**
656** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
657** from the database file in amounts that are not a multiple of the
658** page size and that do not begin at a page boundary. Without this
659** property, SQLite is careful to only do full-page reads and write
660** on aligned pages, with the one exception that it will do a sub-page
661** read of the first page to access the database header.
655*/ 662*/
656#define SQLITE_IOCAP_ATOMIC 0x00000001 663#define SQLITE_IOCAP_ATOMIC 0x00000001
657#define SQLITE_IOCAP_ATOMIC512 0x00000002 664#define SQLITE_IOCAP_ATOMIC512 0x00000002
@@ -668,6 +675,7 @@ SQLITE_API int sqlite3_exec(
668#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 675#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
669#define SQLITE_IOCAP_IMMUTABLE 0x00002000 676#define SQLITE_IOCAP_IMMUTABLE 0x00002000
670#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 677#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
678#define SQLITE_IOCAP_SUBPAGE_READ 0x00008000
671 679
672/* 680/*
673** CAPI3REF: File Locking Levels 681** CAPI3REF: File Locking Levels
@@ -772,8 +780,8 @@ struct sqlite3_file {
772** to xUnlock() is a no-op. 780** to xUnlock() is a no-op.
773** The xCheckReservedLock() method checks whether any database connection, 781** The xCheckReservedLock() method checks whether any database connection,
774** either in this process or in some other process, is holding a RESERVED, 782** either in this process or in some other process, is holding a RESERVED,
775** PENDING, or EXCLUSIVE lock on the file. It returns true 783** PENDING, or EXCLUSIVE lock on the file. It returns, via its output
776** if such a lock exists and false otherwise. 784** pointer parameter, true if such a lock exists and false otherwise.
777** 785**
778** The xFileControl() method is a generic interface that allows custom 786** The xFileControl() method is a generic interface that allows custom
779** VFS implementations to directly control an open file using the 787** VFS implementations to directly control an open file using the
@@ -814,6 +822,7 @@ struct sqlite3_file {
814** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] 822** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
815** <li> [SQLITE_IOCAP_IMMUTABLE] 823** <li> [SQLITE_IOCAP_IMMUTABLE]
816** <li> [SQLITE_IOCAP_BATCH_ATOMIC] 824** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
825** <li> [SQLITE_IOCAP_SUBPAGE_READ]
817** </ul> 826** </ul>
818** 827**
819** The SQLITE_IOCAP_ATOMIC property means that all writes of 828** The SQLITE_IOCAP_ATOMIC property means that all writes of
@@ -3570,8 +3579,8 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3570** 3579**
3571** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> 3580** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt>
3572** <dd>The database connection comes up in "extended result code mode". 3581** <dd>The database connection comes up in "extended result code mode".
3573** In other words, the database behaves has if 3582** In other words, the database behaves as if
3574** [sqlite3_extended_result_codes(db,1)] where called on the database 3583** [sqlite3_extended_result_codes(db,1)] were called on the database
3575** connection as soon as the connection is created. In addition to setting 3584** connection as soon as the connection is created. In addition to setting
3576** the extended result code mode, this flag also causes [sqlite3_open_v2()] 3585** the extended result code mode, this flag also causes [sqlite3_open_v2()]
3577** to return an extended result code.</dd> 3586** to return an extended result code.</dd>
@@ -4222,13 +4231,17 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
4222** and sqlite3_prepare16_v3() use UTF-16. 4231** and sqlite3_prepare16_v3() use UTF-16.
4223** 4232**
4224** ^If the nByte argument is negative, then zSql is read up to the 4233** ^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 4234** first zero terminator. ^If nByte is positive, then it is the maximum
4226** number of bytes read from zSql. ^If nByte is zero, then no prepared 4235** number of bytes read from zSql. When nByte is positive, zSql is read
4236** up to the first zero terminator or until the nByte bytes have been read,
4237** whichever comes first. ^If nByte is zero, then no prepared
4227** statement is generated. 4238** statement is generated.
4228** If the caller knows that the supplied string is nul-terminated, then 4239** If the caller knows that the supplied string is nul-terminated, then
4229** there is a small performance advantage to passing an nByte parameter that 4240** there is a small performance advantage to passing an nByte parameter that
4230** is the number of bytes in the input string <i>including</i> 4241** is the number of bytes in the input string <i>including</i>
4231** the nul-terminator. 4242** the nul-terminator.
4243** Note that nByte measure the length of the input in bytes, not
4244** characters, even for the UTF-16 interfaces.
4232** 4245**
4233** ^If pzTail is not NULL then *pzTail is made to point to the first byte 4246** ^If pzTail is not NULL then *pzTail is made to point to the first byte
4234** past the end of the first SQL statement in zSql. These routines only 4247** past the end of the first SQL statement in zSql. These routines only
@@ -5599,7 +5612,7 @@ SQLITE_API int sqlite3_create_window_function(
5599** This flag instructs SQLite to omit some corner-case optimizations that 5612** This flag instructs SQLite to omit some corner-case optimizations that
5600** might disrupt the operation of the [sqlite3_value_subtype()] function, 5613** might disrupt the operation of the [sqlite3_value_subtype()] function,
5601** causing it to return zero rather than the correct subtype(). 5614** causing it to return zero rather than the correct subtype().
5602** SQL functions that invokes [sqlite3_value_subtype()] should have this 5615** All SQL functions that invoke [sqlite3_value_subtype()] should have this
5603** property. If the SQLITE_SUBTYPE property is omitted, then the return 5616** property. If the SQLITE_SUBTYPE property is omitted, then the return
5604** value from [sqlite3_value_subtype()] might sometimes be zero even though 5617** value from [sqlite3_value_subtype()] might sometimes be zero even though
5605** a non-zero subtype was specified by the function argument expression. 5618** a non-zero subtype was specified by the function argument expression.
@@ -5615,6 +5628,15 @@ SQLITE_API int sqlite3_create_window_function(
5615** [sqlite3_result_subtype()] should avoid setting this property, as the 5628** [sqlite3_result_subtype()] should avoid setting this property, as the
5616** purpose of this property is to disable certain optimizations that are 5629** purpose of this property is to disable certain optimizations that are
5617** incompatible with subtypes. 5630** incompatible with subtypes.
5631**
5632** [[SQLITE_SELFORDER1]] <dt>SQLITE_SELFORDER1</dt><dd>
5633** The SQLITE_SELFORDER1 flag indicates that the function is an aggregate
5634** that internally orders the values provided to the first argument. The
5635** ordered-set aggregate SQL notation with a single ORDER BY term can be
5636** used to invoke this function. If the ordered-set aggregate notation is
5637** used on a function that lacks this flag, then an error is raised. Note
5638** that the ordered-set aggregate syntax is only available if SQLite is
5639** built using the -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES compile-time option.
5618** </dd> 5640** </dd>
5619** </dl> 5641** </dl>
5620*/ 5642*/
@@ -5623,6 +5645,7 @@ SQLITE_API int sqlite3_create_window_function(
5623#define SQLITE_SUBTYPE 0x000100000 5645#define SQLITE_SUBTYPE 0x000100000
5624#define SQLITE_INNOCUOUS 0x000200000 5646#define SQLITE_INNOCUOUS 0x000200000
5625#define SQLITE_RESULT_SUBTYPE 0x001000000 5647#define SQLITE_RESULT_SUBTYPE 0x001000000
5648#define SQLITE_SELFORDER1 0x002000000
5626 5649
5627/* 5650/*
5628** CAPI3REF: Deprecated Functions 5651** CAPI3REF: Deprecated Functions
@@ -5820,7 +5843,7 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
5820** one SQL function to another. Use the [sqlite3_result_subtype()] 5843** one SQL function to another. Use the [sqlite3_result_subtype()]
5821** routine to set the subtype for the return value of an SQL function. 5844** routine to set the subtype for the return value of an SQL function.
5822** 5845**
5823** Every [application-defined SQL function] that invoke this interface 5846** Every [application-defined SQL function] that invokes this interface
5824** should include the [SQLITE_SUBTYPE] property in the text 5847** should include the [SQLITE_SUBTYPE] property in the text
5825** encoding argument when the function is [sqlite3_create_function|registered]. 5848** encoding argument when the function is [sqlite3_create_function|registered].
5826** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype() 5849** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
@@ -7427,9 +7450,11 @@ struct sqlite3_module {
7427** will be returned by the strategy. 7450** will be returned by the strategy.
7428** 7451**
7429** The xBestIndex method may optionally populate the idxFlags field with a 7452** 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 - 7453** mask of SQLITE_INDEX_SCAN_* flags. One such flag is
7431** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite 7454** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN]
7432** assumes that the strategy may visit at most one row. 7455** output to show the idxNum has hex instead of as decimal. Another flag is
7456** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will
7457** return at most one row.
7433** 7458**
7434** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then 7459** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then
7435** SQLite also assumes that if a call to the xUpdate() method is made as 7460** SQLite also assumes that if a call to the xUpdate() method is made as
@@ -7493,7 +7518,9 @@ struct sqlite3_index_info {
7493** [sqlite3_index_info].idxFlags field to some combination of 7518** [sqlite3_index_info].idxFlags field to some combination of
7494** these bits. 7519** these bits.
7495*/ 7520*/
7496#define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */ 7521#define SQLITE_INDEX_SCAN_UNIQUE 0x00000001 /* Scan visits at most 1 row */
7522#define SQLITE_INDEX_SCAN_HEX 0x00000002 /* Display idxNum as hex */
7523 /* in EXPLAIN QUERY PLAN */
7497 7524
7498/* 7525/*
7499** CAPI3REF: Virtual Table Constraint Operator Codes 7526** CAPI3REF: Virtual Table Constraint Operator Codes
@@ -8330,6 +8357,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8330#define SQLITE_TESTCTRL_JSON_SELFCHECK 14 8357#define SQLITE_TESTCTRL_JSON_SELFCHECK 14
8331#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 8358#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
8332#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ 8359#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
8360#define SQLITE_TESTCTRL_GETOPT 16
8333#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ 8361#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
8334#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17 8362#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17
8335#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 8363#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
@@ -8349,7 +8377,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8349#define SQLITE_TESTCTRL_TRACEFLAGS 31 8377#define SQLITE_TESTCTRL_TRACEFLAGS 31
8350#define SQLITE_TESTCTRL_TUNE 32 8378#define SQLITE_TESTCTRL_TUNE 32
8351#define SQLITE_TESTCTRL_LOGEST 33 8379#define SQLITE_TESTCTRL_LOGEST 33
8352#define SQLITE_TESTCTRL_USELONGDOUBLE 34 8380#define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */
8353#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */ 8381#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8354 8382
8355/* 8383/*
@@ -9325,6 +9353,16 @@ typedef struct sqlite3_backup sqlite3_backup;
9325** APIs are not strictly speaking threadsafe. If they are invoked at the 9353** APIs are not strictly speaking threadsafe. If they are invoked at the
9326** same time as another thread is invoking sqlite3_backup_step() it is 9354** same time as another thread is invoking sqlite3_backup_step() it is
9327** possible that they return invalid values. 9355** possible that they return invalid values.
9356**
9357** <b>Alternatives To Using The Backup API</b>
9358**
9359** Other techniques for safely creating a consistent backup of an SQLite
9360** database include:
9361**
9362** <ul>
9363** <li> The [VACUUM INTO] command.
9364** <li> The [sqlite3_rsync] utility program.
9365** </ul>
9328*/ 9366*/
9329SQLITE_API sqlite3_backup *sqlite3_backup_init( 9367SQLITE_API sqlite3_backup *sqlite3_backup_init(
9330 sqlite3 *pDest, /* Destination database handle */ 9368 sqlite3 *pDest, /* Destination database handle */
@@ -10524,6 +10562,14 @@ typedef struct sqlite3_snapshot {
10524** If there is not already a read-transaction open on schema S when 10562** If there is not already a read-transaction open on schema S when
10525** this function is called, one is opened automatically. 10563** this function is called, one is opened automatically.
10526** 10564**
10565** If a read-transaction is opened by this function, then it is guaranteed
10566** that the returned snapshot object may not be invalidated by a database
10567** writer or checkpointer until after the read-transaction is closed. This
10568** is not guaranteed if a read-transaction is already open when this
10569** function is called. In that case, any subsequent write or checkpoint
10570** operation on the database may invalidate the returned snapshot handle,
10571** even while the read-transaction remains open.
10572**
10527** The following must be true for this function to succeed. If any of 10573** The following must be true for this function to succeed. If any of
10528** the following statements are false when sqlite3_snapshot_get() is 10574** the following statements are false when sqlite3_snapshot_get() is
10529** called, SQLITE_ERROR is returned. The final value of *P is undefined 10575** called, SQLITE_ERROR is returned. The final value of *P is undefined
@@ -10832,8 +10878,6 @@ SQLITE_API int sqlite3_deserialize(
10832#if defined(__wasi__) 10878#if defined(__wasi__)
10833# undef SQLITE_WASI 10879# undef SQLITE_WASI
10834# define SQLITE_WASI 1 10880# define SQLITE_WASI 1
10835# undef SQLITE_OMIT_WAL
10836# define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */
10837# ifndef SQLITE_OMIT_LOAD_EXTENSION 10881# ifndef SQLITE_OMIT_LOAD_EXTENSION
10838# define SQLITE_OMIT_LOAD_EXTENSION 10882# define SQLITE_OMIT_LOAD_EXTENSION
10839# endif 10883# endif
@@ -13036,6 +13080,10 @@ struct Fts5PhraseIter {
13036** (i.e. if it is a contentless table), then this API always iterates 13080** (i.e. if it is a contentless table), then this API always iterates
13037** through an empty set (all calls to xPhraseFirst() set iCol to -1). 13081** through an empty set (all calls to xPhraseFirst() set iCol to -1).
13038** 13082**
13083** In all cases, matches are visited in (column ASC, offset ASC) order.
13084** i.e. all those in column 0, sorted by offset, followed by those in
13085** column 1, etc.
13086**
13039** xPhraseNext() 13087** xPhraseNext()
13040** See xPhraseFirst above. 13088** See xPhraseFirst above.
13041** 13089**
@@ -13102,9 +13150,32 @@ struct Fts5PhraseIter {
13102** 13150**
13103** This API can be quite slow if used with an FTS5 table created with the 13151** This API can be quite slow if used with an FTS5 table created with the
13104** "detail=none" or "detail=column" option. 13152** "detail=none" or "detail=column" option.
13153**
13154** xColumnLocale(pFts5, iIdx, pzLocale, pnLocale)
13155** If parameter iCol is less than zero, or greater than or equal to the
13156** number of columns in the table, SQLITE_RANGE is returned.
13157**
13158** Otherwise, this function attempts to retrieve the locale associated
13159** with column iCol of the current row. Usually, there is no associated
13160** locale, and output parameters (*pzLocale) and (*pnLocale) are set
13161** to NULL and 0, respectively. However, if the fts5_locale() function
13162** was used to associate a locale with the value when it was inserted
13163** into the fts5 table, then (*pzLocale) is set to point to a nul-terminated
13164** buffer containing the name of the locale in utf-8 encoding. (*pnLocale)
13165** is set to the size in bytes of the buffer, not including the
13166** nul-terminator.
13167**
13168** If successful, SQLITE_OK is returned. Or, if an error occurs, an
13169** SQLite error code is returned. The final value of the output parameters
13170** is undefined in this case.
13171**
13172** xTokenize_v2:
13173** Tokenize text using the tokenizer belonging to the FTS5 table. This
13174** API is the same as the xTokenize() API, except that it allows a tokenizer
13175** locale to be specified.
13105*/ 13176*/
13106struct Fts5ExtensionApi { 13177struct Fts5ExtensionApi {
13107 int iVersion; /* Currently always set to 3 */ 13178 int iVersion; /* Currently always set to 4 */
13108 13179
13109 void *(*xUserData)(Fts5Context*); 13180 void *(*xUserData)(Fts5Context*);
13110 13181
@@ -13146,6 +13217,15 @@ struct Fts5ExtensionApi {
13146 const char **ppToken, int *pnToken 13217 const char **ppToken, int *pnToken
13147 ); 13218 );
13148 int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*); 13219 int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*);
13220
13221 /* Below this point are iVersion>=4 only */
13222 int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn);
13223 int (*xTokenize_v2)(Fts5Context*,
13224 const char *pText, int nText, /* Text to tokenize */
13225 const char *pLocale, int nLocale, /* Locale to pass to tokenizer */
13226 void *pCtx, /* Context passed to xToken() */
13227 int (*xToken)(void*, int, const char*, int, int, int) /* Callback */
13228 );
13149}; 13229};
13150 13230
13151/* 13231/*
@@ -13166,7 +13246,7 @@ struct Fts5ExtensionApi {
13166** A tokenizer instance is required to actually tokenize text. 13246** A tokenizer instance is required to actually tokenize text.
13167** 13247**
13168** The first argument passed to this function is a copy of the (void*) 13248** The first argument passed to this function is a copy of the (void*)
13169** pointer provided by the application when the fts5_tokenizer object 13249** pointer provided by the application when the fts5_tokenizer_v2 object
13170** was registered with FTS5 (the third argument to xCreateTokenizer()). 13250** was registered with FTS5 (the third argument to xCreateTokenizer()).
13171** The second and third arguments are an array of nul-terminated strings 13251** The second and third arguments are an array of nul-terminated strings
13172** containing the tokenizer arguments, if any, specified following the 13252** containing the tokenizer arguments, if any, specified following the
@@ -13190,7 +13270,7 @@ struct Fts5ExtensionApi {
13190** argument passed to this function is a pointer to an Fts5Tokenizer object 13270** argument passed to this function is a pointer to an Fts5Tokenizer object
13191** returned by an earlier call to xCreate(). 13271** returned by an earlier call to xCreate().
13192** 13272**
13193** The second argument indicates the reason that FTS5 is requesting 13273** The third argument indicates the reason that FTS5 is requesting
13194** tokenization of the supplied text. This is always one of the following 13274** tokenization of the supplied text. This is always one of the following
13195** four values: 13275** four values:
13196** 13276**
@@ -13214,6 +13294,13 @@ struct Fts5ExtensionApi {
13214** on a columnsize=0 database. 13294** on a columnsize=0 database.
13215** </ul> 13295** </ul>
13216** 13296**
13297** The sixth and seventh arguments passed to xTokenize() - pLocale and
13298** nLocale - are a pointer to a buffer containing the locale to use for
13299** tokenization (e.g. "en_US") and its size in bytes, respectively. The
13300** pLocale buffer is not nul-terminated. pLocale may be passed NULL (in
13301** which case nLocale is always 0) to indicate that the tokenizer should
13302** use its default locale.
13303**
13217** For each token in the input string, the supplied callback xToken() must 13304** For each token in the input string, the supplied callback xToken() must
13218** be invoked. The first argument to it should be a copy of the pointer 13305** be invoked. The first argument to it should be a copy of the pointer
13219** passed as the second argument to xTokenize(). The third and fourth 13306** passed as the second argument to xTokenize(). The third and fourth
@@ -13237,6 +13324,30 @@ struct Fts5ExtensionApi {
13237** may abandon the tokenization and return any error code other than 13324** may abandon the tokenization and return any error code other than
13238** SQLITE_OK or SQLITE_DONE. 13325** SQLITE_OK or SQLITE_DONE.
13239** 13326**
13327** If the tokenizer is registered using an fts5_tokenizer_v2 object,
13328** then the xTokenize() method has two additional arguments - pLocale
13329** and nLocale. These specify the locale that the tokenizer should use
13330** for the current request. If pLocale and nLocale are both 0, then the
13331** tokenizer should use its default locale. Otherwise, pLocale points to
13332** an nLocale byte buffer containing the name of the locale to use as utf-8
13333** text. pLocale is not nul-terminated.
13334**
13335** FTS5_TOKENIZER
13336**
13337** There is also an fts5_tokenizer object. This is an older, deprecated,
13338** version of fts5_tokenizer_v2. It is similar except that:
13339**
13340** <ul>
13341** <li> There is no "iVersion" field, and
13342** <li> The xTokenize() method does not take a locale argument.
13343** </ul>
13344**
13345** Legacy fts5_tokenizer tokenizers must be registered using the
13346** legacy xCreateTokenizer() function, instead of xCreateTokenizer_v2().
13347**
13348** Tokenizer implementations registered using either API may be retrieved
13349** using both xFindTokenizer() and xFindTokenizer_v2().
13350**
13240** SYNONYM SUPPORT 13351** SYNONYM SUPPORT
13241** 13352**
13242** Custom tokenizers may also support synonyms. Consider a case in which a 13353** Custom tokenizers may also support synonyms. Consider a case in which a
@@ -13345,6 +13456,33 @@ struct Fts5ExtensionApi {
13345** inefficient. 13456** inefficient.
13346*/ 13457*/
13347typedef struct Fts5Tokenizer Fts5Tokenizer; 13458typedef struct Fts5Tokenizer Fts5Tokenizer;
13459typedef struct fts5_tokenizer_v2 fts5_tokenizer_v2;
13460struct fts5_tokenizer_v2 {
13461 int iVersion; /* Currently always 2 */
13462
13463 int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
13464 void (*xDelete)(Fts5Tokenizer*);
13465 int (*xTokenize)(Fts5Tokenizer*,
13466 void *pCtx,
13467 int flags, /* Mask of FTS5_TOKENIZE_* flags */
13468 const char *pText, int nText,
13469 const char *pLocale, int nLocale,
13470 int (*xToken)(
13471 void *pCtx, /* Copy of 2nd argument to xTokenize() */
13472 int tflags, /* Mask of FTS5_TOKEN_* flags */
13473 const char *pToken, /* Pointer to buffer containing token */
13474 int nToken, /* Size of token in bytes */
13475 int iStart, /* Byte offset of token within input text */
13476 int iEnd /* Byte offset of end of token within input text */
13477 )
13478 );
13479};
13480
13481/*
13482** New code should use the fts5_tokenizer_v2 type to define tokenizer
13483** implementations. The following type is included for legacy applications
13484** that still use it.
13485*/
13348typedef struct fts5_tokenizer fts5_tokenizer; 13486typedef struct fts5_tokenizer fts5_tokenizer;
13349struct fts5_tokenizer { 13487struct fts5_tokenizer {
13350 int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); 13488 int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
@@ -13364,6 +13502,7 @@ struct fts5_tokenizer {
13364 ); 13502 );
13365}; 13503};
13366 13504
13505
13367/* Flags that may be passed as the third argument to xTokenize() */ 13506/* Flags that may be passed as the third argument to xTokenize() */
13368#define FTS5_TOKENIZE_QUERY 0x0001 13507#define FTS5_TOKENIZE_QUERY 0x0001
13369#define FTS5_TOKENIZE_PREFIX 0x0002 13508#define FTS5_TOKENIZE_PREFIX 0x0002
@@ -13383,7 +13522,7 @@ struct fts5_tokenizer {
13383*/ 13522*/
13384typedef struct fts5_api fts5_api; 13523typedef struct fts5_api fts5_api;
13385struct fts5_api { 13524struct fts5_api {
13386 int iVersion; /* Currently always set to 2 */ 13525 int iVersion; /* Currently always set to 3 */
13387 13526
13388 /* Create a new tokenizer */ 13527 /* Create a new tokenizer */
13389 int (*xCreateTokenizer)( 13528 int (*xCreateTokenizer)(
@@ -13410,6 +13549,25 @@ struct fts5_api {
13410 fts5_extension_function xFunction, 13549 fts5_extension_function xFunction,
13411 void (*xDestroy)(void*) 13550 void (*xDestroy)(void*)
13412 ); 13551 );
13552
13553 /* APIs below this point are only available if iVersion>=3 */
13554
13555 /* Create a new tokenizer */
13556 int (*xCreateTokenizer_v2)(
13557 fts5_api *pApi,
13558 const char *zName,
13559 void *pUserData,
13560 fts5_tokenizer_v2 *pTokenizer,
13561 void (*xDestroy)(void*)
13562 );
13563
13564 /* Find an existing tokenizer */
13565 int (*xFindTokenizer_v2)(
13566 fts5_api *pApi,
13567 const char *zName,
13568 void **ppUserData,
13569 fts5_tokenizer_v2 **ppTokenizer
13570 );
13413}; 13571};
13414 13572
13415/* 13573/*