cordova-sqlite-evmax-build-free 0.0.4 → 0.0.6-voltbuild-test01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGES.md +29 -1
  2. package/README.md +37 -32
  3. package/package.json +4 -7
  4. package/plugin.xml +21 -6
  5. package/spec/www/index.html +1 -0
  6. package/spec/www/spec/blobfrombase64-test.js +159 -0
  7. package/spec/www/spec/db-open-close-delete-test.js +3 -1
  8. package/spec/www/spec/db-tx-string-test.js +10 -13
  9. package/spec/www/spec/db-tx-value-bindings-test.js +6 -7
  10. package/spec/www/spec/sqlite-version-test.js +4 -1
  11. package/src/android/io/sqlc/SQLitePlugin.java +6 -3
  12. package/src/deps/android/sqlc-evplus-ndk-driver.jar +0 -0
  13. package/src/deps/common/{libb64-encode → libb64-core}/LICENSE +0 -0
  14. package/src/deps/common/libb64-core/README.md +31 -0
  15. package/src/deps/common/libb64-core/cdecode.c +93 -0
  16. package/src/deps/common/libb64-core/cdecode.h +29 -0
  17. package/src/deps/common/{libb64-encode → libb64-core}/cencode.c +0 -0
  18. package/src/deps/common/{libb64-encode → libb64-core}/cencode.h +0 -0
  19. package/src/deps/common/sqlite3-base64/README.md +18 -4
  20. package/src/deps/common/sqlite3-base64/sqlite3_base64.c +37 -2
  21. package/src/deps/common/sqlite3.c +13097 -7056
  22. package/src/deps/common/sqlite3.h +459 -64
  23. package/src/windows/SQLite3-WinRT-sync/SQLite3/SQLite3.Shared.vcxitems +7 -3
  24. package/src/windows/SQLite3-WinRT-sync/SQLite3/SQLite3.UWP.vcxproj +2 -2
  25. package/src/windows/SQLite3-WinRT-sync/SQLite3/SQLite3.sln +0 -4
  26. package/src/windows/libs/x64/BarcodeComponent.winmd +0 -0
  27. package/src/windows/libs/x64/SQLite3.UWP.dll +0 -0
  28. package/src/windows/libs/x64/SQLite3.winmd +0 -0
  29. package/src/windows/libs/x86/BarcodeComponent.winmd +0 -0
  30. package/src/windows/libs/x86/SQLite3.UWP.dll +0 -0
  31. package/src/windows/libs/x86/SQLite3.winmd +0 -0
  32. package/src/deps/common/libb64-encode/README.md +0 -27
