Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 8af748f

Browse files
committed
Imported 3.40.1 sources
1 parent 60c99bb commit 8af748f

File tree

8 files changed

+15341
-5698
lines changed

8 files changed

+15341
-5698
lines changed

dist/orig/shell.c

Lines changed: 3986 additions & 1197 deletions
Large diffs are not rendered by default.

dist/orig/sqlite3.c

Lines changed: 3586 additions & 1589 deletions
Large diffs are not rendered by default.

dist/orig/sqlite3.h

Lines changed: 91 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ extern "C" {
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149-
#define SQLITE_VERSION "3.39.2"
150-
#define SQLITE_VERSION_NUMBER 3039002
151-
#define SQLITE_SOURCE_ID "2022-07-21 15:24:47 698edb77537b67c41adc68f9b892db56bcf9a55e00371a61420f3ddd668e6603"
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"
152152

153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
@@ -670,13 +670,17 @@ SQLITE_API int sqlite3_exec(
670670
**
671671
** SQLite uses one of these integer values as the second
672672
** 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.
674678
*/
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 */
680684

681685
/*
682686
** CAPI3REF: Synchronization Type Flags
@@ -754,7 +758,14 @@ struct sqlite3_file {
754758
** <li> [SQLITE_LOCK_PENDING], or
755759
** <li> [SQLITE_LOCK_EXCLUSIVE].
756760
** </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.
758769
** The xCheckReservedLock() method checks whether any database connection,
759770
** either in this process or in some other process, is holding a RESERVED,
760771
** PENDING, or EXCLUSIVE lock on the file. It returns true
@@ -859,9 +870,8 @@ struct sqlite3_io_methods {
859870
** opcode causes the xFileControl method to write the current state of
860871
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
861872
** [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].
865875
**
866876
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
867877
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
@@ -1182,6 +1192,12 @@ struct sqlite3_io_methods {
11821192
**
11831193
** <li>[[SQLITE_FCNTL_CKSM_FILE]]
11841194
** 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.
11851201
** </ul>
11861202
*/
11871203
#define SQLITE_FCNTL_LOCKSTATE 1
@@ -1224,6 +1240,7 @@ struct sqlite3_io_methods {
12241240
#define SQLITE_FCNTL_CKPT_START 39
12251241
#define SQLITE_FCNTL_EXTERNAL_READER 40
12261242
#define SQLITE_FCNTL_CKSM_FILE 41
1243+
#define SQLITE_FCNTL_RESET_CACHE 42
12271244

12281245
/* deprecated names */
12291246
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -1253,6 +1270,26 @@ typedef struct sqlite3_mutex sqlite3_mutex;
12531270
*/
12541271
typedef struct sqlite3_api_routines sqlite3_api_routines;
12551272

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+
12561293
/*
12571294
** CAPI3REF: OS Interface Object
12581295
**
@@ -1431,7 +1468,7 @@ struct sqlite3_vfs {
14311468
sqlite3_vfs *pNext; /* Next registered VFS */
14321469
const char *zName; /* Name of this virtual file system */
14331470
void *pAppData; /* Pointer to application-specific data */
1434-
int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
1471+
int (*xOpen)(sqlite3_vfs*, sqlite3_filename zName, sqlite3_file*,
14351472
int flags, int *pOutFlags);
14361473
int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
14371474
int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
@@ -2309,6 +2346,7 @@ struct sqlite3_mem_methods {
23092346
** <ul>
23102347
** <li> The [PRAGMA writable_schema=ON] statement.
23112348
** <li> The [PRAGMA journal_mode=OFF] statement.
2349+
** <li> The [PRAGMA schema_version=N] statement.
23122350
** <li> Writes to the [sqlite_dbpage] virtual table.
23132351
** <li> Direct writes to [shadow tables].
23142352
** </ul>
@@ -3424,6 +3462,9 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
34243462
** <dd>The database is opened [shared cache] enabled, overriding
34253463
** the default shared cache setting provided by
34263464
** [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.
34273468
**
34283469
** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt>
34293470
** <dd>The database is opened [shared cache] disabled, overriding
@@ -3439,7 +3480,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
34393480
** to return an extended result code.</dd>
34403481
**
34413482
** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3442-
** <dd>The database filename is not allowed to be a symbolic link</dd>
3483+
** <dd>The database filename is not allowed to contain a symbolic link</dd>
34433484
** </dl>)^
34443485
**
34453486
** If the 3rd parameter to sqlite3_open_v2() is not one of the
@@ -3698,10 +3739,10 @@ SQLITE_API int sqlite3_open_v2(
36983739
**
36993740
** See the [URI filename] documentation for additional information.
37003741
*/
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);
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);
37053746

37063747
/*
37073748
** CAPI3REF: Translate filenames
@@ -3730,9 +3771,9 @@ SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N);
37303771
** return value from [sqlite3_db_filename()], then the result is
37313772
** undefined and is likely a memory access violation.
37323773
*/
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*);
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);
37363777

37373778
/*
37383779
** CAPI3REF: Database File Corresponding To A Journal
@@ -3798,14 +3839,14 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*);
37983839
** then the corresponding [sqlite3_module.xClose() method should also be
37993840
** invoked prior to calling sqlite3_free_filename(Y).
38003841
*/
3801-
SQLITE_API char *sqlite3_create_filename(
3842+
SQLITE_API sqlite3_filename sqlite3_create_filename(
38023843
const char *zDatabase,
38033844
const char *zJournal,
38043845
const char *zWal,
38053846
int nParam,
38063847
const char **azParam
38073848
);
3808-
SQLITE_API void sqlite3_free_filename(char*);
3849+
SQLITE_API void sqlite3_free_filename(sqlite3_filename);
38093850

38103851
/*
38113852
** CAPI3REF: Error Codes And Messages
@@ -5508,6 +5549,16 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
55085549
** then the conversion is performed. Otherwise no conversion occurs.
55095550
** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
55105551
**
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+
**
55115562
** ^Within the [xUpdate] method of a [virtual table], the
55125563
** sqlite3_value_nochange(X) interface returns true if and only if
55135564
** the column corresponding to X is unchanged by the UPDATE operation
@@ -5572,6 +5623,7 @@ SQLITE_API int sqlite3_value_type(sqlite3_value*);
55725623
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
55735624
SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
55745625
SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
5626+
SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
55755627

55765628
/*
55775629
** CAPI3REF: Finding The Subtype Of SQL Values
@@ -5625,7 +5677,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*);
56255677
**
56265678
** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
56275679
** when first called if N is less than or equal to zero or if a memory
5628-
** allocate error occurs.
5680+
** allocation error occurs.
56295681
**
56305682
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
56315683
** determined by the N parameter on first successful call. Changing the
@@ -5830,9 +5882,10 @@ typedef void (*sqlite3_destructor_type)(void*);
58305882
** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
58315883
** ^SQLite takes the text result from the application from
58325884
** the 2nd parameter of the sqlite3_result_text* interfaces.
5833-
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5834-
** is negative, then SQLite takes result text from the 2nd parameter
5835-
** through the first zero character.
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.
58365889
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
58375890
** is non-negative, then as many bytes (not characters) of the text
58385891
** pointed to by the 2nd parameter are taken as the application-defined
@@ -6328,7 +6381,7 @@ SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N);
63286381
** <li> [sqlite3_filename_wal()]
63296382
** </ul>
63306383
*/
6331-
SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
6384+
SQLITE_API sqlite3_filename sqlite3_db_filename(sqlite3 *db, const char *zDbName);
63326385

63336386
/*
63346387
** CAPI3REF: Determine if a database is read-only
@@ -6465,7 +6518,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
64656518
** function C that is invoked prior to each autovacuum of the database
64666519
** file. ^The callback is passed a copy of the generic data pointer (P),
64676520
** the schema-name of the attached database that is being autovacuumed,
6468-
** the the size of the database file in pages, the number of free pages,
6521+
** the size of the database file in pages, the number of free pages,
64696522
** and the number of bytes per page, respectively. The callback should
64706523
** return the number of free pages that should be removed by the
64716524
** autovacuum. ^If the callback returns zero, then no autovacuum happens.
@@ -6586,6 +6639,11 @@ SQLITE_API void *sqlite3_update_hook(
65866639
** to the same database. Sharing is enabled if the argument is true
65876640
** and disabled if the argument is false.)^
65886641
**
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+
**
65896647
** ^Cache sharing is enabled and disabled for an entire process.
65906648
** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]).
65916649
** In prior versions of SQLite,
@@ -6684,7 +6742,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
66846742
** ^The soft heap limit may not be greater than the hard heap limit.
66856743
** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
66866744
** is invoked with a value of N that is greater than the hard heap limit,
6687-
** the the soft heap limit is set to the value of the hard heap limit.
6745+
** the soft heap limit is set to the value of the hard heap limit.
66886746
** ^The soft heap limit is automatically enabled whenever the hard heap
66896747
** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
66906748
** the soft heap limit is outside the range of 1..N, then the soft heap
@@ -8979,7 +9037,7 @@ typedef struct sqlite3_backup sqlite3_backup;
89799037
** if the application incorrectly accesses the destination [database connection]
89809038
** and so no error code is reported, but the operations may malfunction
89819039
** nevertheless. Use of the destination database connection while a
8982-
** backup is in progress might also also cause a mutex deadlock.
9040+
** backup is in progress might also cause a mutex deadlock.
89839041
**
89849042
** If running in [shared cache mode], the application must
89859043
** guarantee that the shared cache used by the destination database
@@ -9407,7 +9465,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
94079465
*/
94089466
#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
94099467
#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
9410-
#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
9468+
#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */
94119469
#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
94129470

94139471
/*

dist/orig/sqlite3ext.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ struct sqlite3_api_routines {
331331
const char *(*filename_journal)(const char*);
332332
const char *(*filename_wal)(const char*);
333333
/* Version 3.32.0 and later */
334-
char *(*create_filename)(const char*,const char*,const char*,
334+
const char *(*create_filename)(const char*,const char*,const char*,
335335
int,const char**);
336-
void (*free_filename)(char*);
336+
void (*free_filename)(const char*);
337337
sqlite3_file *(*database_file_object)(const char*);
338338
/* Version 3.34.0 and later */
339339
int (*txn_state)(sqlite3*,const char*);
@@ -357,6 +357,8 @@ struct sqlite3_api_routines {
357357
unsigned char *(*serialize)(sqlite3*,const char *,sqlite3_int64*,
358358
unsigned int);
359359
const char *(*db_name)(sqlite3*,int);
360+
/* Version 3.40.0 and later */
361+
int (*value_encoding)(sqlite3_value*);
360362
};
361363

362364
/*
@@ -681,6 +683,8 @@ typedef int (*sqlite3_loadext_entry)(
681683
#define sqlite3_serialize sqlite3_api->serialize
682684
#endif
683685
#define sqlite3_db_name sqlite3_api->db_name
686+
/* Version 3.40.0 and later */
687+
#define sqlite3_value_encoding sqlite3_api->value_encoding
684688
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
685689

686690
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)

0 commit comments

Comments
 (0)