extralite-bundle 1.19 → 1.21
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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/Rakefile +5 -0
- data/ext/extralite/common.c +2 -0
- data/ext/extralite/database.c +185 -14
- data/ext/extralite/extralite.h +7 -0
- data/ext/extralite/extralite_ext.c +1 -1
- data/ext/extralite/prepared_statement.c +26 -10
- data/ext/sqlite3/sqlite3.c +9358 -4988
- data/ext/sqlite3/sqlite3.h +131 -39
- data/lib/extralite/version.rb +1 -1
- data/lib/extralite.rb +60 -1
- data/test/test_database.rb +62 -0
- data/test/test_extralite.rb +24 -0
- data/test/test_prepared_statement.rb +11 -0
- metadata +3 -3
data/ext/sqlite3/sqlite3.h
CHANGED
@@ -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.
|
150
|
-
#define SQLITE_VERSION_NUMBER
|
151
|
-
#define SQLITE_SOURCE_ID "2022-
|
149
|
+
#define SQLITE_VERSION "3.40.1"
|
150
|
+
#define SQLITE_VERSION_NUMBER 3040001
|
151
|
+
#define SQLITE_SOURCE_ID "2022-12-28 14:03:47 df5c253c0b3dd24916e4ec7cf77d3db5294cc9fd45ae7b9c5e82ad8197f38a24"
|
152
152
|
|
153
153
|
/*
|
154
154
|
** CAPI3REF: Run-Time Library Version Numbers
|
@@ -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()
|
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.
|
863
|
-
** is
|
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
|
@@ -1182,6 +1192,12 @@ struct sqlite3_io_methods {
|
|
1182
1192
|
**
|
1183
1193
|
** <li>[[SQLITE_FCNTL_CKSM_FILE]]
|
1184
1194
|
** Used by the cksmvfs VFS module only.
|
1195
|
+
**
|
1196
|
+
** <li>[[SQLITE_FCNTL_RESET_CACHE]]
|
1197
|
+
** If there is currently no transaction open on the database, and the
|
1198
|
+
** database is not a temp db, then this file-control purges the contents
|
1199
|
+
** of the in-memory page cache. If there is an open transaction, or if
|
1200
|
+
** the db is a temp-db, it is a no-op, not an error.
|
1185
1201
|
** </ul>
|
1186
1202
|
*/
|
1187
1203
|
#define SQLITE_FCNTL_LOCKSTATE 1
|
@@ -1224,6 +1240,7 @@ struct sqlite3_io_methods {
|
|
1224
1240
|
#define SQLITE_FCNTL_CKPT_START 39
|
1225
1241
|
#define SQLITE_FCNTL_EXTERNAL_READER 40
|
1226
1242
|
#define SQLITE_FCNTL_CKSM_FILE 41
|
1243
|
+
#define SQLITE_FCNTL_RESET_CACHE 42
|
1227
1244
|
|
1228
1245
|
/* deprecated names */
|
1229
1246
|
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
|
@@ -1253,6 +1270,26 @@ typedef struct sqlite3_mutex sqlite3_mutex;
|
|
1253
1270
|
*/
|
1254
1271
|
typedef struct sqlite3_api_routines sqlite3_api_routines;
|
1255
1272
|
|
1273
|
+
/*
|
1274
|
+
** CAPI3REF: File Name
|
1275
|
+
**
|
1276
|
+
** Type [sqlite3_filename] is used by SQLite to pass filenames to the
|
1277
|
+
** xOpen method of a [VFS]. It may be cast to (const char*) and treated
|
1278
|
+
** as a normal, nul-terminated, UTF-8 buffer containing the filename, but
|
1279
|
+
** may also be passed to special APIs such as:
|
1280
|
+
**
|
1281
|
+
** <ul>
|
1282
|
+
** <li> sqlite3_filename_database()
|
1283
|
+
** <li> sqlite3_filename_journal()
|
1284
|
+
** <li> sqlite3_filename_wal()
|
1285
|
+
** <li> sqlite3_uri_parameter()
|
1286
|
+
** <li> sqlite3_uri_boolean()
|
1287
|
+
** <li> sqlite3_uri_int64()
|
1288
|
+
** <li> sqlite3_uri_key()
|
1289
|
+
** </ul>
|
1290
|
+
*/
|
1291
|
+
typedef const char *sqlite3_filename;
|
1292
|
+
|
1256
1293
|
/*
|
1257
1294
|
** CAPI3REF: OS Interface Object
|
1258
1295
|
**
|
@@ -1431,7 +1468,7 @@ struct sqlite3_vfs {
|
|
1431
1468
|
sqlite3_vfs *pNext; /* Next registered VFS */
|
1432
1469
|
const char *zName; /* Name of this virtual file system */
|
1433
1470
|
void *pAppData; /* Pointer to application-specific data */
|
1434
|
-
int (*xOpen)(sqlite3_vfs*,
|
1471
|
+
int (*xOpen)(sqlite3_vfs*, sqlite3_filename zName, sqlite3_file*,
|
1435
1472
|
int flags, int *pOutFlags);
|
1436
1473
|
int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
|
1437
1474
|
int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
|
@@ -2309,6 +2346,7 @@ struct sqlite3_mem_methods {
|
|
2309
2346
|
** <ul>
|
2310
2347
|
** <li> The [PRAGMA writable_schema=ON] statement.
|
2311
2348
|
** <li> The [PRAGMA journal_mode=OFF] statement.
|
2349
|
+
** <li> The [PRAGMA schema_version=N] statement.
|
2312
2350
|
** <li> Writes to the [sqlite_dbpage] virtual table.
|
2313
2351
|
** <li> Direct writes to [shadow tables].
|
2314
2352
|
** </ul>
|
@@ -3424,6 +3462,9 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
|
|
3424
3462
|
** <dd>The database is opened [shared cache] enabled, overriding
|
3425
3463
|
** the default shared cache setting provided by
|
3426
3464
|
** [sqlite3_enable_shared_cache()].)^
|
3465
|
+
** The [use of shared cache mode is discouraged] and hence shared cache
|
3466
|
+
** capabilities may be omitted from many builds of SQLite. In such cases,
|
3467
|
+
** this option is a no-op.
|
3427
3468
|
**
|
3428
3469
|
** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt>
|
3429
3470
|
** <dd>The database is opened [shared cache] disabled, overriding
|
@@ -3439,7 +3480,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
|
|
3439
3480
|
** to return an extended result code.</dd>
|
3440
3481
|
**
|
3441
3482
|
** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
|
3442
|
-
** <dd>The database filename is not allowed to
|
3483
|
+
** <dd>The database filename is not allowed to contain a symbolic link</dd>
|
3443
3484
|
** </dl>)^
|
3444
3485
|
**
|
3445
3486
|
** If the 3rd parameter to sqlite3_open_v2() is not one of the
|
@@ -3698,10 +3739,10 @@ SQLITE_API int sqlite3_open_v2(
|
|
3698
3739
|
**
|
3699
3740
|
** See the [URI filename] documentation for additional information.
|
3700
3741
|
*/
|
3701
|
-
SQLITE_API const char *sqlite3_uri_parameter(
|
3702
|
-
SQLITE_API int sqlite3_uri_boolean(
|
3703
|
-
SQLITE_API sqlite3_int64 sqlite3_uri_int64(
|
3704
|
-
SQLITE_API const char *sqlite3_uri_key(
|
3742
|
+
SQLITE_API const char *sqlite3_uri_parameter(sqlite3_filename z, const char *zParam);
|
3743
|
+
SQLITE_API int sqlite3_uri_boolean(sqlite3_filename z, const char *zParam, int bDefault);
|
3744
|
+
SQLITE_API sqlite3_int64 sqlite3_uri_int64(sqlite3_filename, const char*, sqlite3_int64);
|
3745
|
+
SQLITE_API const char *sqlite3_uri_key(sqlite3_filename z, int N);
|
3705
3746
|
|
3706
3747
|
/*
|
3707
3748
|
** CAPI3REF: Translate filenames
|
@@ -3730,9 +3771,9 @@ SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N);
|
|
3730
3771
|
** return value from [sqlite3_db_filename()], then the result is
|
3731
3772
|
** undefined and is likely a memory access violation.
|
3732
3773
|
*/
|
3733
|
-
SQLITE_API const char *sqlite3_filename_database(
|
3734
|
-
SQLITE_API const char *sqlite3_filename_journal(
|
3735
|
-
SQLITE_API const char *sqlite3_filename_wal(
|
3774
|
+
SQLITE_API const char *sqlite3_filename_database(sqlite3_filename);
|
3775
|
+
SQLITE_API const char *sqlite3_filename_journal(sqlite3_filename);
|
3776
|
+
SQLITE_API const char *sqlite3_filename_wal(sqlite3_filename);
|
3736
3777
|
|
3737
3778
|
/*
|
3738
3779
|
** CAPI3REF: Database File Corresponding To A Journal
|
@@ -3798,14 +3839,14 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*);
|
|
3798
3839
|
** then the corresponding [sqlite3_module.xClose() method should also be
|
3799
3840
|
** invoked prior to calling sqlite3_free_filename(Y).
|
3800
3841
|
*/
|
3801
|
-
SQLITE_API
|
3842
|
+
SQLITE_API sqlite3_filename sqlite3_create_filename(
|
3802
3843
|
const char *zDatabase,
|
3803
3844
|
const char *zJournal,
|
3804
3845
|
const char *zWal,
|
3805
3846
|
int nParam,
|
3806
3847
|
const char **azParam
|
3807
3848
|
);
|
3808
|
-
SQLITE_API void sqlite3_free_filename(
|
3849
|
+
SQLITE_API void sqlite3_free_filename(sqlite3_filename);
|
3809
3850
|
|
3810
3851
|
/*
|
3811
3852
|
** CAPI3REF: Error Codes And Messages
|
@@ -4979,6 +5020,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
4979
5020
|
** even empty strings, are always zero-terminated. ^The return
|
4980
5021
|
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
|
4981
5022
|
**
|
5023
|
+
** ^Strings returned by sqlite3_column_text16() always have the endianness
|
5024
|
+
** which is native to the platform, regardless of the text encoding set
|
5025
|
+
** for the database.
|
5026
|
+
**
|
4982
5027
|
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
|
4983
5028
|
** [unprotected sqlite3_value] object. In a multithreaded environment,
|
4984
5029
|
** an unprotected sqlite3_value object may only be used safely with
|
@@ -4992,7 +5037,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
4992
5037
|
** [application-defined SQL functions] or [virtual tables], not within
|
4993
5038
|
** top-level application code.
|
4994
5039
|
**
|
4995
|
-
**
|
5040
|
+
** These routines may attempt to convert the datatype of the result.
|
4996
5041
|
** ^For example, if the internal representation is FLOAT and a text result
|
4997
5042
|
** is requested, [sqlite3_snprintf()] is used internally to perform the
|
4998
5043
|
** conversion automatically. ^(The following table details the conversions
|
@@ -5017,7 +5062,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
|
|
5017
5062
|
** <tr><td> TEXT <td> BLOB <td> No change
|
5018
5063
|
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
|
5019
5064
|
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
|
5020
|
-
** <tr><td> BLOB <td> TEXT <td>
|
5065
|
+
** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
|
5021
5066
|
** </table>
|
5022
5067
|
** </blockquote>)^
|
5023
5068
|
**
|
@@ -5504,6 +5549,16 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
|
|
5504
5549
|
** then the conversion is performed. Otherwise no conversion occurs.
|
5505
5550
|
** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
|
5506
5551
|
**
|
5552
|
+
** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
|
5553
|
+
** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current encoding
|
5554
|
+
** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
|
5555
|
+
** returns something other than SQLITE_TEXT, then the return value from
|
5556
|
+
** sqlite3_value_encoding(X) is meaningless. ^Calls to
|
5557
|
+
** sqlite3_value_text(X), sqlite3_value_text16(X), sqlite3_value_text16be(X),
|
5558
|
+
** sqlite3_value_text16le(X), sqlite3_value_bytes(X), or
|
5559
|
+
** sqlite3_value_bytes16(X) might change the encoding of the value X and
|
5560
|
+
** thus change the return from subsequent calls to sqlite3_value_encoding(X).
|
5561
|
+
**
|
5507
5562
|
** ^Within the [xUpdate] method of a [virtual table], the
|
5508
5563
|
** sqlite3_value_nochange(X) interface returns true if and only if
|
5509
5564
|
** the column corresponding to X is unchanged by the UPDATE operation
|
@@ -5568,6 +5623,7 @@ SQLITE_API int sqlite3_value_type(sqlite3_value*);
|
|
5568
5623
|
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
|
5569
5624
|
SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
|
5570
5625
|
SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
|
5626
|
+
SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
|
5571
5627
|
|
5572
5628
|
/*
|
5573
5629
|
** CAPI3REF: Finding The Subtype Of SQL Values
|
@@ -5589,7 +5645,8 @@ SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
|
|
5589
5645
|
** object D and returns a pointer to that copy. ^The [sqlite3_value] returned
|
5590
5646
|
** is a [protected sqlite3_value] object even if the input is not.
|
5591
5647
|
** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
|
5592
|
-
** memory allocation fails.
|
5648
|
+
** memory allocation fails. ^If V is a [pointer value], then the result
|
5649
|
+
** of sqlite3_value_dup(V) is a NULL value.
|
5593
5650
|
**
|
5594
5651
|
** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
|
5595
5652
|
** previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer
|
@@ -5620,7 +5677,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*);
|
|
5620
5677
|
**
|
5621
5678
|
** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
|
5622
5679
|
** when first called if N is less than or equal to zero or if a memory
|
5623
|
-
**
|
5680
|
+
** allocation error occurs.
|
5624
5681
|
**
|
5625
5682
|
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
|
5626
5683
|
** determined by the N parameter on first successful call. Changing the
|
@@ -5825,9 +5882,10 @@ typedef void (*sqlite3_destructor_type)(void*);
|
|
5825
5882
|
** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
|
5826
5883
|
** ^SQLite takes the text result from the application from
|
5827
5884
|
** the 2nd parameter of the sqlite3_result_text* interfaces.
|
5828
|
-
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
|
5829
|
-
** is negative, then SQLite
|
5830
|
-
**
|
5885
|
+
** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
|
5886
|
+
** other than sqlite3_result_text64() is negative, then SQLite computes
|
5887
|
+
** the string length itself by searching the 2nd parameter for the first
|
5888
|
+
** zero character.
|
5831
5889
|
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
|
5832
5890
|
** is non-negative, then as many bytes (not characters) of the text
|
5833
5891
|
** pointed to by the 2nd parameter are taken as the application-defined
|
@@ -6271,6 +6329,28 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*);
|
|
6271
6329
|
*/
|
6272
6330
|
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
|
6273
6331
|
|
6332
|
+
/*
|
6333
|
+
** CAPI3REF: Return The Schema Name For A Database Connection
|
6334
|
+
** METHOD: sqlite3
|
6335
|
+
**
|
6336
|
+
** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name
|
6337
|
+
** for the N-th database on database connection D, or a NULL pointer of N is
|
6338
|
+
** out of range. An N value of 0 means the main database file. An N of 1 is
|
6339
|
+
** the "temp" schema. Larger values of N correspond to various ATTACH-ed
|
6340
|
+
** databases.
|
6341
|
+
**
|
6342
|
+
** Space to hold the string that is returned by sqlite3_db_name() is managed
|
6343
|
+
** by SQLite itself. The string might be deallocated by any operation that
|
6344
|
+
** changes the schema, including [ATTACH] or [DETACH] or calls to
|
6345
|
+
** [sqlite3_serialize()] or [sqlite3_deserialize()], even operations that
|
6346
|
+
** occur on a different thread. Applications that need to
|
6347
|
+
** remember the string long-term should make their own copy. Applications that
|
6348
|
+
** are accessing the same database connection simultaneously on multiple
|
6349
|
+
** threads should mutex-protect calls to this API and should make their own
|
6350
|
+
** private copy of the result prior to releasing the mutex.
|
6351
|
+
*/
|
6352
|
+
SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N);
|
6353
|
+
|
6274
6354
|
/*
|
6275
6355
|
** CAPI3REF: Return The Filename For A Database Connection
|
6276
6356
|
** METHOD: sqlite3
|
@@ -6301,7 +6381,7 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
|
|
6301
6381
|
** <li> [sqlite3_filename_wal()]
|
6302
6382
|
** </ul>
|
6303
6383
|
*/
|
6304
|
-
SQLITE_API
|
6384
|
+
SQLITE_API sqlite3_filename sqlite3_db_filename(sqlite3 *db, const char *zDbName);
|
6305
6385
|
|
6306
6386
|
/*
|
6307
6387
|
** CAPI3REF: Determine if a database is read-only
|
@@ -6438,7 +6518,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
|
|
6438
6518
|
** function C that is invoked prior to each autovacuum of the database
|
6439
6519
|
** file. ^The callback is passed a copy of the generic data pointer (P),
|
6440
6520
|
** the schema-name of the attached database that is being autovacuumed,
|
6441
|
-
** the
|
6521
|
+
** the size of the database file in pages, the number of free pages,
|
6442
6522
|
** and the number of bytes per page, respectively. The callback should
|
6443
6523
|
** return the number of free pages that should be removed by the
|
6444
6524
|
** autovacuum. ^If the callback returns zero, then no autovacuum happens.
|
@@ -6559,6 +6639,11 @@ SQLITE_API void *sqlite3_update_hook(
|
|
6559
6639
|
** to the same database. Sharing is enabled if the argument is true
|
6560
6640
|
** and disabled if the argument is false.)^
|
6561
6641
|
**
|
6642
|
+
** This interface is omitted if SQLite is compiled with
|
6643
|
+
** [-DSQLITE_OMIT_SHARED_CACHE]. The [-DSQLITE_OMIT_SHARED_CACHE]
|
6644
|
+
** compile-time option is recommended because the
|
6645
|
+
** [use of shared cache mode is discouraged].
|
6646
|
+
**
|
6562
6647
|
** ^Cache sharing is enabled and disabled for an entire process.
|
6563
6648
|
** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]).
|
6564
6649
|
** In prior versions of SQLite,
|
@@ -6657,7 +6742,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
|
|
6657
6742
|
** ^The soft heap limit may not be greater than the hard heap limit.
|
6658
6743
|
** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
|
6659
6744
|
** is invoked with a value of N that is greater than the hard heap limit,
|
6660
|
-
** the
|
6745
|
+
** the soft heap limit is set to the value of the hard heap limit.
|
6661
6746
|
** ^The soft heap limit is automatically enabled whenever the hard heap
|
6662
6747
|
** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
|
6663
6748
|
** the soft heap limit is outside the range of 1..N, then the soft heap
|
@@ -8952,7 +9037,7 @@ typedef struct sqlite3_backup sqlite3_backup;
|
|
8952
9037
|
** if the application incorrectly accesses the destination [database connection]
|
8953
9038
|
** and so no error code is reported, but the operations may malfunction
|
8954
9039
|
** nevertheless. Use of the destination database connection while a
|
8955
|
-
** backup is in progress might also
|
9040
|
+
** backup is in progress might also cause a mutex deadlock.
|
8956
9041
|
**
|
8957
9042
|
** If running in [shared cache mode], the application must
|
8958
9043
|
** guarantee that the shared cache used by the destination database
|
@@ -9380,7 +9465,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
|
|
9380
9465
|
*/
|
9381
9466
|
#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
|
9382
9467
|
#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
|
9383
|
-
#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for
|
9468
|
+
#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */
|
9384
9469
|
#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
|
9385
9470
|
|
9386
9471
|
/*
|
@@ -9550,8 +9635,8 @@ SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_
|
|
9550
9635
|
** of a [virtual table] implementation. The result of calling this
|
9551
9636
|
** interface from outside of xBestIndex() is undefined and probably harmful.
|
9552
9637
|
**
|
9553
|
-
** ^The sqlite3_vtab_distinct() interface returns an integer
|
9554
|
-
**
|
9638
|
+
** ^The sqlite3_vtab_distinct() interface returns an integer between 0 and
|
9639
|
+
** 3. The integer returned by sqlite3_vtab_distinct()
|
9555
9640
|
** gives the virtual table additional information about how the query
|
9556
9641
|
** planner wants the output to be ordered. As long as the virtual table
|
9557
9642
|
** can meet the ordering requirements of the query planner, it may set
|
@@ -9583,6 +9668,13 @@ SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_
|
|
9583
9668
|
** that have the same value for all columns identified by "aOrderBy".
|
9584
9669
|
** ^However omitting the extra rows is optional.
|
9585
9670
|
** This mode is used for a DISTINCT query.
|
9671
|
+
** <li value="3"><p>
|
9672
|
+
** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
|
9673
|
+
** that the query planner needs only distinct rows but it does need the
|
9674
|
+
** rows to be sorted.)^ ^The virtual table implementation is free to omit
|
9675
|
+
** rows that are identical in all aOrderBy columns, if it wants to, but
|
9676
|
+
** it is not required to omit any rows. This mode is used for queries
|
9677
|
+
** that have both DISTINCT and ORDER BY clauses.
|
9586
9678
|
** </ol>
|
9587
9679
|
**
|
9588
9680
|
** ^For the purposes of comparing virtual table output values to see if the
|
@@ -9767,7 +9859,7 @@ SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
|
|
9767
9859
|
** ^When xBestIndex returns, the sqlite3_value object returned by
|
9768
9860
|
** sqlite3_vtab_rhs_value() is automatically deallocated.
|
9769
9861
|
**
|
9770
|
-
** The "_rhs_" in the name of this routine is an
|
9862
|
+
** The "_rhs_" in the name of this routine is an abbreviation for
|
9771
9863
|
** "Right-Hand Side".
|
9772
9864
|
*/
|
9773
9865
|
SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
|
data/lib/extralite/version.rb
CHANGED
data/lib/extralite.rb
CHANGED
@@ -2,8 +2,48 @@ require_relative './extralite_ext'
|
|
2
2
|
|
3
3
|
# Extralite is a Ruby gem for working with SQLite databases
|
4
4
|
module Extralite
|
5
|
+
|
6
|
+
SQLITE_STATUS_MEMORY_USED = 0
|
7
|
+
SQLITE_STATUS_PAGECACHE_USED = 1
|
8
|
+
SQLITE_STATUS_PAGECACHE_OVERFLOW = 2
|
9
|
+
SQLITE_STATUS_SCRATCH_USED = 3 # NOT USED
|
10
|
+
SQLITE_STATUS_SCRATCH_OVERFLOW = 4 # NOT USED
|
11
|
+
SQLITE_STATUS_MALLOC_SIZE = 5
|
12
|
+
SQLITE_STATUS_PARSER_STACK = 6
|
13
|
+
SQLITE_STATUS_PAGECACHE_SIZE = 7
|
14
|
+
SQLITE_STATUS_SCRATCH_SIZE = 8 # NOT USED
|
15
|
+
SQLITE_STATUS_MALLOC_COUNT = 9
|
16
|
+
|
17
|
+
SQLITE_DBSTATUS_LOOKASIDE_USED = 0
|
18
|
+
SQLITE_DBSTATUS_CACHE_USED = 1
|
19
|
+
SQLITE_DBSTATUS_SCHEMA_USED = 2
|
20
|
+
SQLITE_DBSTATUS_STMT_USED = 3
|
21
|
+
SQLITE_DBSTATUS_LOOKASIDE_HIT = 4
|
22
|
+
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5
|
23
|
+
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6
|
24
|
+
SQLITE_DBSTATUS_CACHE_HIT = 7
|
25
|
+
SQLITE_DBSTATUS_CACHE_MISS = 8
|
26
|
+
SQLITE_DBSTATUS_CACHE_WRITE = 9
|
27
|
+
SQLITE_DBSTATUS_DEFERRED_FKS = 10
|
28
|
+
SQLITE_DBSTATUS_CACHE_USED_SHARED = 11
|
29
|
+
SQLITE_DBSTATUS_CACHE_SPILL = 12
|
30
|
+
|
31
|
+
SQLITE_STMTSTATUS_FULLSCAN_STEP = 1
|
32
|
+
SQLITE_STMTSTATUS_SORT = 2
|
33
|
+
SQLITE_STMTSTATUS_AUTOINDEX = 3
|
34
|
+
SQLITE_STMTSTATUS_VM_STEP = 4
|
35
|
+
SQLITE_STMTSTATUS_REPREPARE = 5
|
36
|
+
SQLITE_STMTSTATUS_RUN = 6
|
37
|
+
SQLITE_STMTSTATUS_FILTER_MISS = 7
|
38
|
+
SQLITE_STMTSTATUS_FILTER_HIT = 8
|
39
|
+
SQLITE_STMTSTATUS_MEMUSED = 99
|
40
|
+
|
41
|
+
# The following class definitions are not really needed, as they're already
|
42
|
+
# defined in the C extension. We put them here for the sake of generating
|
43
|
+
# docs.
|
44
|
+
|
5
45
|
# A base class for Extralite exceptions
|
6
|
-
class Error <
|
46
|
+
class Error < ::StandardError
|
7
47
|
end
|
8
48
|
|
9
49
|
# An exception representing an SQL error emitted by SQLite
|
@@ -15,6 +55,11 @@ module Extralite
|
|
15
55
|
class BusyError < Error
|
16
56
|
end
|
17
57
|
|
58
|
+
# An exception raised when a query is interrupted by calling
|
59
|
+
# `Database#interrupt` from another thread
|
60
|
+
class InterruptError < Error
|
61
|
+
end
|
62
|
+
|
18
63
|
# An SQLite database
|
19
64
|
class Database
|
20
65
|
alias_method :execute, :query
|
@@ -42,4 +87,18 @@ module Extralite
|
|
42
87
|
query("pragma #{key}")
|
43
88
|
end
|
44
89
|
end
|
90
|
+
|
91
|
+
# An SQLite backup
|
92
|
+
class Backup
|
93
|
+
# def initialize(dst, dst_name, src, src_name); end
|
94
|
+
|
95
|
+
# def dst; end
|
96
|
+
# def src; end
|
97
|
+
|
98
|
+
# def step(pages); end
|
99
|
+
# def finish; end
|
100
|
+
|
101
|
+
# def pagecount; end
|
102
|
+
# def remaining; end
|
103
|
+
end
|
45
104
|
end
|
data/test/test_database.rb
CHANGED
@@ -243,6 +243,32 @@ end
|
|
243
243
|
{ bar: 'bye' }
|
244
244
|
], @db.query('select * from foo')
|
245
245
|
end
|
246
|
+
|
247
|
+
def test_interrupt
|
248
|
+
t = Thread.new do
|
249
|
+
sleep 0.5
|
250
|
+
@db.interrupt
|
251
|
+
end
|
252
|
+
|
253
|
+
n = 2**31
|
254
|
+
assert_raises(Extralite::InterruptError) {
|
255
|
+
@db.query <<-SQL
|
256
|
+
WITH RECURSIVE
|
257
|
+
fibo (curr, next)
|
258
|
+
AS
|
259
|
+
( SELECT 1,1
|
260
|
+
UNION ALL
|
261
|
+
SELECT next, curr+next FROM fibo
|
262
|
+
LIMIT #{n} )
|
263
|
+
SELECT curr, next FROM fibo LIMIT 1 OFFSET #{n}-1;
|
264
|
+
SQL
|
265
|
+
}
|
266
|
+
t.join
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_database_status
|
270
|
+
assert_operator 0, :<, @db.status(Extralite::SQLITE_DBSTATUS_SCHEMA_USED).first
|
271
|
+
end
|
246
272
|
end
|
247
273
|
|
248
274
|
class ScenarioTest < MiniTest::Test
|
@@ -311,3 +337,39 @@ class ScenarioTest < MiniTest::Test
|
|
311
337
|
assert_equal [1, 4, 7], result
|
312
338
|
end
|
313
339
|
end
|
340
|
+
|
341
|
+
class BackupTest < MiniTest::Test
|
342
|
+
def setup
|
343
|
+
@src = Extralite::Database.new(':memory:')
|
344
|
+
@dst = Extralite::Database.new(':memory:')
|
345
|
+
|
346
|
+
@src.query('create table t (x,y,z)')
|
347
|
+
@src.query('insert into t values (1, 2, 3)')
|
348
|
+
@src.query('insert into t values (4, 5, 6)')
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_backup
|
352
|
+
@src.backup(@dst)
|
353
|
+
assert_equal [[1, 2, 3], [4, 5, 6]], @dst.query_ary('select * from t')
|
354
|
+
end
|
355
|
+
|
356
|
+
def test_backup_with_block
|
357
|
+
progress = []
|
358
|
+
@src.backup(@dst) { |r, t| progress << [r, t] }
|
359
|
+
assert_equal [[1, 2, 3], [4, 5, 6]], @dst.query_ary('select * from t')
|
360
|
+
assert_equal [[2, 2]], progress
|
361
|
+
end
|
362
|
+
|
363
|
+
def test_backup_with_schema_names
|
364
|
+
@src.backup(@dst, 'main', 'temp')
|
365
|
+
assert_equal [[1, 2, 3], [4, 5, 6]], @dst.query_ary('select * from temp.t')
|
366
|
+
end
|
367
|
+
|
368
|
+
def test_backup_with_fn
|
369
|
+
tmp_fn = "/tmp/#{rand(86400)}.db"
|
370
|
+
@src.backup(tmp_fn)
|
371
|
+
|
372
|
+
db = Extralite::Database.new(tmp_fn)
|
373
|
+
assert_equal [[1, 2, 3], [4, 5, 6]], db.query_ary('select * from t')
|
374
|
+
end
|
375
|
+
end
|
data/test/test_extralite.rb
CHANGED
@@ -6,4 +6,28 @@ class ExtraliteTest < MiniTest::Test
|
|
6
6
|
def test_sqlite3_version
|
7
7
|
assert_match /^3\.\d+\.\d+$/, Extralite.sqlite3_version
|
8
8
|
end
|
9
|
+
|
10
|
+
def test_status
|
11
|
+
db = Extralite::Database.new(':memory:')
|
12
|
+
db.query('create table if not exists t (x,y,z)')
|
13
|
+
db.query('insert into t values (1, 2, 3)')
|
14
|
+
|
15
|
+
begin
|
16
|
+
a = Extralite::runtime_status(Extralite::SQLITE_STATUS_MEMORY_USED, false)
|
17
|
+
b = Extralite::runtime_status(Extralite::SQLITE_STATUS_MEMORY_USED)
|
18
|
+
c = Extralite::runtime_status(Extralite::SQLITE_STATUS_MEMORY_USED, true)
|
19
|
+
d = Extralite::runtime_status(Extralite::SQLITE_STATUS_MEMORY_USED, true)
|
20
|
+
|
21
|
+
assert_operator 0, :<, a[0]
|
22
|
+
assert_operator a[0], :<=, a[1]
|
23
|
+
|
24
|
+
assert_equal a, b
|
25
|
+
assert_equal a, c
|
26
|
+
|
27
|
+
assert_equal a[0], d[0]
|
28
|
+
assert_equal a[0], d[1]
|
29
|
+
ensure
|
30
|
+
db.close
|
31
|
+
end
|
32
|
+
end
|
9
33
|
end
|
@@ -200,4 +200,15 @@ end
|
|
200
200
|
{ a: '4', b: 5, c: 6 }
|
201
201
|
], @db.query('select * from foo')
|
202
202
|
end
|
203
|
+
|
204
|
+
def test_prepared_statement_status
|
205
|
+
assert_equal 0, @stmt.status(Extralite::SQLITE_STMTSTATUS_RUN)
|
206
|
+
@stmt.query
|
207
|
+
assert_equal 1, @stmt.status(Extralite::SQLITE_STMTSTATUS_RUN)
|
208
|
+
@stmt.query
|
209
|
+
assert_equal 2, @stmt.status(Extralite::SQLITE_STMTSTATUS_RUN)
|
210
|
+
@stmt.query
|
211
|
+
assert_equal 3, @stmt.status(Extralite::SQLITE_STMTSTATUS_RUN, true)
|
212
|
+
assert_equal 0, @stmt.status(Extralite::SQLITE_STMTSTATUS_RUN)
|
213
|
+
end
|
203
214
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extralite-bundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.21'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.4.1
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Extra-lightweight SQLite3 wrapper for Ruby with bundled SQLite3
|