@@ -146,9 +146,9 @@ extern "C" {
146
146
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
147
  ** [sqlite_version()] and [sqlite_source_id()].
148
148
  */
149
- #define SQLITE_VERSION "3.37.2"
150
- #define SQLITE_VERSION_NUMBER 3037002
151
- #define SQLITE_SOURCE_ID "2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0"
149
+ #define SQLITE_VERSION "3.40.0"
150
+ #define SQLITE_VERSION_NUMBER 3040000
151
+ #define SQLITE_SOURCE_ID "2022-11-16 12:10:08 89c459e766ea7e9165d0beeb124708b955a4950d0f4792f457465d71b158d318"
152
152
 
153
153
  /*
154
154
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -566,7 +566,7 @@ SQLITE_API int sqlite3_exec(
566
566
  #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
567
567
  #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
568
568
  #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
569
- #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
569
+ #define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
570
570
 
571
571
  /*
572
572
  ** CAPI3REF: Flags For File Open Operations
@@ -670,13 +670,17 @@ SQLITE_API int sqlite3_exec(
670
670
  **
671
671
  ** SQLite uses one of these integer values as the second
672
672
  ** argument to calls it makes to the xLock() and xUnlock() methods
673
- ** of an [sqlite3_io_methods] object.
673
+ ** of an [sqlite3_io_methods] object. These values are ordered from
674
+ ** lest restrictive to most restrictive.
675
+ **
676
+ ** The argument to xLock() is always SHARED or higher. The argument to
677
+ ** xUnlock is either SHARED or NONE.
674
678
  */
675
- #define SQLITE_LOCK_NONE 0
676
- #define SQLITE_LOCK_SHARED 1
677
- #define SQLITE_LOCK_RESERVED 2
678
- #define SQLITE_LOCK_PENDING 3
679
- #define SQLITE_LOCK_EXCLUSIVE 4
679
+ #define SQLITE_LOCK_NONE 0 /* xUnlock() only */
680
+ #define SQLITE_LOCK_SHARED 1 /* xLock() or xUnlock() */
681
+ #define SQLITE_LOCK_RESERVED 2 /* xLock() only */
682
+ #define SQLITE_LOCK_PENDING 3 /* xLock() only */
683
+ #define SQLITE_LOCK_EXCLUSIVE 4 /* xLock() only */
680
684
 
681
685
  /*
682
686
  ** CAPI3REF: Synchronization Type Flags
@@ -754,7 +758,14 @@ struct sqlite3_file {
754
758
  ** <li> [SQLITE_LOCK_PENDING], or
755
759
  ** <li> [SQLITE_LOCK_EXCLUSIVE].
756
760
  ** </ul>
757
- ** xLock() increases the lock. xUnlock() decreases the lock.
761
+ ** xLock() upgrades the database file lock. In other words, xLock() moves the
762
+ ** database file lock in the direction NONE toward EXCLUSIVE. The argument to
763
+ ** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
764
+ ** SQLITE_LOCK_NONE. If the database file lock is already at or above the
765
+ ** requested lock, then the call to xLock() is a no-op.
766
+ ** xUnlock() downgrades the database file lock to either SHARED or NONE.
767
+ * If the lock is already at or below the requested lock state, then the call
768
+ ** to xUnlock() is a no-op.
758
769
  ** The xCheckReservedLock() method checks whether any database connection,
759
770
  ** either in this process or in some other process, is holding a RESERVED,
760
771
  ** PENDING, or EXCLUSIVE lock on the file. It returns true
@@ -859,9 +870,8 @@ struct sqlite3_io_methods {
859
870
  ** opcode causes the xFileControl method to write the current state of
860
871
  ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
861
872
  ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
862
- ** into an integer that the pArg argument points to. This capability
863
- ** is used during testing and is only available when the SQLITE_TEST
864
- ** compile-time option is used.
873
+ ** into an integer that the pArg argument points to.
874
+ ** This capability is only available if SQLite is compiled with [SQLITE_DEBUG].
865
875
  **
866
876
  ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
867
877
  ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
@@ -1253,6 +1263,26 @@ typedef struct sqlite3_mutex sqlite3_mutex;
1253
1263
  */
1254
1264
  typedef struct sqlite3_api_routines sqlite3_api_routines;
1255
1265
 
1266
+ /*
1267
+ ** CAPI3REF: File Name
1268
+ **
1269
+ ** Type [sqlite3_filename] is used by SQLite to pass filenames to the
1270
+ ** xOpen method of a [VFS]. It may be cast to (const char*) and treated
1271
+ ** as a normal, nul-terminated, UTF-8 buffer containing the filename, but
1272
+ ** may also be passed to special APIs such as:
1273
+ **
1274
+ ** <ul>
1275
+ ** <li> sqlite3_filename_database()
1276
+ ** <li> sqlite3_filename_journal()
1277
+ ** <li> sqlite3_filename_wal()
1278
+ ** <li> sqlite3_uri_parameter()
1279
+ ** <li> sqlite3_uri_boolean()
1280
+ ** <li> sqlite3_uri_int64()
1281
+ ** <li> sqlite3_uri_key()
1282
+ ** </ul>
1283
+ */
1284
+ typedef const char *sqlite3_filename;
1285
+
1256
1286
  /*
1257
1287
  ** CAPI3REF: OS Interface Object
1258
1288
  **
@@ -1431,7 +1461,7 @@ struct sqlite3_vfs {
1431
1461
  sqlite3_vfs *pNext; /* Next registered VFS */
1432
1462
  const char *zName; /* Name of this virtual file system */
1433
1463
  void *pAppData; /* Pointer to application-specific data */
1434
- int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
1464
+ int (*xOpen)(sqlite3_vfs*, sqlite3_filename zName, sqlite3_file*,
1435
1465
  int flags, int *pOutFlags);
1436
1466
  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
1437
1467
  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
@@ -2309,6 +2339,7 @@ struct sqlite3_mem_methods {
2309
2339
  ** <ul>
2310
2340
  ** <li> The [PRAGMA writable_schema=ON] statement.
2311
2341
  ** <li> The [PRAGMA journal_mode=OFF] statement.
2342
+ ** <li> The [PRAGMA schema_version=N] statement.
2312
2343
  ** <li> Writes to the [sqlite_dbpage] virtual table.
2313
2344
  ** <li> Direct writes to [shadow tables].
2314
2345
  ** </ul>
@@ -3424,6 +3455,9 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3424
3455
  ** <dd>The database is opened [shared cache] enabled, overriding
3425
3456
  ** the default shared cache setting provided by
3426
3457
  ** [sqlite3_enable_shared_cache()].)^
3458
+ ** The [use of shared cache mode is discouraged] and hence shared cache
3459
+ ** capabilities may be omitted from many builds of SQLite. In such cases,
3460
+ ** this option is a no-op.
3427
3461
  **
3428
3462
  ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt>
3429
3463
  ** <dd>The database is opened [shared cache] disabled, overriding
@@ -3439,7 +3473,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3439
3473
  ** to return an extended result code.</dd>
3440
3474
  **
3441
3475
  ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3442
- ** <dd>The database filename is not allowed to be a symbolic link</dd>
3476
+ ** <dd>The database filename is not allowed to contain a symbolic link</dd>
3443
3477
  ** </dl>)^
3444
3478
  **
3445
3479
  ** If the 3rd parameter to sqlite3_open_v2() is not one of the
@@ -3698,10 +3732,10 @@ SQLITE_API int sqlite3_open_v2(
3698
3732
  **
3699
3733
  ** See the [URI filename] documentation for additional information.
3700
3734
  */
3701
- SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3702
- SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3703
- SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3704
- SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N);
3735
+ SQLITE_API const char *sqlite3_uri_parameter(sqlite3_filename z, const char *zParam);
3736
+ SQLITE_API int sqlite3_uri_boolean(sqlite3_filename z, const char *zParam, int bDefault);
3737
+ SQLITE_API sqlite3_int64 sqlite3_uri_int64(sqlite3_filename, const char*, sqlite3_int64);
3738
+ SQLITE_API const char *sqlite3_uri_key(sqlite3_filename z, int N);
3705
3739
 
3706
3740
  /*
3707
3741
  ** CAPI3REF: Translate filenames
@@ -3730,9 +3764,9 @@ SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N);
3730
3764
  ** return value from [sqlite3_db_filename()], then the result is
3731
3765
  ** undefined and is likely a memory access violation.
3732
3766
  */
3733
- SQLITE_API const char *sqlite3_filename_database(const char*);
3734
- SQLITE_API const char *sqlite3_filename_journal(const char*);
3735
- SQLITE_API const char *sqlite3_filename_wal(const char*);
3767
+ SQLITE_API const char *sqlite3_filename_database(sqlite3_filename);
3768
+ SQLITE_API const char *sqlite3_filename_journal(sqlite3_filename);
3769
+ SQLITE_API const char *sqlite3_filename_wal(sqlite3_filename);
3736
3770
 
