diff options
Diffstat (limited to '')
| -rw-r--r-- | c/loadable-ext-sqlite3.h | 448 |
1 files changed, 385 insertions, 63 deletions
diff --git a/c/loadable-ext-sqlite3.h b/c/loadable-ext-sqlite3.h index 6ca6914..4e93395 100644 --- a/c/loadable-ext-sqlite3.h +++ b/c/loadable-ext-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.44.0" | 149 | #define SQLITE_VERSION "3.47.1" |
| 150 | #define SQLITE_VERSION_NUMBER 3044000 | 150 | #define SQLITE_VERSION_NUMBER 3047001 |
| 151 | #define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" | 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 |
| @@ -412,6 +412,8 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); | |||
| 412 | ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. | 412 | ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. |
| 413 | ** <li> The application must not modify the SQL statement text passed into | 413 | ** <li> The application must not modify the SQL statement text passed into |
| 414 | ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. | 414 | ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. |
| 415 | ** <li> The application must not dereference the arrays or string pointers | ||
| 416 | ** passed as the 3rd and 4th callback parameters after it returns. | ||
| 415 | ** </ul> | 417 | ** </ul> |
| 416 | */ | 418 | */ |
| 417 | 419 | ||
| @@ -635,6 +637,13 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); | |||
| 635 | ** filesystem supports doing multiple write operations atomically when those | 637 | ** filesystem supports doing multiple write operations atomically when those |
| 636 | ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and | 638 | ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and |
| 637 | ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. | 639 | ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. |
| 640 | ** | ||
| 641 | ** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read | ||
| 642 | ** from the database file in amounts that are not a multiple of the | ||
| 643 | ** page size and that do not begin at a page boundary. Without this | ||
| 644 | ** property, SQLite is careful to only do full-page reads and write | ||
| 645 | ** on aligned pages, with the one exception that it will do a sub-page | ||
| 646 | ** read of the first page to access the database header. | ||
| 638 | */ | 647 | */ |
| 639 | #define SQLITE_IOCAP_ATOMIC 0x00000001 | 648 | #define SQLITE_IOCAP_ATOMIC 0x00000001 |
| 640 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 | 649 | #define SQLITE_IOCAP_ATOMIC512 0x00000002 |
| @@ -651,6 +660,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**); | |||
| 651 | #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 | 660 | #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 |
| 652 | #define SQLITE_IOCAP_IMMUTABLE 0x00002000 | 661 | #define SQLITE_IOCAP_IMMUTABLE 0x00002000 |
| 653 | #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 | 662 | #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 |
| 663 | #define SQLITE_IOCAP_SUBPAGE_READ 0x00008000 | ||
| 654 | 664 | ||
| 655 | /* | 665 | /* |
| 656 | ** CAPI3REF: File Locking Levels | 666 | ** CAPI3REF: File Locking Levels |
| @@ -747,16 +757,16 @@ struct sqlite3_file { | |||
| 747 | ** </ul> | 757 | ** </ul> |
| 748 | ** xLock() upgrades the database file lock. In other words, xLock() moves the | 758 | ** xLock() upgrades the database file lock. In other words, xLock() moves the |
| 749 | ** database file lock in the direction NONE toward EXCLUSIVE. The argument to | 759 | ** database file lock in the direction NONE toward EXCLUSIVE. The argument to |
| 750 | ** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never | 760 | ** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never |
| 751 | ** SQLITE_LOCK_NONE. If the database file lock is already at or above the | 761 | ** SQLITE_LOCK_NONE. If the database file lock is already at or above the |
| 752 | ** requested lock, then the call to xLock() is a no-op. | 762 | ** requested lock, then the call to xLock() is a no-op. |
| 753 | ** xUnlock() downgrades the database file lock to either SHARED or NONE. | 763 | ** xUnlock() downgrades the database file lock to either SHARED or NONE. |
| 754 | * If the lock is already at or below the requested lock state, then the call | 764 | ** If the lock is already at or below the requested lock state, then the call |
| 755 | ** to xUnlock() is a no-op. | 765 | ** to xUnlock() is a no-op. |
| 756 | ** The xCheckReservedLock() method checks whether any database connection, | 766 | ** The xCheckReservedLock() method checks whether any database connection, |
| 757 | ** either in this process or in some other process, is holding a RESERVED, | 767 | ** either in this process or in some other process, is holding a RESERVED, |
| 758 | ** PENDING, or EXCLUSIVE lock on the file. It returns true | 768 | ** PENDING, or EXCLUSIVE lock on the file. It returns, via its output |
| 759 | ** if such a lock exists and false otherwise. | 769 | ** pointer parameter, true if such a lock exists and false otherwise. |
| 760 | ** | 770 | ** |
| 761 | ** The xFileControl() method is a generic interface that allows custom | 771 | ** The xFileControl() method is a generic interface that allows custom |
| 762 | ** VFS implementations to directly control an open file using the | 772 | ** VFS implementations to directly control an open file using the |
| @@ -797,6 +807,7 @@ struct sqlite3_file { | |||
| 797 | ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] | 807 | ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] |
| 798 | ** <li> [SQLITE_IOCAP_IMMUTABLE] | 808 | ** <li> [SQLITE_IOCAP_IMMUTABLE] |
| 799 | ** <li> [SQLITE_IOCAP_BATCH_ATOMIC] | 809 | ** <li> [SQLITE_IOCAP_BATCH_ATOMIC] |
| 810 | ** <li> [SQLITE_IOCAP_SUBPAGE_READ] | ||
| 800 | ** </ul> | 811 | ** </ul> |
| 801 | ** | 812 | ** |
| 802 | ** The SQLITE_IOCAP_ATOMIC property means that all writes of | 813 | ** The SQLITE_IOCAP_ATOMIC property means that all writes of |
| @@ -2120,6 +2131,22 @@ struct sqlite3_mem_methods { | |||
| 2120 | ** configuration setting is never used, then the default maximum is determined | 2131 | ** configuration setting is never used, then the default maximum is determined |
| 2121 | ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that | 2132 | ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that |
| 2122 | ** compile-time option is not set, then the default maximum is 1073741824. | 2133 | ** compile-time option is not set, then the default maximum is 1073741824. |
| 2134 | ** | ||
| 2135 | ** [[SQLITE_CONFIG_ROWID_IN_VIEW]] | ||
| 2136 | ** <dt>SQLITE_CONFIG_ROWID_IN_VIEW | ||
| 2137 | ** <dd>The SQLITE_CONFIG_ROWID_IN_VIEW option enables or disables the ability | ||
| 2138 | ** for VIEWs to have a ROWID. The capability can only be enabled if SQLite is | ||
| 2139 | ** compiled with -DSQLITE_ALLOW_ROWID_IN_VIEW, in which case the capability | ||
| 2140 | ** defaults to on. This configuration option queries the current setting or | ||
| 2141 | ** changes the setting to off or on. The argument is a pointer to an integer. | ||
| 2142 | ** If that integer initially holds a value of 1, then the ability for VIEWs to | ||
| 2143 | ** have ROWIDs is activated. If the integer initially holds zero, then the | ||
| 2144 | ** ability is deactivated. Any other initial value for the integer leaves the | ||
| 2145 | ** setting unchanged. After changes, if any, the integer is written with | ||
| 2146 | ** a 1 or 0, if the ability for VIEWs to have ROWIDs is on or off. If SQLite | ||
| 2147 | ** is compiled without -DSQLITE_ALLOW_ROWID_IN_VIEW (which is the usual and | ||
| 2148 | ** recommended case) then the integer is always filled with zero, regardless | ||
| 2149 | ** if its initial value. | ||
| 2123 | ** </dl> | 2150 | ** </dl> |
| 2124 | */ | 2151 | */ |
| 2125 | #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ | 2152 | #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ |
| @@ -2151,6 +2178,7 @@ struct sqlite3_mem_methods { | |||
| 2151 | #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ | 2178 | #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ |
| 2152 | #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ | 2179 | #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ |
| 2153 | #define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */ | 2180 | #define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */ |
| 2181 | #define SQLITE_CONFIG_ROWID_IN_VIEW 30 /* int* */ | ||
| 2154 | 2182 | ||
| 2155 | /* | 2183 | /* |
| 2156 | ** CAPI3REF: Database Connection Configuration Options | 2184 | ** CAPI3REF: Database Connection Configuration Options |
| @@ -3225,8 +3253,8 @@ struct sqlite3_mem_methods { | |||
| 3225 | #define SQLITE_RECURSIVE 33 /* NULL NULL */ | 3253 | #define SQLITE_RECURSIVE 33 /* NULL NULL */ |
| 3226 | 3254 | ||
| 3227 | /* | 3255 | /* |
| 3228 | ** CAPI3REF: Tracing And Profiling Functions | 3256 | ** CAPI3REF: Deprecated Tracing And Profiling Functions |
| 3229 | ** METHOD: sqlite3 | 3257 | ** DEPRECATED |
| 3230 | ** | 3258 | ** |
| 3231 | ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface | 3259 | ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface |
| 3232 | ** instead of the routines described here. | 3260 | ** instead of the routines described here. |
| @@ -3479,8 +3507,8 @@ struct sqlite3_mem_methods { | |||
| 3479 | ** | 3507 | ** |
| 3480 | ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> | 3508 | ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> |
| 3481 | ** <dd>The database connection comes up in "extended result code mode". | 3509 | ** <dd>The database connection comes up in "extended result code mode". |
| 3482 | ** In other words, the database behaves has if | 3510 | ** In other words, the database behaves as if |
| 3483 | ** [sqlite3_extended_result_codes(db,1)] where called on the database | 3511 | ** [sqlite3_extended_result_codes(db,1)] were called on the database |
| 3484 | ** connection as soon as the connection is created. In addition to setting | 3512 | ** connection as soon as the connection is created. In addition to setting |
| 3485 | ** the extended result code mode, this flag also causes [sqlite3_open_v2()] | 3513 | ** the extended result code mode, this flag also causes [sqlite3_open_v2()] |
| 3486 | ** to return an extended result code.</dd> | 3514 | ** to return an extended result code.</dd> |
| @@ -3852,15 +3880,17 @@ struct sqlite3_mem_methods { | |||
| 3852 | ** </ul> | 3880 | ** </ul> |
| 3853 | ** | 3881 | ** |
| 3854 | ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language | 3882 | ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language |
| 3855 | ** text that describes the error, as either UTF-8 or UTF-16 respectively. | 3883 | ** text that describes the error, as either UTF-8 or UTF-16 respectively, |
| 3884 | ** or NULL if no error message is available. | ||
| 3856 | ** (See how SQLite handles [invalid UTF] for exceptions to this rule.) | 3885 | ** (See how SQLite handles [invalid UTF] for exceptions to this rule.) |
| 3857 | ** ^(Memory to hold the error message string is managed internally. | 3886 | ** ^(Memory to hold the error message string is managed internally. |
| 3858 | ** The application does not need to worry about freeing the result. | 3887 | ** The application does not need to worry about freeing the result. |
| 3859 | ** However, the error string might be overwritten or deallocated by | 3888 | ** However, the error string might be overwritten or deallocated by |
| 3860 | ** subsequent calls to other SQLite interface functions.)^ | 3889 | ** subsequent calls to other SQLite interface functions.)^ |
| 3861 | ** | 3890 | ** |
| 3862 | ** ^The sqlite3_errstr() interface returns the English-language text | 3891 | ** ^The sqlite3_errstr(E) interface returns the English-language text |
| 3863 | ** that describes the [result code], as UTF-8. | 3892 | ** that describes the [result code] E, as UTF-8, or NULL if E is not an |
| 3893 | ** result code for which a text error message is available. | ||
| 3864 | ** ^(Memory to hold the error message string is managed internally | 3894 | ** ^(Memory to hold the error message string is managed internally |
| 3865 | ** and must not be freed by the application)^. | 3895 | ** and must not be freed by the application)^. |
| 3866 | ** | 3896 | ** |
| @@ -4092,13 +4122,17 @@ typedef struct sqlite3_stmt sqlite3_stmt; | |||
| 4092 | ** and sqlite3_prepare16_v3() use UTF-16. | 4122 | ** and sqlite3_prepare16_v3() use UTF-16. |
| 4093 | ** | 4123 | ** |
| 4094 | ** ^If the nByte argument is negative, then zSql is read up to the | 4124 | ** ^If the nByte argument is negative, then zSql is read up to the |
| 4095 | ** first zero terminator. ^If nByte is positive, then it is the | 4125 | ** first zero terminator. ^If nByte is positive, then it is the maximum |
| 4096 | ** number of bytes read from zSql. ^If nByte is zero, then no prepared | 4126 | ** number of bytes read from zSql. When nByte is positive, zSql is read |
| 4127 | ** up to the first zero terminator or until the nByte bytes have been read, | ||
| 4128 | ** whichever comes first. ^If nByte is zero, then no prepared | ||
| 4097 | ** statement is generated. | 4129 | ** statement is generated. |
| 4098 | ** If the caller knows that the supplied string is nul-terminated, then | 4130 | ** If the caller knows that the supplied string is nul-terminated, then |
| 4099 | ** there is a small performance advantage to passing an nByte parameter that | 4131 | ** there is a small performance advantage to passing an nByte parameter that |
| 4100 | ** is the number of bytes in the input string <i>including</i> | 4132 | ** is the number of bytes in the input string <i>including</i> |
| 4101 | ** the nul-terminator. | 4133 | ** the nul-terminator. |
| 4134 | ** Note that nByte measure the length of the input in bytes, not | ||
| 4135 | ** characters, even for the UTF-16 interfaces. | ||
| 4102 | ** | 4136 | ** |
| 4103 | ** ^If pzTail is not NULL then *pzTail is made to point to the first byte | 4137 | ** ^If pzTail is not NULL then *pzTail is made to point to the first byte |
| 4104 | ** past the end of the first SQL statement in zSql. These routines only | 4138 | ** past the end of the first SQL statement in zSql. These routines only |
| @@ -5326,13 +5360,36 @@ typedef struct sqlite3_context sqlite3_context; | |||
| 5326 | ** </dd> | 5360 | ** </dd> |
| 5327 | ** | 5361 | ** |
| 5328 | ** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd> | 5362 | ** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd> |
| 5329 | ** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call | 5363 | ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call |
| 5330 | ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. | 5364 | ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. |
| 5331 | ** Specifying this flag makes no difference for scalar or aggregate user | 5365 | ** This flag instructs SQLite to omit some corner-case optimizations that |
| 5332 | ** functions. However, if it is not specified for a user-defined window | 5366 | ** might disrupt the operation of the [sqlite3_value_subtype()] function, |
| 5333 | ** function, then any sub-types belonging to arguments passed to the window | 5367 | ** causing it to return zero rather than the correct subtype(). |
| 5334 | ** function may be discarded before the window function is called (i.e. | 5368 | ** All SQL functions that invoke [sqlite3_value_subtype()] should have this |
| 5335 | ** sqlite3_value_subtype() will always return 0). | 5369 | ** property. If the SQLITE_SUBTYPE property is omitted, then the return |
| 5370 | ** value from [sqlite3_value_subtype()] might sometimes be zero even though | ||
| 5371 | ** a non-zero subtype was specified by the function argument expression. | ||
| 5372 | ** | ||
| 5373 | ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd> | ||
| 5374 | ** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call | ||
| 5375 | ** [sqlite3_result_subtype()] to cause a sub-type to be associated with its | ||
| 5376 | ** result. | ||
| 5377 | ** Every function that invokes [sqlite3_result_subtype()] should have this | ||
| 5378 | ** property. If it does not, then the call to [sqlite3_result_subtype()] | ||
| 5379 | ** might become a no-op if the function is used as term in an | ||
| 5380 | ** [expression index]. On the other hand, SQL functions that never invoke | ||
| 5381 | ** [sqlite3_result_subtype()] should avoid setting this property, as the | ||
| 5382 | ** purpose of this property is to disable certain optimizations that are | ||
| 5383 | ** incompatible with subtypes. | ||
| 5384 | ** | ||
| 5385 | ** [[SQLITE_SELFORDER1]] <dt>SQLITE_SELFORDER1</dt><dd> | ||
| 5386 | ** The SQLITE_SELFORDER1 flag indicates that the function is an aggregate | ||
| 5387 | ** that internally orders the values provided to the first argument. The | ||
| 5388 | ** ordered-set aggregate SQL notation with a single ORDER BY term can be | ||
| 5389 | ** used to invoke this function. If the ordered-set aggregate notation is | ||
| 5390 | ** used on a function that lacks this flag, then an error is raised. Note | ||
| 5391 | ** that the ordered-set aggregate syntax is only available if SQLite is | ||
| 5392 | ** built using the -DSQLITE_ENABLE_ORDERED_SET_AGGREGATES compile-time option. | ||
| 5336 | ** </dd> | 5393 | ** </dd> |
| 5337 | ** </dl> | 5394 | ** </dl> |
| 5338 | */ | 5395 | */ |
| @@ -5340,6 +5397,8 @@ typedef struct sqlite3_context sqlite3_context; | |||
| 5340 | #define SQLITE_DIRECTONLY 0x000080000 | 5397 | #define SQLITE_DIRECTONLY 0x000080000 |
| 5341 | #define SQLITE_SUBTYPE 0x000100000 | 5398 | #define SQLITE_SUBTYPE 0x000100000 |
| 5342 | #define SQLITE_INNOCUOUS 0x000200000 | 5399 | #define SQLITE_INNOCUOUS 0x000200000 |
| 5400 | #define SQLITE_RESULT_SUBTYPE 0x001000000 | ||
| 5401 | #define SQLITE_SELFORDER1 0x002000000 | ||
| 5343 | 5402 | ||
| 5344 | /* | 5403 | /* |
| 5345 | ** CAPI3REF: Deprecated Functions | 5404 | ** CAPI3REF: Deprecated Functions |
| @@ -5513,6 +5572,12 @@ typedef struct sqlite3_context sqlite3_context; | |||
| 5513 | ** information can be used to pass a limited amount of context from | 5572 | ** information can be used to pass a limited amount of context from |
| 5514 | ** one SQL function to another. Use the [sqlite3_result_subtype()] | 5573 | ** one SQL function to another. Use the [sqlite3_result_subtype()] |
| 5515 | ** routine to set the subtype for the return value of an SQL function. | 5574 | ** routine to set the subtype for the return value of an SQL function. |
| 5575 | ** | ||
| 5576 | ** Every [application-defined SQL function] that invokes this interface | ||
| 5577 | ** should include the [SQLITE_SUBTYPE] property in the text | ||
| 5578 | ** encoding argument when the function is [sqlite3_create_function|registered]. | ||
| 5579 | ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype() | ||
| 5580 | ** might return zero instead of the upstream subtype in some corner cases. | ||
| 5516 | */ | 5581 | */ |
| 5517 | 5582 | ||
| 5518 | /* | 5583 | /* |
| @@ -5637,14 +5702,22 @@ typedef struct sqlite3_context sqlite3_context; | |||
| 5637 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same | 5702 | ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 5638 | ** parameter)^, or | 5703 | ** parameter)^, or |
| 5639 | ** <li> ^(during the original sqlite3_set_auxdata() call when a memory | 5704 | ** <li> ^(during the original sqlite3_set_auxdata() call when a memory |
| 5640 | ** allocation error occurs.)^ </ul> | 5705 | ** allocation error occurs.)^ |
| 5706 | ** <li> ^(during the original sqlite3_set_auxdata() call if the function | ||
| 5707 | ** is evaluated during query planning instead of during query execution, | ||
| 5708 | ** as sometimes happens with [SQLITE_ENABLE_STAT4].)^ </ul> | ||
| 5641 | ** | 5709 | ** |
| 5642 | ** Note the last bullet in particular. The destructor X in | 5710 | ** Note the last two bullets in particular. The destructor X in |
| 5643 | ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the | 5711 | ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the |
| 5644 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() | 5712 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 5645 | ** should be called near the end of the function implementation and the | 5713 | ** should be called near the end of the function implementation and the |
| 5646 | ** function implementation should not make any use of P after | 5714 | ** function implementation should not make any use of P after |
| 5647 | ** sqlite3_set_auxdata() has been called. | 5715 | ** sqlite3_set_auxdata() has been called. Furthermore, a call to |
| 5716 | ** sqlite3_get_auxdata() that occurs immediately after a corresponding call | ||
| 5717 | ** to sqlite3_set_auxdata() might still return NULL if an out-of-memory | ||
| 5718 | ** condition occurred during the sqlite3_set_auxdata() call or if the | ||
| 5719 | ** function is being evaluated during query planning rather than during | ||
| 5720 | ** query execution. | ||
| 5648 | ** | 5721 | ** |
| 5649 | ** ^(In practice, auxiliary data is preserved between function calls for | 5722 | ** ^(In practice, auxiliary data is preserved between function calls for |
| 5650 | ** function parameters that are compile-time constants, including literal | 5723 | ** function parameters that are compile-time constants, including literal |
| @@ -5892,6 +5965,20 @@ typedef void (*sqlite3_destructor_type)(void*); | |||
| 5892 | ** higher order bits are discarded. | 5965 | ** higher order bits are discarded. |
| 5893 | ** The number of subtype bytes preserved by SQLite might increase | 5966 | ** The number of subtype bytes preserved by SQLite might increase |
| 5894 | ** in future releases of SQLite. | 5967 | ** in future releases of SQLite. |
| 5968 | ** | ||
| 5969 | ** Every [application-defined SQL function] that invokes this interface | ||
| 5970 | ** should include the [SQLITE_RESULT_SUBTYPE] property in its | ||
| 5971 | ** text encoding argument when the SQL function is | ||
| 5972 | ** [sqlite3_create_function|registered]. If the [SQLITE_RESULT_SUBTYPE] | ||
| 5973 | ** property is omitted from the function that invokes sqlite3_result_subtype(), | ||
| 5974 | ** then in some cases the sqlite3_result_subtype() might fail to set | ||
| 5975 | ** the result subtype. | ||
| 5976 | ** | ||
| 5977 | ** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any | ||
| 5978 | ** SQL function that invokes the sqlite3_result_subtype() interface | ||
| 5979 | ** and that does not have the SQLITE_RESULT_SUBTYPE property will raise | ||
| 5980 | ** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1 | ||
| 5981 | ** by default. | ||
| 5895 | */ | 5982 | */ |
| 5896 | 5983 | ||
| 5897 | /* | 5984 | /* |
| @@ -6463,6 +6550,12 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory; | |||
| 6463 | ** The exceptions defined in this paragraph might change in a future | 6550 | ** The exceptions defined in this paragraph might change in a future |
| 6464 | ** release of SQLite. | 6551 | ** release of SQLite. |
| 6465 | ** | 6552 | ** |
| 6553 | ** Whether the update hook is invoked before or after the | ||
| 6554 | ** corresponding change is currently unspecified and may differ | ||
| 6555 | ** depending on the type of change. Do not rely on the order of the | ||
| 6556 | ** hook call with regards to the final result of the operation which | ||
| 6557 | ** triggers the hook. | ||
| 6558 | ** | ||
| 6466 | ** The update hook implementation must not do anything that will modify | 6559 | ** The update hook implementation must not do anything that will modify |
| 6467 | ** the database connection that invoked the update hook. Any actions | 6560 | ** the database connection that invoked the update hook. Any actions |
| 6468 | ** to modify the database connection must be deferred until after the | 6561 | ** to modify the database connection must be deferred until after the |
| @@ -6965,9 +7058,11 @@ struct sqlite3_module { | |||
| 6965 | ** will be returned by the strategy. | 7058 | ** will be returned by the strategy. |
| 6966 | ** | 7059 | ** |
| 6967 | ** The xBestIndex method may optionally populate the idxFlags field with a | 7060 | ** The xBestIndex method may optionally populate the idxFlags field with a |
| 6968 | ** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - | 7061 | ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is |
| 6969 | ** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite | 7062 | ** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN] |
| 6970 | ** assumes that the strategy may visit at most one row. | 7063 | ** output to show the idxNum has hex instead of as decimal. Another flag is |
| 7064 | ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will | ||
| 7065 | ** return at most one row. | ||
| 6971 | ** | 7066 | ** |
| 6972 | ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then | 7067 | ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then |
| 6973 | ** SQLite also assumes that if a call to the xUpdate() method is made as | 7068 | ** SQLite also assumes that if a call to the xUpdate() method is made as |
| @@ -7031,7 +7126,9 @@ struct sqlite3_index_info { | |||
| 7031 | ** [sqlite3_index_info].idxFlags field to some combination of | 7126 | ** [sqlite3_index_info].idxFlags field to some combination of |
| 7032 | ** these bits. | 7127 | ** these bits. |
| 7033 | */ | 7128 | */ |
| 7034 | #define SQLITE_INDEX_SCAN_UNIQUE 1 /* Scan visits at most 1 row */ | 7129 | #define SQLITE_INDEX_SCAN_UNIQUE 0x00000001 /* Scan visits at most 1 row */ |
| 7130 | #define SQLITE_INDEX_SCAN_HEX 0x00000002 /* Display idxNum as hex */ | ||
| 7131 | /* in EXPLAIN QUERY PLAN */ | ||
| 7035 | 7132 | ||
| 7036 | /* | 7133 | /* |
| 7037 | ** CAPI3REF: Virtual Table Constraint Operator Codes | 7134 | ** CAPI3REF: Virtual Table Constraint Operator Codes |
| @@ -7566,9 +7663,11 @@ typedef struct sqlite3_blob sqlite3_blob; | |||
| 7566 | ** | 7663 | ** |
| 7567 | ** ^(Some systems (for example, Windows 95) do not support the operation | 7664 | ** ^(Some systems (for example, Windows 95) do not support the operation |
| 7568 | ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() | 7665 | ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() |
| 7569 | ** will always return SQLITE_BUSY. The SQLite core only ever uses | 7666 | ** will always return SQLITE_BUSY. In most cases the SQLite core only uses |
| 7570 | ** sqlite3_mutex_try() as an optimization so this is acceptable | 7667 | ** sqlite3_mutex_try() as an optimization, so this is acceptable |
| 7571 | ** behavior.)^ | 7668 | ** behavior. The exceptions are unix builds that set the |
| 7669 | ** SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working | ||
| 7670 | ** sqlite3_mutex_try() is required.)^ | ||
| 7572 | ** | 7671 | ** |
| 7573 | ** ^The sqlite3_mutex_leave() routine exits a mutex that was | 7672 | ** ^The sqlite3_mutex_leave() routine exits a mutex that was |
| 7574 | ** previously entered by the same thread. The behavior | 7673 | ** previously entered by the same thread. The behavior |
| @@ -7817,8 +7916,10 @@ struct sqlite3_mutex_methods { | |||
| 7817 | #define SQLITE_TESTCTRL_ASSERT 12 | 7916 | #define SQLITE_TESTCTRL_ASSERT 12 |
| 7818 | #define SQLITE_TESTCTRL_ALWAYS 13 | 7917 | #define SQLITE_TESTCTRL_ALWAYS 13 |
| 7819 | #define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */ | 7918 | #define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */ |
| 7919 | #define SQLITE_TESTCTRL_JSON_SELFCHECK 14 | ||
| 7820 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 | 7920 | #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 |
| 7821 | #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ | 7921 | #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ |
| 7922 | #define SQLITE_TESTCTRL_GETOPT 16 | ||
| 7822 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ | 7923 | #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ |
| 7823 | #define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17 | 7924 | #define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17 |
| 7824 | #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 | 7925 | #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 |
| @@ -7838,7 +7939,7 @@ struct sqlite3_mutex_methods { | |||
| 7838 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 | 7939 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 |
| 7839 | #define SQLITE_TESTCTRL_TUNE 32 | 7940 | #define SQLITE_TESTCTRL_TUNE 32 |
| 7840 | #define SQLITE_TESTCTRL_LOGEST 33 | 7941 | #define SQLITE_TESTCTRL_LOGEST 33 |
| 7841 | #define SQLITE_TESTCTRL_USELONGDOUBLE 34 | 7942 | #define SQLITE_TESTCTRL_USELONGDOUBLE 34 /* NOT USED */ |
| 7842 | #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */ | 7943 | #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */ |
| 7843 | 7944 | ||
| 7844 | /* | 7945 | /* |
| @@ -7852,7 +7953,7 @@ struct sqlite3_mutex_methods { | |||
| 7852 | ** The sqlite3_keyword_count() interface returns the number of distinct | 7953 | ** The sqlite3_keyword_count() interface returns the number of distinct |
| 7853 | ** keywords understood by SQLite. | 7954 | ** keywords understood by SQLite. |
| 7854 | ** | 7955 | ** |
| 7855 | ** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and | 7956 | ** The sqlite3_keyword_name(N,Z,L) interface finds the 0-based N-th keyword and |
| 7856 | ** makes *Z point to that keyword expressed as UTF8 and writes the number | 7957 | ** makes *Z point to that keyword expressed as UTF8 and writes the number |
| 7857 | ** of bytes in the keyword into *L. The string that *Z points to is not | 7958 | ** of bytes in the keyword into *L. The string that *Z points to is not |
| 7858 | ** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns | 7959 | ** zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns |
| @@ -8791,6 +8892,16 @@ typedef struct sqlite3_backup sqlite3_backup; | |||
| 8791 | ** APIs are not strictly speaking threadsafe. If they are invoked at the | 8892 | ** APIs are not strictly speaking threadsafe. If they are invoked at the |
| 8792 | ** same time as another thread is invoking sqlite3_backup_step() it is | 8893 | ** same time as another thread is invoking sqlite3_backup_step() it is |
| 8793 | ** possible that they return invalid values. | 8894 | ** possible that they return invalid values. |
| 8895 | ** | ||
| 8896 | ** <b>Alternatives To Using The Backup API</b> | ||
| 8897 | ** | ||
| 8898 | ** Other techniques for safely creating a consistent backup of an SQLite | ||
| 8899 | ** database include: | ||
| 8900 | ** | ||
| 8901 | ** <ul> | ||
| 8902 | ** <li> The [VACUUM INTO] command. | ||
| 8903 | ** <li> The [sqlite3_rsync] utility program. | ||
| 8904 | ** </ul> | ||
| 8794 | */ | 8905 | */ |
| 8795 | 8906 | ||
| 8796 | /* | 8907 | /* |
| @@ -9370,24 +9481,45 @@ typedef struct sqlite3_backup sqlite3_backup; | |||
| 9370 | ** <li value="2"><p> | 9481 | ** <li value="2"><p> |
| 9371 | ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means | 9482 | ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means |
| 9372 | ** that the query planner does not need the rows returned in any particular | 9483 | ** that the query planner does not need the rows returned in any particular |
| 9373 | ** order, as long as rows with the same values in all "aOrderBy" columns | 9484 | ** order, as long as rows with the same values in all columns identified |
| 9374 | ** are adjacent.)^ ^(Furthermore, only a single row for each particular | 9485 | ** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows |
| 9375 | ** combination of values in the columns identified by the "aOrderBy" field | 9486 | ** contain the same values for all columns identified by "colUsed", all but |
| 9376 | ** needs to be returned.)^ ^It is always ok for two or more rows with the same | 9487 | ** one such row may optionally be omitted from the result.)^ |
| 9377 | ** values in all "aOrderBy" columns to be returned, as long as all such rows | 9488 | ** The virtual table is not required to omit rows that are duplicates |
| 9378 | ** are adjacent. ^The virtual table may, if it chooses, omit extra rows | 9489 | ** over the "colUsed" columns, but if the virtual table can do that without |
| 9379 | ** that have the same value for all columns identified by "aOrderBy". | 9490 | ** too much extra effort, it could potentially help the query to run faster. |
| 9380 | ** ^However omitting the extra rows is optional. | ||
| 9381 | ** This mode is used for a DISTINCT query. | 9491 | ** This mode is used for a DISTINCT query. |
| 9382 | ** <li value="3"><p> | 9492 | ** <li value="3"><p> |
| 9383 | ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means | 9493 | ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the |
| 9384 | ** that the query planner needs only distinct rows but it does need the | 9494 | ** virtual table must return rows in the order defined by "aOrderBy" as |
| 9385 | ** rows to be sorted.)^ ^The virtual table implementation is free to omit | 9495 | ** if the sqlite3_vtab_distinct() interface had returned 0. However if |
| 9386 | ** rows that are identical in all aOrderBy columns, if it wants to, but | 9496 | ** two or more rows in the result have the same values for all columns |
| 9387 | ** it is not required to omit any rows. This mode is used for queries | 9497 | ** identified by "colUsed", then all but one such row may optionally be |
| 9498 | ** omitted.)^ Like when the return value is 2, the virtual table | ||
| 9499 | ** is not required to omit rows that are duplicates over the "colUsed" | ||
| 9500 | ** columns, but if the virtual table can do that without | ||
| 9501 | ** too much extra effort, it could potentially help the query to run faster. | ||
| 9502 | ** This mode is used for queries | ||
| 9388 | ** that have both DISTINCT and ORDER BY clauses. | 9503 | ** that have both DISTINCT and ORDER BY clauses. |
| 9389 | ** </ol> | 9504 | ** </ol> |
| 9390 | ** | 9505 | ** |
| 9506 | ** <p>The following table summarizes the conditions under which the | ||
| 9507 | ** virtual table is allowed to set the "orderByConsumed" flag based on | ||
| 9508 | ** the value returned by sqlite3_vtab_distinct(). This table is a | ||
| 9509 | ** restatement of the previous four paragraphs: | ||
| 9510 | ** | ||
| 9511 | ** <table border=1 cellspacing=0 cellpadding=10 width="90%"> | ||
| 9512 | ** <tr> | ||
| 9513 | ** <td valign="top">sqlite3_vtab_distinct() return value | ||
| 9514 | ** <td valign="top">Rows are returned in aOrderBy order | ||
| 9515 | ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent | ||
| 9516 | ** <td valign="top">Duplicates over all colUsed columns may be omitted | ||
| 9517 | ** <tr><td>0<td>yes<td>yes<td>no | ||
| 9518 | ** <tr><td>1<td>no<td>yes<td>no | ||
| 9519 | ** <tr><td>2<td>no<td>yes<td>yes | ||
| 9520 | ** <tr><td>3<td>yes<td>yes<td>yes | ||
| 9521 | ** </table> | ||
| 9522 | ** | ||
| 9391 | ** ^For the purposes of comparing virtual table output values to see if the | 9523 | ** ^For the purposes of comparing virtual table output values to see if the |
| 9392 | ** values are same value for sorting purposes, two NULL values are considered | 9524 | ** values are same value for sorting purposes, two NULL values are considered |
| 9393 | ** to be the same. In other words, the comparison operator is "IS" | 9525 | ** to be the same. In other words, the comparison operator is "IS" |
| @@ -9892,6 +10024,14 @@ typedef struct sqlite3_snapshot { | |||
| 9892 | ** If there is not already a read-transaction open on schema S when | 10024 | ** If there is not already a read-transaction open on schema S when |
| 9893 | ** this function is called, one is opened automatically. | 10025 | ** this function is called, one is opened automatically. |
| 9894 | ** | 10026 | ** |
| 10027 | ** If a read-transaction is opened by this function, then it is guaranteed | ||
| 10028 | ** that the returned snapshot object may not be invalidated by a database | ||
| 10029 | ** writer or checkpointer until after the read-transaction is closed. This | ||
| 10030 | ** is not guaranteed if a read-transaction is already open when this | ||
| 10031 | ** function is called. In that case, any subsequent write or checkpoint | ||
| 10032 | ** operation on the database may invalidate the returned snapshot handle, | ||
| 10033 | ** even while the read-transaction remains open. | ||
| 10034 | ** | ||
| 9895 | ** The following must be true for this function to succeed. If any of | 10035 | ** The following must be true for this function to succeed. If any of |
| 9896 | ** the following statements are false when sqlite3_snapshot_get() is | 10036 | ** the following statements are false when sqlite3_snapshot_get() is |
| 9897 | ** called, SQLITE_ERROR is returned. The final value of *P is undefined | 10037 | ** called, SQLITE_ERROR is returned. The final value of *P is undefined |
| @@ -10170,8 +10310,6 @@ typedef struct sqlite3_snapshot { | |||
| 10170 | #if defined(__wasi__) | 10310 | #if defined(__wasi__) |
| 10171 | # undef SQLITE_WASI | 10311 | # undef SQLITE_WASI |
| 10172 | # define SQLITE_WASI 1 | 10312 | # define SQLITE_WASI 1 |
| 10173 | # undef SQLITE_OMIT_WAL | ||
| 10174 | # define SQLITE_OMIT_WAL 1/* because it requires shared memory APIs */ | ||
| 10175 | # ifndef SQLITE_OMIT_LOAD_EXTENSION | 10313 | # ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 10176 | # define SQLITE_OMIT_LOAD_EXTENSION | 10314 | # define SQLITE_OMIT_LOAD_EXTENSION |
| 10177 | # endif | 10315 | # endif |
| @@ -11246,6 +11384,26 @@ typedef struct sqlite3_changegroup sqlite3_changegroup; | |||
| 11246 | */ | 11384 | */ |
| 11247 | 11385 | ||
| 11248 | /* | 11386 | /* |
| 11387 | ** CAPI3REF: Add A Single Change To A Changegroup | ||
| 11388 | ** METHOD: sqlite3_changegroup | ||
| 11389 | ** | ||
| 11390 | ** This function adds the single change currently indicated by the iterator | ||
| 11391 | ** passed as the second argument to the changegroup object. The rules for | ||
| 11392 | ** adding the change are just as described for [sqlite3changegroup_add()]. | ||
| 11393 | ** | ||
| 11394 | ** If the change is successfully added to the changegroup, SQLITE_OK is | ||
| 11395 | ** returned. Otherwise, an SQLite error code is returned. | ||
| 11396 | ** | ||
| 11397 | ** The iterator must point to a valid entry when this function is called. | ||
| 11398 | ** If it does not, SQLITE_ERROR is returned and no change is added to the | ||
| 11399 | ** changegroup. Additionally, the iterator must not have been opened with | ||
| 11400 | ** the SQLITE_CHANGESETAPPLY_INVERT flag. In this case SQLITE_ERROR is also | ||
| 11401 | ** returned. | ||
| 11402 | */ | ||
| 11403 | |||
| 11404 | |||
| 11405 | |||
| 11406 | /* | ||
| 11249 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup | 11407 | ** CAPI3REF: Obtain A Composite Changeset From A Changegroup |
| 11250 | ** METHOD: sqlite3_changegroup | 11408 | ** METHOD: sqlite3_changegroup |
| 11251 | ** | 11409 | ** |
| @@ -11917,8 +12075,8 @@ struct Fts5PhraseIter { | |||
| 11917 | ** EXTENSION API FUNCTIONS | 12075 | ** EXTENSION API FUNCTIONS |
| 11918 | ** | 12076 | ** |
| 11919 | ** xUserData(pFts): | 12077 | ** xUserData(pFts): |
| 11920 | ** Return a copy of the context pointer the extension function was | 12078 | ** Return a copy of the pUserData pointer passed to the xCreateFunction() |
| 11921 | ** registered with. | 12079 | ** API when the extension function was registered. |
| 11922 | ** | 12080 | ** |
| 11923 | ** xColumnTotalSize(pFts, iCol, pnToken): | 12081 | ** xColumnTotalSize(pFts, iCol, pnToken): |
| 11924 | ** If parameter iCol is less than zero, set output variable *pnToken | 12082 | ** If parameter iCol is less than zero, set output variable *pnToken |
| @@ -11950,8 +12108,11 @@ struct Fts5PhraseIter { | |||
| 11950 | ** created with the "columnsize=0" option. | 12108 | ** created with the "columnsize=0" option. |
| 11951 | ** | 12109 | ** |
| 11952 | ** xColumnText: | 12110 | ** xColumnText: |
| 11953 | ** This function attempts to retrieve the text of column iCol of the | 12111 | ** If parameter iCol is less than zero, or greater than or equal to the |
| 11954 | ** current document. If successful, (*pz) is set to point to a buffer | 12112 | ** number of columns in the table, SQLITE_RANGE is returned. |
| 12113 | ** | ||
| 12114 | ** Otherwise, this function attempts to retrieve the text of column iCol of | ||
| 12115 | ** the current document. If successful, (*pz) is set to point to a buffer | ||
| 11955 | ** containing the text in utf-8 encoding, (*pn) is set to the size in bytes | 12116 | ** containing the text in utf-8 encoding, (*pn) is set to the size in bytes |
| 11956 | ** (not characters) of the buffer and SQLITE_OK is returned. Otherwise, | 12117 | ** (not characters) of the buffer and SQLITE_OK is returned. Otherwise, |
| 11957 | ** if an error occurs, an SQLite error code is returned and the final values | 12118 | ** if an error occurs, an SQLite error code is returned and the final values |
| @@ -11961,8 +12122,10 @@ struct Fts5PhraseIter { | |||
| 11961 | ** Returns the number of phrases in the current query expression. | 12122 | ** Returns the number of phrases in the current query expression. |
| 11962 | ** | 12123 | ** |
| 11963 | ** xPhraseSize: | 12124 | ** xPhraseSize: |
| 11964 | ** Returns the number of tokens in phrase iPhrase of the query. Phrases | 12125 | ** If parameter iCol is less than zero, or greater than or equal to the |
| 11965 | ** are numbered starting from zero. | 12126 | ** number of phrases in the current query, as returned by xPhraseCount, |
| 12127 | ** 0 is returned. Otherwise, this function returns the number of tokens in | ||
| 12128 | ** phrase iPhrase of the query. Phrases are numbered starting from zero. | ||
| 11966 | ** | 12129 | ** |
| 11967 | ** xInstCount: | 12130 | ** xInstCount: |
| 11968 | ** Set *pnInst to the total number of occurrences of all phrases within | 12131 | ** Set *pnInst to the total number of occurrences of all phrases within |
| @@ -11978,12 +12141,13 @@ struct Fts5PhraseIter { | |||
| 11978 | ** Query for the details of phrase match iIdx within the current row. | 12141 | ** Query for the details of phrase match iIdx within the current row. |
| 11979 | ** Phrase matches are numbered starting from zero, so the iIdx argument | 12142 | ** Phrase matches are numbered starting from zero, so the iIdx argument |
| 11980 | ** should be greater than or equal to zero and smaller than the value | 12143 | ** should be greater than or equal to zero and smaller than the value |
| 11981 | ** output by xInstCount(). | 12144 | ** output by xInstCount(). If iIdx is less than zero or greater than |
| 12145 | ** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned. | ||
| 11982 | ** | 12146 | ** |
| 11983 | ** Usually, output parameter *piPhrase is set to the phrase number, *piCol | 12147 | ** Otherwise, output parameter *piPhrase is set to the phrase number, *piCol |
| 11984 | ** to the column in which it occurs and *piOff the token offset of the | 12148 | ** to the column in which it occurs and *piOff the token offset of the |
| 11985 | ** first token of the phrase. Returns SQLITE_OK if successful, or an error | 12149 | ** first token of the phrase. SQLITE_OK is returned if successful, or an |
| 11986 | ** code (i.e. SQLITE_NOMEM) if an error occurs. | 12150 | ** error code (i.e. SQLITE_NOMEM) if an error occurs. |
| 11987 | ** | 12151 | ** |
| 11988 | ** This API can be quite slow if used with an FTS5 table created with the | 12152 | ** This API can be quite slow if used with an FTS5 table created with the |
| 11989 | ** "detail=none" or "detail=column" option. | 12153 | ** "detail=none" or "detail=column" option. |
| @@ -12009,6 +12173,10 @@ struct Fts5PhraseIter { | |||
| 12009 | ** Invoking Api.xUserData() returns a copy of the pointer passed as | 12173 | ** Invoking Api.xUserData() returns a copy of the pointer passed as |
| 12010 | ** the third argument to pUserData. | 12174 | ** the third argument to pUserData. |
| 12011 | ** | 12175 | ** |
| 12176 | ** If parameter iPhrase is less than zero, or greater than or equal to | ||
| 12177 | ** the number of phrases in the query, as returned by xPhraseCount(), | ||
| 12178 | ** this function returns SQLITE_RANGE. | ||
| 12179 | ** | ||
| 12012 | ** If the callback function returns any value other than SQLITE_OK, the | 12180 | ** If the callback function returns any value other than SQLITE_OK, the |
| 12013 | ** query is abandoned and the xQueryPhrase function returns immediately. | 12181 | ** query is abandoned and the xQueryPhrase function returns immediately. |
| 12014 | ** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. | 12182 | ** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. |
| @@ -12090,6 +12258,10 @@ struct Fts5PhraseIter { | |||
| 12090 | ** (i.e. if it is a contentless table), then this API always iterates | 12258 | ** (i.e. if it is a contentless table), then this API always iterates |
| 12091 | ** through an empty set (all calls to xPhraseFirst() set iCol to -1). | 12259 | ** through an empty set (all calls to xPhraseFirst() set iCol to -1). |
| 12092 | ** | 12260 | ** |
| 12261 | ** In all cases, matches are visited in (column ASC, offset ASC) order. | ||
| 12262 | ** i.e. all those in column 0, sorted by offset, followed by those in | ||
| 12263 | ** column 1, etc. | ||
| 12264 | ** | ||
| 12093 | ** xPhraseNext() | 12265 | ** xPhraseNext() |
| 12094 | ** See xPhraseFirst above. | 12266 | ** See xPhraseFirst above. |
| 12095 | ** | 12267 | ** |
| @@ -12123,9 +12295,65 @@ struct Fts5PhraseIter { | |||
| 12123 | ** | 12295 | ** |
| 12124 | ** xPhraseNextColumn() | 12296 | ** xPhraseNextColumn() |
| 12125 | ** See xPhraseFirstColumn above. | 12297 | ** See xPhraseFirstColumn above. |
| 12298 | ** | ||
| 12299 | ** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken) | ||
| 12300 | ** This is used to access token iToken of phrase iPhrase of the current | ||
| 12301 | ** query. Before returning, output parameter *ppToken is set to point | ||
| 12302 | ** to a buffer containing the requested token, and *pnToken to the | ||
| 12303 | ** size of this buffer in bytes. | ||
| 12304 | ** | ||
| 12305 | ** If iPhrase or iToken are less than zero, or if iPhrase is greater than | ||
| 12306 | ** or equal to the number of phrases in the query as reported by | ||
| 12307 | ** xPhraseCount(), or if iToken is equal to or greater than the number of | ||
| 12308 | ** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken | ||
| 12309 | are both zeroed. | ||
| 12310 | ** | ||
| 12311 | ** The output text is not a copy of the query text that specified the | ||
| 12312 | ** token. It is the output of the tokenizer module. For tokendata=1 | ||
| 12313 | ** tables, this includes any embedded 0x00 and trailing data. | ||
| 12314 | ** | ||
| 12315 | ** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) | ||
| 12316 | ** This is used to access token iToken of phrase hit iIdx within the | ||
| 12317 | ** current row. If iIdx is less than zero or greater than or equal to the | ||
| 12318 | ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, | ||
| 12319 | ** output variable (*ppToken) is set to point to a buffer containing the | ||
| 12320 | ** matching document token, and (*pnToken) to the size of that buffer in | ||
| 12321 | ** bytes. This API is not available if the specified token matches a | ||
| 12322 | ** prefix query term. In that case both output variables are always set | ||
| 12323 | ** to 0. | ||
| 12324 | ** | ||
| 12325 | ** The output text is not a copy of the document text that was tokenized. | ||
| 12326 | ** It is the output of the tokenizer module. For tokendata=1 tables, this | ||
| 12327 | ** includes any embedded 0x00 and trailing data. | ||
| 12328 | ** | ||
| 12329 | ** This API can be quite slow if used with an FTS5 table created with the | ||
| 12330 | ** "detail=none" or "detail=column" option. | ||
| 12331 | ** | ||
| 12332 | ** xColumnLocale(pFts5, iIdx, pzLocale, pnLocale) | ||
| 12333 | ** If parameter iCol is less than zero, or greater than or equal to the | ||
| 12334 | ** number of columns in the table, SQLITE_RANGE is returned. | ||
| 12335 | ** | ||
| 12336 | ** Otherwise, this function attempts to retrieve the locale associated | ||
| 12337 | ** with column iCol of the current row. Usually, there is no associated | ||
| 12338 | ** locale, and output parameters (*pzLocale) and (*pnLocale) are set | ||
| 12339 | ** to NULL and 0, respectively. However, if the fts5_locale() function | ||
| 12340 | ** was used to associate a locale with the value when it was inserted | ||
| 12341 | ** into the fts5 table, then (*pzLocale) is set to point to a nul-terminated | ||
| 12342 | ** buffer containing the name of the locale in utf-8 encoding. (*pnLocale) | ||
| 12343 | ** is set to the size in bytes of the buffer, not including the | ||
| 12344 | ** nul-terminator. | ||
| 12345 | ** | ||
| 12346 | ** If successful, SQLITE_OK is returned. Or, if an error occurs, an | ||
| 12347 | ** SQLite error code is returned. The final value of the output parameters | ||
| 12348 | ** is undefined in this case. | ||
| 12349 | ** | ||
| 12350 | ** xTokenize_v2: | ||
| 12351 | ** Tokenize text using the tokenizer belonging to the FTS5 table. This | ||
| 12352 | ** API is the same as the xTokenize() API, except that it allows a tokenizer | ||
| 12353 | ** locale to be specified. | ||
| 12126 | */ | 12354 | */ |
| 12127 | struct Fts5ExtensionApi { | 12355 | struct Fts5ExtensionApi { |
| 12128 | int iVersion; /* Currently always set to 2 */ | 12356 | int iVersion; /* Currently always set to 4 */ |
| 12129 | 12357 | ||
| 12130 | void *(*xUserData)(Fts5Context*); | 12358 | void *(*xUserData)(Fts5Context*); |
| 12131 | 12359 | ||
| @@ -12160,6 +12388,22 @@ struct Fts5ExtensionApi { | |||
| 12160 | 12388 | ||
| 12161 | int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); | 12389 | int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); |
| 12162 | void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); | 12390 | void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); |
| 12391 | |||
| 12392 | /* Below this point are iVersion>=3 only */ | ||
| 12393 | int (*xQueryToken)(Fts5Context*, | ||
| 12394 | int iPhrase, int iToken, | ||
| 12395 | const char **ppToken, int *pnToken | ||
| 12396 | ); | ||
| 12397 | int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*); | ||
| 12398 | |||
| 12399 | /* Below this point are iVersion>=4 only */ | ||
| 12400 | int (*xColumnLocale)(Fts5Context*, int iCol, const char **pz, int *pn); | ||
| 12401 | int (*xTokenize_v2)(Fts5Context*, | ||
| 12402 | const char *pText, int nText, /* Text to tokenize */ | ||
| 12403 | const char *pLocale, int nLocale, /* Locale to pass to tokenizer */ | ||
| 12404 | void *pCtx, /* Context passed to xToken() */ | ||
| 12405 | int (*xToken)(void*, int, const char*, int, int, int) /* Callback */ | ||
| 12406 | ); | ||
| 12163 | }; | 12407 | }; |
| 12164 | 12408 | ||
| 12165 | /* | 12409 | /* |
| @@ -12180,7 +12424,7 @@ struct Fts5ExtensionApi { | |||
| 12180 | ** A tokenizer instance is required to actually tokenize text. | 12424 | ** A tokenizer instance is required to actually tokenize text. |
| 12181 | ** | 12425 | ** |
| 12182 | ** The first argument passed to this function is a copy of the (void*) | 12426 | ** The first argument passed to this function is a copy of the (void*) |
| 12183 | ** pointer provided by the application when the fts5_tokenizer object | 12427 | ** pointer provided by the application when the fts5_tokenizer_v2 object |
| 12184 | ** was registered with FTS5 (the third argument to xCreateTokenizer()). | 12428 | ** was registered with FTS5 (the third argument to xCreateTokenizer()). |
| 12185 | ** The second and third arguments are an array of nul-terminated strings | 12429 | ** The second and third arguments are an array of nul-terminated strings |
| 12186 | ** containing the tokenizer arguments, if any, specified following the | 12430 | ** containing the tokenizer arguments, if any, specified following the |
| @@ -12204,7 +12448,7 @@ struct Fts5ExtensionApi { | |||
| 12204 | ** argument passed to this function is a pointer to an Fts5Tokenizer object | 12448 | ** argument passed to this function is a pointer to an Fts5Tokenizer object |
| 12205 | ** returned by an earlier call to xCreate(). | 12449 | ** returned by an earlier call to xCreate(). |
| 12206 | ** | 12450 | ** |
| 12207 | ** The second argument indicates the reason that FTS5 is requesting | 12451 | ** The third argument indicates the reason that FTS5 is requesting |
| 12208 | ** tokenization of the supplied text. This is always one of the following | 12452 | ** tokenization of the supplied text. This is always one of the following |
| 12209 | ** four values: | 12453 | ** four values: |
| 12210 | ** | 12454 | ** |
| @@ -12228,6 +12472,13 @@ struct Fts5ExtensionApi { | |||
| 12228 | ** on a columnsize=0 database. | 12472 | ** on a columnsize=0 database. |
| 12229 | ** </ul> | 12473 | ** </ul> |
| 12230 | ** | 12474 | ** |
| 12475 | ** The sixth and seventh arguments passed to xTokenize() - pLocale and | ||
| 12476 | ** nLocale - are a pointer to a buffer containing the locale to use for | ||
| 12477 | ** tokenization (e.g. "en_US") and its size in bytes, respectively. The | ||
| 12478 | ** pLocale buffer is not nul-terminated. pLocale may be passed NULL (in | ||
| 12479 | ** which case nLocale is always 0) to indicate that the tokenizer should | ||
| 12480 | ** use its default locale. | ||
| 12481 | ** | ||
| 12231 | ** For each token in the input string, the supplied callback xToken() must | 12482 | ** For each token in the input string, the supplied callback xToken() must |
| 12232 | ** be invoked. The first argument to it should be a copy of the pointer | 12483 | ** be invoked. The first argument to it should be a copy of the pointer |
| 12233 | ** passed as the second argument to xTokenize(). The third and fourth | 12484 | ** passed as the second argument to xTokenize(). The third and fourth |
| @@ -12251,6 +12502,30 @@ struct Fts5ExtensionApi { | |||
| 12251 | ** may abandon the tokenization and return any error code other than | 12502 | ** may abandon the tokenization and return any error code other than |
| 12252 | ** SQLITE_OK or SQLITE_DONE. | 12503 | ** SQLITE_OK or SQLITE_DONE. |
| 12253 | ** | 12504 | ** |
| 12505 | ** If the tokenizer is registered using an fts5_tokenizer_v2 object, | ||
| 12506 | ** then the xTokenize() method has two additional arguments - pLocale | ||
| 12507 | ** and nLocale. These specify the locale that the tokenizer should use | ||
| 12508 | ** for the current request. If pLocale and nLocale are both 0, then the | ||
| 12509 | ** tokenizer should use its default locale. Otherwise, pLocale points to | ||
| 12510 | ** an nLocale byte buffer containing the name of the locale to use as utf-8 | ||
| 12511 | ** text. pLocale is not nul-terminated. | ||
| 12512 | ** | ||
| 12513 | ** FTS5_TOKENIZER | ||
| 12514 | ** | ||
| 12515 | ** There is also an fts5_tokenizer object. This is an older, deprecated, | ||
| 12516 | ** version of fts5_tokenizer_v2. It is similar except that: | ||
| 12517 | ** | ||
| 12518 | ** <ul> | ||
| 12519 | ** <li> There is no "iVersion" field, and | ||
| 12520 | ** <li> The xTokenize() method does not take a locale argument. | ||
| 12521 | ** </ul> | ||
| 12522 | ** | ||
| 12523 | ** Legacy fts5_tokenizer tokenizers must be registered using the | ||
| 12524 | ** legacy xCreateTokenizer() function, instead of xCreateTokenizer_v2(). | ||
| 12525 | ** | ||
| 12526 | ** Tokenizer implementations registered using either API may be retrieved | ||
| 12527 | ** using both xFindTokenizer() and xFindTokenizer_v2(). | ||
| 12528 | ** | ||
| 12254 | ** SYNONYM SUPPORT | 12529 | ** SYNONYM SUPPORT |
| 12255 | ** | 12530 | ** |
| 12256 | ** Custom tokenizers may also support synonyms. Consider a case in which a | 12531 | ** Custom tokenizers may also support synonyms. Consider a case in which a |
| @@ -12359,6 +12634,33 @@ struct Fts5ExtensionApi { | |||
| 12359 | ** inefficient. | 12634 | ** inefficient. |
| 12360 | */ | 12635 | */ |
| 12361 | typedef struct Fts5Tokenizer Fts5Tokenizer; | 12636 | typedef struct Fts5Tokenizer Fts5Tokenizer; |
| 12637 | typedef struct fts5_tokenizer_v2 fts5_tokenizer_v2; | ||
| 12638 | struct fts5_tokenizer_v2 { | ||
| 12639 | int iVersion; /* Currently always 2 */ | ||
| 12640 | |||
| 12641 | int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); | ||
| 12642 | void (*xDelete)(Fts5Tokenizer*); | ||
| 12643 | int (*xTokenize)(Fts5Tokenizer*, | ||
| 12644 | void *pCtx, | ||
| 12645 | int flags, /* Mask of FTS5_TOKENIZE_* flags */ | ||
| 12646 | const char *pText, int nText, | ||
| 12647 | const char *pLocale, int nLocale, | ||
| 12648 | int (*xToken)( | ||
| 12649 | void *pCtx, /* Copy of 2nd argument to xTokenize() */ | ||
| 12650 | int tflags, /* Mask of FTS5_TOKEN_* flags */ | ||
| 12651 | const char *pToken, /* Pointer to buffer containing token */ | ||
| 12652 | int nToken, /* Size of token in bytes */ | ||
| 12653 | int iStart, /* Byte offset of token within input text */ | ||
| 12654 | int iEnd /* Byte offset of end of token within input text */ | ||
| 12655 | ) | ||
| 12656 | ); | ||
| 12657 | }; | ||
| 12658 | |||
| 12659 | /* | ||
| 12660 | ** New code should use the fts5_tokenizer_v2 type to define tokenizer | ||
| 12661 | ** implementations. The following type is included for legacy applications | ||
| 12662 | ** that still use it. | ||
| 12663 | */ | ||
| 12362 | typedef struct fts5_tokenizer fts5_tokenizer; | 12664 | typedef struct fts5_tokenizer fts5_tokenizer; |
| 12363 | struct fts5_tokenizer { | 12665 | struct fts5_tokenizer { |
| 12364 | int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); | 12666 | int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut); |
| @@ -12378,6 +12680,7 @@ struct fts5_tokenizer { | |||
| 12378 | ); | 12680 | ); |
| 12379 | }; | 12681 | }; |
| 12380 | 12682 | ||
| 12683 | |||
| 12381 | /* Flags that may be passed as the third argument to xTokenize() */ | 12684 | /* Flags that may be passed as the third argument to xTokenize() */ |
| 12382 | #define FTS5_TOKENIZE_QUERY 0x0001 | 12685 | #define FTS5_TOKENIZE_QUERY 0x0001 |
| 12383 | #define FTS5_TOKENIZE_PREFIX 0x0002 | 12686 | #define FTS5_TOKENIZE_PREFIX 0x0002 |
| @@ -12397,7 +12700,7 @@ struct fts5_tokenizer { | |||
| 12397 | */ | 12700 | */ |
| 12398 | typedef struct fts5_api fts5_api; | 12701 | typedef struct fts5_api fts5_api; |
| 12399 | struct fts5_api { | 12702 | struct fts5_api { |
| 12400 | int iVersion; /* Currently always set to 2 */ | 12703 | int iVersion; /* Currently always set to 3 */ |
| 12401 | 12704 | ||
| 12402 | /* Create a new tokenizer */ | 12705 | /* Create a new tokenizer */ |
| 12403 | int (*xCreateTokenizer)( | 12706 | int (*xCreateTokenizer)( |
| @@ -12424,6 +12727,25 @@ struct fts5_api { | |||
| 12424 | fts5_extension_function xFunction, | 12727 | fts5_extension_function xFunction, |
| 12425 | void (*xDestroy)(void*) | 12728 | void (*xDestroy)(void*) |
| 12426 | ); | 12729 | ); |
| 12730 | |||
| 12731 | /* APIs below this point are only available if iVersion>=3 */ | ||
| 12732 | |||
| 12733 | /* Create a new tokenizer */ | ||
| 12734 | int (*xCreateTokenizer_v2)( | ||
| 12735 | fts5_api *pApi, | ||
| 12736 | const char *zName, | ||
| 12737 | void *pUserData, | ||
| 12738 | fts5_tokenizer_v2 *pTokenizer, | ||
| 12739 | void (*xDestroy)(void*) | ||
| 12740 | ); | ||
| 12741 | |||
| 12742 | /* Find an existing tokenizer */ | ||
| 12743 | int (*xFindTokenizer_v2)( | ||
| 12744 | fts5_api *pApi, | ||
| 12745 | const char *zName, | ||
| 12746 | void **ppUserData, | ||
| 12747 | fts5_tokenizer_v2 **ppTokenizer | ||
| 12748 | ); | ||
| 12427 | }; | 12749 | }; |
| 12428 | 12750 | ||
| 12429 | /* | 12751 | /* |