Skip to content

Commit 44eae99

Browse files
committed
Update to sqlite 3.50.0
1 parent ad8fb36 commit 44eae99

File tree

6 files changed

+3586
-1888
lines changed

6 files changed

+3586
-1888
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let package = Package(
2929
.linkedLibrary("wasi-emulated-signal", .when(platforms: [.wasi])),
3030
.linkedLibrary("wasi-emulated-process-clocks", .when(platforms: [.wasi])),
3131
.linkedLibrary("wasi-emulated-getpid", .when(platforms: [.wasi])),
32+
.linkedLibrary("m", .when(platforms: [.linux])),
3233
]
3334
),
3435
.target(

Sources/CSQLite/include/sqlite3.h

Lines changed: 102 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ extern "C" {
133133
**
134134
** Since [version 3.6.18] ([dateof:3.6.18]),
135135
** SQLite source code has been stored in the
136-
** <a href="http://www.fossil-scm.org/">Fossil configuration management
136+
** <a href="http://fossil-scm.org/">Fossil configuration management
137137
** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to
138138
** a string which identifies a particular check-in of SQLite
139139
** within its configuration management system. ^The SQLITE_SOURCE_ID
@@ -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.49.1"
150-
#define SQLITE_VERSION_NUMBER 3049001
151-
#define SQLITE_SOURCE_ID "2025-02-18 13:38:58 873d4e274b4988d260ba8354a9718324a1c26187a4ab4c1cc0227c03d0f10e70"
149+
#define SQLITE_VERSION "3.50.0"
150+
#define SQLITE_VERSION_NUMBER 3050000
151+
#define SQLITE_SOURCE_ID "2025-05-29 14:26:00 dfc790f998f450d9c35e3ba1c8c89c17466cb559f87b0239e4aab9d34e28f742"
152152

153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
@@ -1163,6 +1163,12 @@ struct sqlite3_io_methods {
11631163
** the value that M is to be set to. Before returning, the 32-bit signed
11641164
** integer is overwritten with the previous value of M.
11651165
**
1166+
** <li>[[SQLITE_FCNTL_BLOCK_ON_CONNECT]]
1167+
** The [SQLITE_FCNTL_BLOCK_ON_CONNECT] opcode is used to configure the
1168+
** VFS to block when taking a SHARED lock to connect to a wal mode database.
1169+
** This is used to implement the functionality associated with
1170+
** SQLITE_SETLK_BLOCK_ON_CONNECT.
1171+
**
11661172
** <li>[[SQLITE_FCNTL_DATA_VERSION]]
11671173
** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to
11681174
** a database file. The argument is a pointer to a 32-bit unsigned integer.
@@ -1259,6 +1265,7 @@ struct sqlite3_io_methods {
12591265
#define SQLITE_FCNTL_CKSM_FILE 41
12601266
#define SQLITE_FCNTL_RESET_CACHE 42
12611267
#define SQLITE_FCNTL_NULL_IO 43
1268+
#define SQLITE_FCNTL_BLOCK_ON_CONNECT 44
12621269

12631270
/* deprecated names */
12641271
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -1989,13 +1996,16 @@ struct sqlite3_mem_methods {
19891996
**
19901997
** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
19911998
** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
1992-
** the default size of lookaside memory on each [database connection].
1999+
** the default size of [lookaside memory] on each [database connection].
19932000
** The first argument is the
1994-
** size of each lookaside buffer slot and the second is the number of
1995-
** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
1996-
** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1997-
** option to [sqlite3_db_config()] can be used to change the lookaside
1998-
** configuration on individual connections.)^ </dd>
2001+
** size of each lookaside buffer slot ("sz") and the second is the number of
2002+
** slots allocated to each database connection ("cnt").)^
2003+
** ^(SQLITE_CONFIG_LOOKASIDE sets the <i>default</i> lookaside size.
2004+
** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can
2005+
** be used to change the lookaside configuration on individual connections.)^
2006+
** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the
2007+
** default lookaside configuration at compile-time.
2008+
** </dd>
19992009
**
20002010
** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
20012011
** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
@@ -2232,31 +2242,50 @@ struct sqlite3_mem_methods {
22322242
** [[SQLITE_DBCONFIG_LOOKASIDE]]
22332243
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
22342244
** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
2235-
** configuration of the lookaside memory allocator within a database
2245+
** configuration of the [lookaside memory allocator] within a database
22362246
** connection.
22372247
** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
22382248
** in the [DBCONFIG arguments|usual format].
22392249
** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
22402250
** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
22412251
** should have a total of five parameters.
2242-
** ^The first argument (the third parameter to [sqlite3_db_config()] is a
2252+
** <ol>
2253+
** <li><p>The first argument ("buf") is a
22432254
** pointer to a memory buffer to use for lookaside memory.
2244-
** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
2245-
** may be NULL in which case SQLite will allocate the
2246-
** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
2247-
** size of each lookaside buffer slot. ^The third argument is the number of
2248-
** slots. The size of the buffer in the first argument must be greater than
2249-
** or equal to the product of the second and third arguments. The buffer
2250-
** must be aligned to an 8-byte boundary. ^If the second argument to
2251-
** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2252-
** rounded down to the next smaller multiple of 8. ^(The lookaside memory
2255+
** The first argument may be NULL in which case SQLite will allocate the
2256+
** lookaside buffer itself using [sqlite3_malloc()].
2257+
** <li><P>The second argument ("sz") is the
2258+
** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2259+
** is less than 8. The "sz" argument should be a multiple of 8 less than
2260+
** 65536. If "sz" does not meet this constraint, it is reduced in size until
2261+
** it does.
2262+
** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2263+
** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2264+
** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2265+
** parameter is usually chosen so that the product of "sz" and "cnt" is less
2266+
** than 1,000,000.
2267+
** </ol>
2268+
** <p>If the "buf" argument is not NULL, then it must
2269+
** point to a memory buffer with a size that is greater than
2270+
** or equal to the product of "sz" and "cnt".
2271+
** The buffer must be aligned to an 8-byte boundary.
2272+
** The lookaside memory
22532273
** configuration for a database connection can only be changed when that
22542274
** connection is not currently using lookaside memory, or in other words
2255-
** when the "current value" returned by
2256-
** [sqlite3_db_status](D,[SQLITE_DBSTATUS_LOOKASIDE_USED],...) is zero.
2275+
** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero.
22572276
** Any attempt to change the lookaside memory configuration when lookaside
22582277
** memory is in use leaves the configuration unchanged and returns
2259-
** [SQLITE_BUSY].)^</dd>
2278+
** [SQLITE_BUSY].
2279+
** If the "buf" argument is NULL and an attempt
2280+
** to allocate memory based on "sz" and "cnt" fails, then
2281+
** lookaside is silently disabled.
2282+
** <p>
2283+
** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the
2284+
** default lookaside configuration at initialization. The
2285+
** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside
2286+
** configuration at compile-time. Typical values for lookaside are 1200 for
2287+
** "sz" and 40 to 100 for "cnt".
2288+
** </dd>
22602289
**
22612290
** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
22622291
** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
@@ -2993,6 +3022,44 @@ SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
29933022
*/
29943023
SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
29953024

3025+
/*
3026+
** CAPI3REF: Set the Setlk Timeout
3027+
** METHOD: sqlite3
3028+
**
3029+
** This routine is only useful in SQLITE_ENABLE_SETLK_TIMEOUT builds. If
3030+
** the VFS supports blocking locks, it sets the timeout in ms used by
3031+
** eligible locks taken on wal mode databases by the specified database
3032+
** handle. In non-SQLITE_ENABLE_SETLK_TIMEOUT builds, or if the VFS does
3033+
** not support blocking locks, this function is a no-op.
3034+
**
3035+
** Passing 0 to this function disables blocking locks altogether. Passing
3036+
** -1 to this function requests that the VFS blocks for a long time -
3037+
** indefinitely if possible. The results of passing any other negative value
3038+
** are undefined.
3039+
**
3040+
** Internally, each SQLite database handle store two timeout values - the
3041+
** busy-timeout (used for rollback mode databases, or if the VFS does not
3042+
** support blocking locks) and the setlk-timeout (used for blocking locks
3043+
** on wal-mode databases). The sqlite3_busy_timeout() method sets both
3044+
** values, this function sets only the setlk-timeout value. Therefore,
3045+
** to configure separate busy-timeout and setlk-timeout values for a single
3046+
** database handle, call sqlite3_busy_timeout() followed by this function.
3047+
**
3048+
** Whenever the number of connections to a wal mode database falls from
3049+
** 1 to 0, the last connection takes an exclusive lock on the database,
3050+
** then checkpoints and deletes the wal file. While it is doing this, any
3051+
** new connection that tries to read from the database fails with an
3052+
** SQLITE_BUSY error. Or, if the SQLITE_SETLK_BLOCK_ON_CONNECT flag is
3053+
** passed to this API, the new connection blocks until the exclusive lock
3054+
** has been released.
3055+
*/
3056+
SQLITE_API int sqlite3_setlk_timeout(sqlite3*, int ms, int flags);
3057+
3058+
/*
3059+
** CAPI3REF: Flags for sqlite3_setlk_timeout()
3060+
*/
3061+
#define SQLITE_SETLK_BLOCK_ON_CONNECT 0x01
3062+
29963063
/*
29973064
** CAPI3REF: Convenience Routines For Running Queries
29983065
** METHOD: sqlite3
@@ -5108,7 +5175,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
51085175
** other than [SQLITE_ROW] before any subsequent invocation of
51095176
** sqlite3_step(). Failure to reset the prepared statement using
51105177
** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from
5111-
** sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1],
5178+
** sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1]),
51125179
** sqlite3_step() began
51135180
** calling [sqlite3_reset()] automatically in this circumstance rather
51145181
** than returning [SQLITE_MISUSE]. This is not considered a compatibility
@@ -7004,6 +7071,8 @@ SQLITE_API int sqlite3_autovacuum_pages(
70047071
**
70057072
** ^The second argument is a pointer to the function to invoke when a
70067073
** row is updated, inserted or deleted in a rowid table.
7074+
** ^The update hook is disabled by invoking sqlite3_update_hook()
7075+
** with a NULL pointer as the second parameter.
70077076
** ^The first argument to the callback is a copy of the third argument
70087077
** to sqlite3_update_hook().
70097078
** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
@@ -11486,9 +11555,10 @@ SQLITE_API void sqlite3session_table_filter(
1148611555
** is inserted while a session object is enabled, then later deleted while
1148711556
** the same session object is disabled, no INSERT record will appear in the
1148811557
** changeset, even though the delete took place while the session was disabled.
11489-
** Or, if one field of a row is updated while a session is disabled, and
11490-
** another field of the same row is updated while the session is enabled, the
11491-
** resulting changeset will contain an UPDATE change that updates both fields.
11558+
** Or, if one field of a row is updated while a session is enabled, and
11559+
** then another field of the same row is updated while the session is disabled,
11560+
** the resulting changeset will contain an UPDATE change that updates both
11561+
** fields.
1149211562
*/
1149311563
SQLITE_API int sqlite3session_changeset(
1149411564
sqlite3_session *pSession, /* Session object */
@@ -11560,8 +11630,9 @@ SQLITE_API sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession
1156011630
** database zFrom the contents of the two compatible tables would be
1156111631
** identical.
1156211632
**
11563-
** It an error if database zFrom does not exist or does not contain the
11564-
** required compatible table.
11633+
** Unless the call to this function is a no-op as described above, it is an
11634+
** error if database zFrom does not exist or does not contain the required
11635+
** compatible table.
1156511636
**
1156611637
** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite
1156711638
** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
@@ -11696,7 +11767,7 @@ SQLITE_API int sqlite3changeset_start_v2(
1169611767
** The following flags may passed via the 4th parameter to
1169711768
** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
1169811769
**
11699-
** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
11770+
** <dt>SQLITE_CHANGESETSTART_INVERT <dd>
1170011771
** Invert the changeset while iterating through it. This is equivalent to
1170111772
** inverting a changeset using sqlite3changeset_invert() before applying it.
1170211773
** It is an error to specify this flag with a patchset.
@@ -12011,19 +12082,6 @@ SQLITE_API int sqlite3changeset_concat(
1201112082
void **ppOut /* OUT: Buffer containing output changeset */
1201212083
);
1201312084

12014-
12015-
/*
12016-
** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
12017-
*/
12018-
SQLITE_API int sqlite3changeset_upgrade(
12019-
sqlite3 *db,
12020-
const char *zDb,
12021-
int nIn, const void *pIn, /* Input changeset */
12022-
int *pnOut, void **ppOut /* OUT: Inverse of input */
12023-
);
12024-
12025-
12026-
1202712085
/*
1202812086
** CAPI3REF: Changegroup Handle
1202912087
**

Sources/CSQLite/include/sqlite3ext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ struct sqlite3_api_routines {
366366
/* Version 3.44.0 and later */
367367
void *(*get_clientdata)(sqlite3*,const char*);
368368
int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*));
369+
/* Version 3.50.0 and later */
370+
int (*setlk_timeout)(sqlite3*,int,int);
369371
};
370372

371373
/*
@@ -699,6 +701,8 @@ typedef int (*sqlite3_loadext_entry)(
699701
/* Version 3.44.0 and later */
700702
#define sqlite3_get_clientdata sqlite3_api->get_clientdata
701703
#define sqlite3_set_clientdata sqlite3_api->set_clientdata
704+
/* Version 3.50.0 and later */
705+
#define sqlite3_setlk_timeout sqlite3_api->setlk_timeout
702706
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
703707

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

0 commit comments

Comments
 (0)