3737
3771
  /*
3738
3772
  ** CAPI3REF: Database File Corresponding To A Journal
@@ -3798,14 +3832,14 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*);
3798
3832
  ** then the corresponding [sqlite3_module.xClose() method should also be
3799
3833
  ** invoked prior to calling sqlite3_free_filename(Y).
3800
3834
  */
3801
- SQLITE_API char *sqlite3_create_filename(
3835
+ SQLITE_API sqlite3_filename sqlite3_create_filename(
3802
3836
  const char *zDatabase,
3803
3837
  const char *zJournal,
3804
3838
  const char *zWal,
3805
3839
  int nParam,
3806
3840
  const char **azParam
3807
3841
  );
3808
- SQLITE_API void sqlite3_free_filename(char*);
3842
+ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
3809
3843
 
3810
3844
  /*
3811
3845
  ** CAPI3REF: Error Codes And Messages
@@ -3824,13 +3858,14 @@ SQLITE_API void sqlite3_free_filename(char*);
3824
3858
  ** sqlite3_extended_errcode() might change with each API call.
3825
3859
  ** Except, there are some interfaces that are guaranteed to never
3826
3860
  ** change the value of the error code. The error-code preserving
3827
- ** interfaces are:
3861
+ ** interfaces include the following:
3828
3862
  **
3829
3863
  ** <ul>
3830
3864
  ** <li> sqlite3_errcode()
3831
3865
  ** <li> sqlite3_extended_errcode()
3832
3866
  ** <li> sqlite3_errmsg()
3833
3867
  ** <li> sqlite3_errmsg16()
3868
+ ** <li> sqlite3_error_offset()
3834
3869
  ** </ul>
3835
3870
  **
3836
3871
  ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3845,6 +3880,13 @@ SQLITE_API void sqlite3_free_filename(char*);
3845
3880
  ** ^(Memory to hold the error message string is managed internally
3846
3881
  ** and must not be freed by the application)^.
3847
3882
  **
3883
+ ** ^If the most recent error references a specific token in the input
3884
+ ** SQL, the sqlite3_error_offset() interface returns the byte offset
3885
+ ** of the start of that token. ^The byte offset returned by
3886
+ ** sqlite3_error_offset() assumes that the input SQL is UTF8.
3887
+ ** ^If the most recent error does not reference a specific token in the input
3888
+ ** SQL, then the sqlite3_error_offset() function returns -1.
3889
+ **
3848
3890
  ** When the serialized [threading mode] is in use, it might be the
3849
3891
  ** case that a second error occurs on a separate thread in between
3850
3892
  ** the time of the first error and the call to these interfaces.
@@ -3864,6 +3906,7 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3864
3906
  SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3865
3907
  SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3866
3908
  SQLITE_API const char *sqlite3_errstr(int);
3909
+ SQLITE_API int sqlite3_error_offset(sqlite3 *db);
3867
3910
 
3868
3911
  /*
3869
3912
  ** CAPI3REF: Prepared Statement Object
@@ -4275,6 +4318,10 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4275
4318
  ** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
4276
4319
  ** read-only no-op if the table already exists, but
4277
4320
  ** sqlite3_stmt_readonly() still returns false for such a statement.
4321
+ **
4322
+ ** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
4323
+ ** statement, then sqlite3_stmt_readonly(X) returns the same value as
4324
+ ** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
4278
4325
  */
4279
4326
  SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
4280
4327
 
@@ -4343,6 +4390,8 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
4343
4390
  **
4344
4391
  ** ^The sqlite3_value objects that are passed as parameters into the
4345
4392
  ** implementation of [application-defined SQL functions] are protected.
4393
+ ** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
4394
+ ** are protected.
4346
4395
  ** ^The sqlite3_value object returned by
4347
4396
  ** [sqlite3_column_value()] is unprotected.
4348
4397
  ** Unprotected sqlite3_value objects may only be used as arguments
@@ -4964,6 +5013,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4964
5013
  ** even empty strings, are always zero-terminated. ^The return
4965
5014
  ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
4966
5015
  **
5016
+ ** ^Strings returned by sqlite3_column_text16() always have the endianness
5017
+ ** which is native to the platform, regardless of the text encoding set
5018
+ ** for the database.
5019
+ **
4967
5020
  ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
4968
5021
  ** [unprotected sqlite3_value] object. In a multithreaded environment,
4969
5022
  ** an unprotected sqlite3_value object may only be used safely with
@@ -4977,7 +5030,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4977
5030
  ** [application-defined SQL functions] or [virtual tables], not within
4978
5031
  ** top-level application code.
4979
5032
  **
4980
- ** The these routines may attempt to convert the datatype of the result.
5033
+ ** These routines may attempt to convert the datatype of the result.
4981
5034
  ** ^For example, if the internal representation is FLOAT and a text result
4982
5035
  ** is requested, [sqlite3_snprintf()] is used internally to perform the
4983
5036
  ** conversion automatically. ^(The following table details the conversions
@@ -5002,7 +5055,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
5002
5055
  ** <tr><td> TEXT <td> BLOB <td> No change
5003
5056
  ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
5004
5057
  ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
5005
- ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
5058
+ ** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
5006
5059
  ** </table>
5007
5060
  ** </blockquote>)^
5008
5061
  **
@@ -5489,6 +5542,16 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
5489
5542
  ** then the conversion is performed. Otherwise no conversion occurs.
5490
5543
  ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
5491
5544
  **
5545
+ ** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
5546
+ ** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current encoding
5547
+ ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
5548
+ ** returns something other than SQLITE_TEXT, then the return value from
5549
+ ** sqlite3_value_encoding(X) is meaningless. ^Calls to
5550
+ ** sqlite3_value_text(X), sqlite3_value_text16(X), sqlite3_value_text16be(X),
5551
+ ** sqlite3_value_text16le(X), sqlite3_value_bytes(X), or
5552
+ ** sqlite3_value_bytes16(X) might change the encoding of the value X and
5553
+ ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
5554
+ **
5492
5555
  ** ^Within the [xUpdate] method of a [virtual table], the
5493
5556
  ** sqlite3_value_nochange(X) interface returns true if and only if
5494
5557
  ** the column corresponding to X is unchanged by the UPDATE operation
@@ -5553,6 +5616,7 @@ SQLITE_API int sqlite3_value_type(sqlite3_value*);
5553
5616
  SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
5554
5617
  SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
5555
5618
  SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
5619
+ SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
5556
5620
 
5557
5621
  /*
5558
5622
  ** CAPI3REF: Finding The Subtype Of SQL Values
@@ -5574,7 +5638,8 @@ SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
5574
5638
  ** object D and returns a pointer to that copy. ^The [sqlite3_value] returned
5575
5639
  ** is a [protected sqlite3_value] object even if the input is not.
5576
5640
  ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
5577
- ** memory allocation fails.
5641
+ ** memory allocation fails. ^If V is a [pointer value], then the result
5642
+ ** of sqlite3_value_dup(V) is a NULL value.
5578
5643
  **
5579
5644
  ** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
5580
5645
  ** previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer
@@ -5605,7 +5670,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*);
5605
5670
  **
5606
5671
  ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
5607
5672
  ** when first called if N is less than or equal to zero or if a memory
5608
- ** allocate error occurs.
5673
+ ** allocation error occurs.
5609
5674
  **
5610
5675
  ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
5611
5676
  ** determined by the N parameter on first successful call. Changing the
@@ -5810,9 +5875,10 @@ typedef void (*sqlite3_destructor_type)(void*);
5810
5875
  ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
5811
5876
  ** ^SQLite takes the text result from the application from
5812
5877
  ** the 2nd parameter of the sqlite3_result_text* interfaces.
5813
- ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5814
- ** is negative, then SQLite takes result text from the 2nd parameter
5815
- ** through the first zero character.
5878
+ ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
5879
+ ** other than sqlite3_result_text64() is negative, then SQLite computes
5880
+ ** the string length itself by searching the 2nd parameter for the first
5881
+ ** zero character.
5816
5882
  ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5817
5883
  ** is non-negative, then as many bytes (not characters) of the text
5818
5884
  ** pointed to by the 2nd parameter are taken as the application-defined
@@ -6256,6 +6322,28 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*);
6256
6322
  */
6257
6323
  SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
6258
6324
 
6325
+ /*
6326
+ ** CAPI3REF: Return The Schema Name For A Database Connection
6327
+ ** METHOD: sqlite3
6328
+ **
6329
+ ** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name
6330
+ ** for the N-th database on database connection D, or a NULL pointer of N is
6331
+ ** out of range. An N value of 0 means the main database file. An N of 1 is
6332
+ ** the "temp" schema. Larger values of N correspond to various ATTACH-ed
6333
+ ** databases.
6334
+ **
6335
+ ** Space to hold the string that is returned by sqlite3_db_name() is managed
6336
+ ** by SQLite itself. The string might be deallocated by any operation that
6337
+ ** changes the schema, including [ATTACH] or [DETACH] or calls to
6338
+ ** [sqlite3_serialize()] or [sqlite3_deserialize()], even operations that
6339
+ ** occur on a different thread. Applications that need to
6340
+ ** remember the string long-term should make their own copy. Applications that
6341
+ ** are accessing the same database connection simultaneously on multiple
6342
+ ** threads should mutex-protect calls to this API and should make their own
6343
+ ** private copy of the result prior to releasing the mutex.
6344
+ */
6345
+ SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N);
6346
+
6259
6347
  /*
6260
6348
  ** CAPI3REF: Return The Filename For A Database Connection
6261
6349
  ** METHOD: sqlite3
@@ -6286,7 +6374,7 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
6286
6374
  ** <li> [sqlite3_filename_wal()]
6287
6375
  ** </ul>
6288
6376
  */
6289
- SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
6377
+ SQLITE_API sqlite3_filename sqlite3_db_filename(sqlite3 *db, const char *zDbName);
6290
6378
 
6291
6379
  /*
6292
6380
  ** CAPI3REF: Determine if a database is read-only
@@ -6423,7 +6511,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
6423
6511
  ** function C that is invoked prior to each autovacuum of the database
6424
6512
  ** file. ^The callback is passed a copy of the generic data pointer (P),
6425
6513
  ** the schema-name of the attached database that is being autovacuumed,
6426
- ** the the size of the database file in pages, the number of free pages,
6514
+ ** the size of the database file in pages, the number of free pages,
6427
6515
  ** and the number of bytes per page, respectively. The callback should
6428
6516
  ** return the number of free pages that should be removed by the
6429
6517
  ** autovacuum. ^If the callback returns zero, then no autovacuum happens.
@@ -6544,6 +6632,11 @@ SQLITE_API void *sqlite3_update_hook(
6544
6632
  ** to the same database. Sharing is enabled if the argument is true
6545
6633
  ** and disabled if the argument is false.)^
6546
6634
  **
6635
+ ** This interface is omitted if SQLite is compiled with
6636
+ ** [-DSQLITE_OMIT_SHARED_CACHE]. The [-DSQLITE_OMIT_SHARED_CACHE]
6637
+ ** compile-time option is recommended because the
6638
+ ** [use of shared cache mode is discouraged].
6639
+ **
6547
6640
  ** ^Cache sharing is enabled and disabled for an entire process.
6548
6641
  ** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]).
6549
6642
  ** In prior versions of SQLite,
@@ -6642,7 +6735,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
6642
6735
  ** ^The soft heap limit may not be greater than the hard heap limit.
6643
6736
  ** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
6644
6737
  ** is invoked with a value of N that is greater than the hard heap limit,
6645
- ** the the soft heap limit is set to the value of the hard heap limit.
6738
+ ** the soft heap limit is set to the value of the hard heap limit.
6646
6739
  ** ^The soft heap limit is automatically enabled whenever the hard heap
6647
6740
  ** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
6648
6741
  ** the soft heap limit is outside the range of 1..N, then the soft heap
@@ -7122,24 +7215,56 @@ struct sqlite3_index_info {
7122
7215
  **
7123
7216
  ** These macros define the allowed values for the
7124
7217
  ** [sqlite3_index_info].aConstraint[].op field. Each value represents
7125
- ** an operator that is part of a constraint term in the wHERE clause of
7218
+ ** an operator that is part of a constraint term in the WHERE clause of
7126
7219
  ** a query that uses a [virtual table].
7127
- */
7128
- #define SQLITE_INDEX_CONSTRAINT_EQ 2
7129
- #define SQLITE_INDEX_CONSTRAINT_GT 4
7130
- #define SQLITE_INDEX_CONSTRAINT_LE 8
7131
- #define SQLITE_INDEX_CONSTRAINT_LT 16
7132
- #define SQLITE_INDEX_CONSTRAINT_GE 32
7133
- #define SQLITE_INDEX_CONSTRAINT_MATCH 64
7134
- #define SQLITE_INDEX_CONSTRAINT_LIKE 65
7135
- #define SQLITE_INDEX_CONSTRAINT_GLOB 66
7136
- #define SQLITE_INDEX_CONSTRAINT_REGEXP 67
7137
- #define SQLITE_INDEX_CONSTRAINT_NE 68
7138
- #define SQLITE_INDEX_CONSTRAINT_ISNOT 69
7139
- #define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
7140
- #define SQLITE_INDEX_CONSTRAINT_ISNULL 71
7141
- #define SQLITE_INDEX_CONSTRAINT_IS 72
7142
- #define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
7220
+ **
7221
+ ** ^The left-hand operand of the operator is given by the corresponding
7222
+ ** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
7223
+ ** operand is the rowid.
7224
+ ** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
7225
+ ** operators have no left-hand operand, and so for those operators the
7226
+ ** corresponding aConstraint[].iColumn is meaningless and should not be
7227
+ ** used.
7228
+ **
7229
+ ** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
7230
+ ** value 255 are reserved to represent functions that are overloaded
7231
+ ** by the [xFindFunction|xFindFunction method] of the virtual table
7232
+ ** implementation.
7233
+ **
7234
+ ** The right-hand operands for each constraint might be accessible using
7235
+ ** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
7236
+ ** operand is only available if it appears as a single constant literal
7237
+ ** in the input SQL. If the right-hand operand is another column or an
7238
+ ** expression (even a constant expression) or a parameter, then the
7239
+ ** sqlite3_vtab_rhs_value() probably will not be able to extract it.
7240
+ ** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
7241
+ ** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
7242
+ ** and hence calls to sqlite3_vtab_rhs_value() for those operators will
7243
+ ** always return SQLITE_NOTFOUND.
7244
+ **
7245
+ ** The collating sequence to be used for comparison can be found using
7246
+ ** the [sqlite3_vtab_collation()] interface. For most real-world virtual
7247
+ ** tables, the collating sequence of constraints does not matter (for example
7248
+ ** because the constraints are numeric) and so the sqlite3_vtab_collation()
7249
+ ** interface is no commonly needed.
7250
+ */
7251
+ #define SQLITE_INDEX_CONSTRAINT_EQ 2
7252
+ #define SQLITE_INDEX_CONSTRAINT_GT 4
7253
+ #define SQLITE_INDEX_CONSTRAINT_LE 8
7254
+ #define SQLITE_INDEX_CONSTRAINT_LT 16
7255
+ #define SQLITE_INDEX_CONSTRAINT_GE 32
7256
+ #define SQLITE_INDEX_CONSTRAINT_MATCH 64
7257
+ #define SQLITE_INDEX_CONSTRAINT_LIKE 65
7258
+ #define SQLITE_INDEX_CONSTRAINT_GLOB 66
7259
+ #define SQLITE_INDEX_CONSTRAINT_REGEXP 67
7260
+ #define SQLITE_INDEX_CONSTRAINT_NE 68
7261
+ #define SQLITE_INDEX_CONSTRAINT_ISNOT 69
7262
+ #define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
7263
+ #define SQLITE_INDEX_CONSTRAINT_ISNULL 71
7264
+ #define SQLITE_INDEX_CONSTRAINT_IS 72
7265
+ #define SQLITE_INDEX_CONSTRAINT_LIMIT 73
7266
+ #define SQLITE_INDEX_CONSTRAINT_OFFSET 74
7267
+ #define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
7143
7268
 
7144
7269
  /*
7145
7270
  ** CAPI3REF: Register A Virtual Table Implementation
@@ -7168,7 +7293,7 @@ struct sqlite3_index_info {
7168
7293
  ** destructor.
7169
7294
  **
7170
7295
  ** ^If the third parameter (the pointer to the sqlite3_module object) is
7171
- ** NULL then no new module is create and any existing modules with the
7296
+ ** NULL then no new module is created and any existing modules with the
7172
7297
  ** same name are dropped.
7173
7298
  **
7174
7299
  ** See also: [sqlite3_drop_modules()]
@@ -7944,7 +8069,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
7944
8069
  #define SQLITE_TESTCTRL_SEEK_COUNT 30
7945
8070
  #define SQLITE_TESTCTRL_TRACEFLAGS 31
7946
8071
  #define SQLITE_TESTCTRL_TUNE 32
7947
- #define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
8072
+ #define SQLITE_TESTCTRL_LOGEST 33
8073
+ #define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
7948
8074
 
7949
8075
  /*
7950
8076
  ** CAPI3REF: SQL Keyword Checking
@@ -8467,6 +8593,16 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
8467
8593
  ** The counter is incremented on the first [sqlite3_step()] call of each
8468
8594
  ** cycle.
8469
8595
  **
8596
+ ** [[SQLITE_STMTSTATUS_FILTER_MISS]]
8597
+ ** [[SQLITE_STMTSTATUS_FILTER HIT]]
8598
+ ** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
8599
+ ** SQLITE_STMTSTATUS_FILTER_MISS</dt>
8600
+ ** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
8601
+ ** step was bypassed because a Bloom filter returned not-found. The
8602
+ ** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
8603
+ ** times that the Bloom filter returned a find, and thus the join step
8604
+ ** had to be processed as normal.
8605
+ **
8470
8606
  ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
8471
8607
  ** <dd>^This is the approximate number of bytes of heap memory
8472
8608
  ** used to store the prepared statement. ^This value is not actually
@@ -8481,6 +8617,8 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
8481
8617
  #define SQLITE_STMTSTATUS_VM_STEP 4
8482
8618
  #define SQLITE_STMTSTATUS_REPREPARE 5
8483
8619
  #define SQLITE_STMTSTATUS_RUN 6
8620
+ #define SQLITE_STMTSTATUS_FILTER_MISS 7
8621
+ #define SQLITE_STMTSTATUS_FILTER_HIT 8
8484
8622
  #define SQLITE_STMTSTATUS_MEMUSED 99
8485
8623
 
8486
8624
  /*
@@ -8892,7 +9030,7 @@ typedef struct sqlite3_backup sqlite3_backup;
8892
9030
  ** if the application incorrectly accesses the destination [database connection]
8893
9031
  ** and so no error code is reported, but the operations may malfunction
8894
9032
  ** nevertheless. Use of the destination database connection while a
8895
- ** backup is in progress might also also cause a mutex deadlock.
9033
+ ** backup is in progress might also cause a mutex deadlock.
8896
9034
  **
8897
9035
  ** If running in [shared cache mode], the application must
8898
9036
  ** guarantee that the shared cache used by the destination database
@@ -9320,7 +9458,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
9320
9458
  */
9321
9459
  #define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
9322
9460
  #define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
9323
- #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
9461
+ #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */
9324
9462
  #define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
9325
9463
 
9326
9464
  /*
@@ -9449,19 +9587,276 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
9449
9587
 
9450
9588
  /*
9451
9589
  ** CAPI3REF: Determine The Collation For a Virtual Table Constraint
9590
+ ** METHOD: sqlite3_index_info
9452
9591
  **
9453
9592
  ** This function may only be called from within a call to the [xBestIndex]
9454
- ** method of a [virtual table].
9593
+ ** method of a [virtual table]. This function returns a pointer to a string
9594
+ ** that is the name of the appropriate collation sequence to use for text
9595
+ ** comparisons on the constraint identified by its arguments.
9596
+ **
9597
+ ** The first argument must be the pointer to the [sqlite3_index_info] object
9598
+ ** that is the first parameter to the xBestIndex() method. The second argument
9599
+ ** must be an index into the aConstraint[] array belonging to the
9600
+ ** sqlite3_index_info structure passed to xBestIndex.
9601
+ **
9602
+ ** Important:
9603
+ ** The first parameter must be the same pointer that is passed into the
9604
+ ** xBestMethod() method. The first parameter may not be a pointer to a
9605
+ ** different [sqlite3_index_info] object, even an exact copy.
9606
+ **
9607
+ ** The return value is computed as follows:
9455
9608
  **
9456
- ** The first argument must be the sqlite3_index_info object that is the
9457
- ** first parameter to the xBestIndex() method. The second argument must be
9458
- ** an index into the aConstraint[] array belonging to the sqlite3_index_info
9459
- ** structure passed to xBestIndex. This function returns a pointer to a buffer
9460
- ** containing the name of the collation sequence for the corresponding
9461
- ** constraint.
9609
+ ** <ol>
9610
+ ** <li><p> If the constraint comes from a WHERE clause expression that contains
9611
+ ** a [COLLATE operator], then the name of the collation specified by
9612
+ ** that COLLATE operator is returned.
9613
+ ** <li><p> If there is no COLLATE operator, but the column that is the subject
9614
+ ** of the constraint specifies an alternative collating sequence via
9615
+ ** a [COLLATE clause] on the column definition within the CREATE TABLE
9616
+ ** statement that was passed into [sqlite3_declare_vtab()], then the
9617
+ ** name of that alternative collating sequence is returned.
9618
+ ** <li><p> Otherwise, "BINARY" is returned.
9619
+ ** </ol>
9462
9620
  */
9463
9621
  SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
9464
9622
 
9623
+ /*
9624
+ ** CAPI3REF: Determine if a virtual table query is DISTINCT
9625
+ ** METHOD: sqlite3_index_info
9626
+ **
9627
+ ** This API may only be used from within an [xBestIndex|xBestIndex method]
9628
+ ** of a [virtual table] implementation. The result of calling this
9629
+ ** interface from outside of xBestIndex() is undefined and probably harmful.
9630
+ **
9631
+ ** ^The sqlite3_vtab_distinct() interface returns an integer between 0 and
9632
+ ** 3. The integer returned by sqlite3_vtab_distinct()
9633
+ ** gives the virtual table additional information about how the query
9634
+ ** planner wants the output to be ordered. As long as the virtual table
9635
+ ** can meet the ordering requirements of the query planner, it may set
9636
+ ** the "orderByConsumed" flag.
9637
+ **
9638
+ ** <ol><li value="0"><p>
9639
+ ** ^If the sqlite3_vtab_distinct() interface returns 0, that means
9640
+ ** that the query planner needs the virtual table to return all rows in the
9641
+ ** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
9642
+ ** [sqlite3_index_info] object. This is the default expectation. If the
9643
+ ** virtual table outputs all rows in sorted order, then it is always safe for
9644
+ ** the xBestIndex method to set the "orderByConsumed" flag, regardless of
9645
+ ** the return value from sqlite3_vtab_distinct().
9646
+ ** <li value="1"><p>
9647
+ ** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
9648
+ ** that the query planner does not need the rows to be returned in sorted order
9649
+ ** as long as all rows with the same values in all columns identified by the
9650
+ ** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
9651
+ ** is doing a GROUP BY.
9652
+ ** <li value="2"><p>
9653
+ ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
9654
+ ** that the query planner does not need the rows returned in any particular
9655
+ ** order, as long as rows with the same values in all "aOrderBy" columns
9656
+ ** are adjacent.)^ ^(Furthermore, only a single row for each particular
9657
+ ** combination of values in the columns identified by the "aOrderBy" field
9658
+ ** needs to be returned.)^ ^It is always ok for two or more rows with the same
9659
+ ** values in all "aOrderBy" columns to be returned, as long as all such rows
9660
+ ** are adjacent. ^The virtual table may, if it chooses, omit extra rows
9661
+ ** that have the same value for all columns identified by "aOrderBy".
9662
+ ** ^However omitting the extra rows is optional.
9663
+ ** This mode is used for a DISTINCT query.
9664
+ ** <li value="3"><p>
9665
+ ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
9666
+ ** that the query planner needs only distinct rows but it does need the
9667
+ ** rows to be sorted.)^ ^The virtual table implementation is free to omit
9668
+ ** rows that are identical in all aOrderBy columns, if it wants to, but
9669
+ ** it is not required to omit any rows. This mode is used for queries
9670
+ ** that have both DISTINCT and ORDER BY clauses.
9671
+ ** </ol>
9672
+ **
9673
+ ** ^For the purposes of comparing virtual table output values to see if the
9674
+ ** values are same value for sorting purposes, two NULL values are considered
9675
+ ** to be the same. In other words, the comparison operator is "IS"
9676
+ ** (or "IS NOT DISTINCT FROM") and not "==".
9677
+ **
9678
+ ** If a virtual table implementation is unable to meet the requirements
9679
+ ** specified above, then it must not set the "orderByConsumed" flag in the
9680
+ ** [sqlite3_index_info] object or an incorrect answer may result.
9681
+ **
9682
+ ** ^A virtual table implementation is always free to return rows in any order
9683
+ ** it wants, as long as the "orderByConsumed" flag is not set. ^When the
9684
+ ** the "orderByConsumed" flag is unset, the query planner will add extra
9685
+ ** [bytecode] to ensure that the final results returned by the SQL query are
9686
+ ** ordered correctly. The use of the "orderByConsumed" flag and the
9687
+ ** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
9688
+ ** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
9689
+ ** flag might help queries against a virtual table to run faster. Being
9690
+ ** overly aggressive and setting the "orderByConsumed" flag when it is not
9691
+ ** valid to do so, on the other hand, might cause SQLite to return incorrect
9692
+ ** results.
9693
+ */
9694
+ SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
9695
+
9696
+ /*
9697
+ ** CAPI3REF: Identify and handle IN constraints in xBestIndex
9698
+ **
9699
+ ** This interface may only be used from within an
9700
+ ** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
9701
+ ** The result of invoking this interface from any other context is
9702
+ ** undefined and probably harmful.
9703
+ **
9704
+ ** ^(A constraint on a virtual table of the form
9705
+ ** "[IN operator|column IN (...)]" is
9706
+ ** communicated to the xBestIndex method as a
9707
+ ** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
9708
+ ** this constraint, it must set the corresponding
9709
+ ** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
9710
+ ** the usual mode of handling IN operators, SQLite generates [bytecode]
9711
+ ** that invokes the [xFilter|xFilter() method] once for each value
9712
+ ** on the right-hand side of the IN operator.)^ Thus the virtual table
9713
+ ** only sees a single value from the right-hand side of the IN operator
9714
+ ** at a time.
9715
+ **
9716
+ ** In some cases, however, it would be advantageous for the virtual
9717
+ ** table to see all values on the right-hand of the IN operator all at
9718
+ ** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
9719
+ **
9720
+ ** <ol>
9721
+ ** <li><p>
9722
+ ** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
9723
+ ** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
9724
+ ** is an [IN operator] that can be processed all at once. ^In other words,
9725
+ ** sqlite3_vtab_in() with -1 in the third argument is a mechanism
9726
+ ** by which the virtual table can ask SQLite if all-at-once processing
9727
+ ** of the IN operator is even possible.
9728
+ **
9729
+ ** <li><p>
9730
+ ** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
9731
+ ** to SQLite that the virtual table does or does not want to process
9732
+ ** the IN operator all-at-once, respectively. ^Thus when the third
9733
+ ** parameter (F) is non-negative, this interface is the mechanism by
9734
+ ** which the virtual table tells SQLite how it wants to process the
9735
+ ** IN operator.
9736
+ ** </ol>
9737
+ **
9738
+ ** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
9739
+ ** within the same xBestIndex method call. ^For any given P,N pair,
9740
+ ** the return value from sqlite3_vtab_in(P,N,F) will always be the same
9741
+ ** within the same xBestIndex call. ^If the interface returns true
9742
+ ** (non-zero), that means that the constraint is an IN operator
9743
+ ** that can be processed all-at-once. ^If the constraint is not an IN
9744
+ ** operator or cannot be processed all-at-once, then the interface returns
9745
+ ** false.
9746
+ **
9747
+ ** ^(All-at-once processing of the IN operator is selected if both of the
9748
+ ** following conditions are met:
9749
+ **
9750
+ ** <ol>
9751
+ ** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
9752
+ ** integer. This is how the virtual table tells SQLite that it wants to
9753
+ ** use the N-th constraint.
9754
+ **
9755
+ ** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
9756
+ ** non-negative had F>=1.
9757
+ ** </ol>)^
9758
+ **
9759
+ ** ^If either or both of the conditions above are false, then SQLite uses
9760
+ ** the traditional one-at-a-time processing strategy for the IN constraint.
9761
+ ** ^If both conditions are true, then the argvIndex-th parameter to the
9762
+ ** xFilter method will be an [sqlite3_value] that appears to be NULL,
9763
+ ** but which can be passed to [sqlite3_vtab_in_first()] and
9764
+ ** [sqlite3_vtab_in_next()] to find all values on the right-hand side
9765
+ ** of the IN constraint.
9766
+ */
9767
+ SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
9768
+
9769
+ /*
9770
+ ** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
9771
+ **
9772
+ ** These interfaces are only useful from within the
9773
+ ** [xFilter|xFilter() method] of a [virtual table] implementation.
9774
+ ** The result of invoking these interfaces from any other context
9775
+ ** is undefined and probably harmful.
9776
+ **
9777
+ ** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
9778
+ ** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
9779
+ ** xFilter method which invokes these routines, and specifically
9780
+ ** a parameter that was previously selected for all-at-once IN constraint
9781
+ ** processing use the [sqlite3_vtab_in()] interface in the
9782
+ ** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
9783
+ ** an xFilter argument that was selected for all-at-once IN constraint
9784
+ ** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
9785
+ ** exhibit some other undefined or harmful behavior.
9786
+ **
9787
+ ** ^(Use these routines to access all values on the right-hand side
9788
+ ** of the IN constraint using code like the following:
9789
+ **
9790
+ ** <blockquote><pre>
9791
+ ** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
9792
+ ** &nbsp; rc==SQLITE_OK && pVal
9793
+ ** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
9794
+ ** &nbsp; ){
9795
+ ** &nbsp; // do something with pVal
9796
+ ** &nbsp; }
9797
+ ** &nbsp; if( rc!=SQLITE_OK ){
9798
+ ** &nbsp; // an error has occurred
9799
+ ** &nbsp; }
9800
+ ** </pre></blockquote>)^
9801
+ **
9802
+ ** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
9803
+ ** routines return SQLITE_OK and set *P to point to the first or next value
9804
+ ** on the RHS of the IN constraint. ^If there are no more values on the
9805
+ ** right hand side of the IN constraint, then *P is set to NULL and these
9806
+ ** routines return [SQLITE_DONE]. ^The return value might be
9807
+ ** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
9808
+ **
9809
+ ** The *ppOut values returned by these routines are only valid until the
9810
+ ** next call to either of these routines or until the end of the xFilter
9811
+ ** method from which these routines were called. If the virtual table
9812
+ ** implementation needs to retain the *ppOut values for longer, it must make
9813
+ ** copies. The *ppOut values are [protected sqlite3_value|protected].
9814
+ */
9815
+ SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
9816
+ SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
9817
+
9818
+ /*
9819
+ ** CAPI3REF: Constraint values in xBestIndex()
9820
+ ** METHOD: sqlite3_index_info
9821
+ **
9822
+ ** This API may only be used from within the [xBestIndex|xBestIndex method]
9823
+ ** of a [virtual table] implementation. The result of calling this interface
9824
+ ** from outside of an xBestIndex method are undefined and probably harmful.
9825
+ **
9826
+ ** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
9827
+ ** the [xBestIndex] method of a [virtual table] implementation, with P being
9828
+ ** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
9829
+ ** J being a 0-based index into P->aConstraint[], then this routine
9830
+ ** attempts to set *V to the value of the right-hand operand of
9831
+ ** that constraint if the right-hand operand is known. ^If the
9832
+ ** right-hand operand is not known, then *V is set to a NULL pointer.
9833
+ ** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
9834
+ ** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
9835
+ ** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
9836
+ ** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
9837
+ ** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
9838
+ ** something goes wrong.
9839
+ **
9840
+ ** The sqlite3_vtab_rhs_value() interface is usually only successful if
9841
+ ** the right-hand operand of a constraint is a literal value in the original
9842
+ ** SQL statement. If the right-hand operand is an expression or a reference
9843
+ ** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
9844
+ ** will probably return [SQLITE_NOTFOUND].
9845
+ **
9846
+ ** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
9847
+ ** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
9848
+ ** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
9849
+ **
9850
+ ** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
9851
+ ** and remains valid for the duration of the xBestIndex method call.
9852
+ ** ^When xBestIndex returns, the sqlite3_value object returned by
9853
+ ** sqlite3_vtab_rhs_value() is automatically deallocated.
9854
+ **
9855
+ ** The "_rhs_" in the name of this routine is an abbreviation for
9856
+ ** "Right-Hand Side".
9857
+ */
9858
+ SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
9859
+
9465
9860
  /*
9466
9861
  ** CAPI3REF: Conflict resolution modes
9467
9862
  ** KEYWORDS: {conflict resolution mode}