Skip to content

Commit f52b6ec

Browse files
committed
libsql-ffi: Update bundled SQLite
1 parent e4a1a5a commit f52b6ec

5 files changed

Lines changed: 119 additions & 27 deletions

File tree

libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,38 @@
8181
** src/where.c
8282
** src/wherecode.c
8383
** test/all.test
84+
** test/dbdata.test
85+
** test/dbfuzz.c
86+
** test/dbfuzz001.test
87+
** test/dbfuzz2-seed1.db
88+
** test/dbfuzz2.c
89+
** test/dbpage.test
90+
** test/dbpagefault.test
91+
** test/dbstatus.test
92+
** test/dbstatus2.test
93+
** test/delete_db.test
94+
** test/fuzzdata1.db
95+
** test/fuzzdata2.db
96+
** test/fuzzdata3.db
97+
** test/fuzzdata4.db
98+
** test/fuzzdata5.db
99+
** test/fuzzdata6.db
100+
** test/fuzzdata7.db
101+
** test/fuzzdata8.db
102+
** test/indexedby.test
103+
** test/manydb.test
104+
** test/memdb.test
105+
** test/memdb1.test
106+
** test/memdb2.test
107+
** test/optfuzz-db01.c
108+
** test/optfuzz-db01.txt
84109
** test/permutations.test
110+
** test/resetdb.test
85111
** test/rowvaluevtab.test
112+
** test/sessionfuzz-data1.db
113+
** test/tempdb.test
114+
** test/tempdb2.test
115+
** test/tkt-94c04eaadb.test
86116
** tool/mkkeywordhash.c
87117
** tool/mksqlite3c-noext.tcl
88118
** tool/mksqlite3c.tcl
@@ -10991,7 +11021,7 @@ SQLITE_API int libsql_wal_insert_end(sqlite3*);
1099111021
** CAPI3REF: Insert a frame into the WAL
1099211022
** METHOD: sqlite3
1099311023
*/
10994-
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int);
11024+
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int, int *);
1099511025

1099611026
/*
1099711027
** CAPI3REF: Low-level system error code
@@ -16441,7 +16471,7 @@ SQLITE_PRIVATE int sqlite3PagerWalFrameCount(Pager *, unsigned int *);
1644116471
SQLITE_PRIVATE int sqlite3PagerWalReadFrame(Pager *, unsigned int, void *, unsigned int);
1644216472
SQLITE_PRIVATE int sqlite3PagerWalBeginCommit(Pager*);
1644316473
SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager*);
16444-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int);
16474+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int, int *);
1644516475

1644616476
SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
1644716477
SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);
@@ -65340,9 +65370,12 @@ SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager *pPager) {
6534065370
return rc;
6534165371
}
6534265372

65343-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf) {
65373+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf, int *pConflict) {
6534465374
int rc = SQLITE_OK;
6534565375

65376+
if( pConflict ) {
65377+
*pConflict = 0;
65378+
}
6534665379
if (!pagerUseWal(pPager)) {
6534765380
return SQLITE_ERROR;
6534865381
}
@@ -65352,6 +65385,22 @@ SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, voi
6535265385
return rc;
6535365386
}
6535465387
if (iFrame <= mxFrame) {
65388+
unsigned long frame_len = nBuf-24;
65389+
unsigned char current[frame_len];
65390+
rc = pPager->wal->methods.xReadFrame(pPager->wal->pData, iFrame, frame_len, current);
65391+
if (rc != SQLITE_OK) {
65392+
return rc;
65393+
}
65394+
int conflict = 0;
65395+
if (memcmp(pBuf+24, current, frame_len) != 0) {
65396+
conflict = 1;
65397+
}
65398+
if (pConflict) {
65399+
*pConflict = conflict;
65400+
}
65401+
if (conflict) {
65402+
return SQLITE_ERROR;
65403+
}
6535565404
return SQLITE_OK;
6535665405
}
6535765406
u8 *aFrame = (u8*)pBuf;
@@ -183347,7 +183396,8 @@ int libsql_wal_insert_frame(
183347183396
sqlite3* db,
183348183397
unsigned int iFrame,
183349183398
void *pBuf,
183350-
unsigned int nBuf
183399+
unsigned int nBuf,
183400+
int *pConflict
183351183401
){
183352183402
int rc = SQLITE_OK;
183353183403
Pager *pPager;
@@ -183362,7 +183412,7 @@ int libsql_wal_insert_frame(
183362183412

183363183413
sqlite3_mutex_enter(db->mutex);
183364183414
pPager = sqlite3BtreePager(db->aDb[0].pBt);
183365-
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf);
183415+
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf, pConflict);
183366183416
if (rc != SQLITE_OK) {
183367183417
goto out_unlock;
183368183418
}

libsql-ffi/bundled/bindings/bindgen.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ extern "C" {
2323
) -> ::std::os::raw::c_int;
2424
}
2525

26-
pub const __GNUC_VA_LIST: i32 = 1;
2726
pub const SQLITE_VERSION: &[u8; 7] = b"3.45.1\0";
2827
pub const SQLITE_VERSION_NUMBER: i32 = 3045001;
2928
pub const SQLITE_SOURCE_ID: &[u8; 85] =
@@ -502,8 +501,8 @@ pub const FTS5_TOKENIZE_DOCUMENT: i32 = 4;
502501
pub const FTS5_TOKENIZE_AUX: i32 = 8;
503502
pub const FTS5_TOKEN_COLOCATED: i32 = 1;
504503
pub const WAL_SAVEPOINT_NDATA: i32 = 4;
505-
pub type va_list = __builtin_va_list;
506504
pub type __gnuc_va_list = __builtin_va_list;
505+
pub type va_list = __builtin_va_list;
507506
extern "C" {
508507
pub static sqlite3_version: [::std::os::raw::c_char; 0usize];
509508
}
@@ -940,7 +939,7 @@ extern "C" {
940939
extern "C" {
941940
pub fn sqlite3_vmprintf(
942941
arg1: *const ::std::os::raw::c_char,
943-
arg2: *mut __va_list_tag,
942+
arg2: va_list,
944943
) -> *mut ::std::os::raw::c_char;
945944
}
946945
extern "C" {
@@ -956,7 +955,7 @@ extern "C" {
956955
arg1: ::std::os::raw::c_int,
957956
arg2: *mut ::std::os::raw::c_char,
958957
arg3: *const ::std::os::raw::c_char,
959-
arg4: *mut __va_list_tag,
958+
arg4: va_list,
960959
) -> *mut ::std::os::raw::c_char;
961960
}
962961
extern "C" {
@@ -2506,7 +2505,7 @@ extern "C" {
25062505
pub fn sqlite3_str_vappendf(
25072506
arg1: *mut sqlite3_str,
25082507
zFormat: *const ::std::os::raw::c_char,
2509-
arg2: *mut __va_list_tag,
2508+
arg2: va_list,
25102509
);
25112510
}
25122511
extern "C" {
@@ -2895,6 +2894,7 @@ extern "C" {
28952894
arg2: ::std::os::raw::c_uint,
28962895
arg3: *mut ::std::os::raw::c_void,
28972896
arg4: ::std::os::raw::c_uint,
2897+
arg5: *mut ::std::os::raw::c_int,
28982898
) -> ::std::os::raw::c_int;
28992899
}
29002900
extern "C" {
@@ -3573,12 +3573,4 @@ extern "C" {
35733573
extern "C" {
35743574
pub static sqlite3_wal_manager: libsql_wal_manager;
35753575
}
3576-
pub type __builtin_va_list = [__va_list_tag; 1usize];
3577-
#[repr(C)]
3578-
#[derive(Debug, Copy, Clone)]
3579-
pub struct __va_list_tag {
3580-
pub gp_offset: ::std::os::raw::c_uint,
3581-
pub fp_offset: ::std::os::raw::c_uint,
3582-
pub overflow_arg_area: *mut ::std::os::raw::c_void,
3583-
pub reg_save_area: *mut ::std::os::raw::c_void,
3584-
}
3576+
pub type __builtin_va_list = *mut ::std::os::raw::c_char;

libsql-ffi/bundled/bindings/session_bindgen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ extern "C" {
2323
) -> ::std::os::raw::c_int;
2424
}
2525

26-
pub const __GNUC_VA_LIST: i32 = 1;
2726
pub const SQLITE_VERSION: &[u8; 7] = b"3.45.1\0";
2827
pub const SQLITE_VERSION_NUMBER: i32 = 3045001;
2928
pub const SQLITE_SOURCE_ID: &[u8; 85] =
@@ -519,8 +518,8 @@ pub const FTS5_TOKENIZE_DOCUMENT: i32 = 4;
519518
pub const FTS5_TOKENIZE_AUX: i32 = 8;
520519
pub const FTS5_TOKEN_COLOCATED: i32 = 1;
521520
pub const WAL_SAVEPOINT_NDATA: i32 = 4;
522-
pub type va_list = __builtin_va_list;
523521
pub type __gnuc_va_list = __builtin_va_list;
522+
pub type va_list = __builtin_va_list;
524523
extern "C" {
525524
pub static sqlite3_version: [::std::os::raw::c_char; 0usize];
526525
}
@@ -2912,6 +2911,7 @@ extern "C" {
29122911
arg2: ::std::os::raw::c_uint,
29132912
arg3: *mut ::std::os::raw::c_void,
29142913
arg4: ::std::os::raw::c_uint,
2914+
arg5: *mut ::std::os::raw::c_int,
29152915
) -> ::std::os::raw::c_int;
29162916
}
29172917
extern "C" {

libsql-ffi/bundled/src/sqlite3.c

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,38 @@
8181
** src/where.c
8282
** src/wherecode.c
8383
** test/all.test
84+
** test/dbdata.test
85+
** test/dbfuzz.c
86+
** test/dbfuzz001.test
87+
** test/dbfuzz2-seed1.db
88+
** test/dbfuzz2.c
89+
** test/dbpage.test
90+
** test/dbpagefault.test
91+
** test/dbstatus.test
92+
** test/dbstatus2.test
93+
** test/delete_db.test
94+
** test/fuzzdata1.db
95+
** test/fuzzdata2.db
96+
** test/fuzzdata3.db
97+
** test/fuzzdata4.db
98+
** test/fuzzdata5.db
99+
** test/fuzzdata6.db
100+
** test/fuzzdata7.db
101+
** test/fuzzdata8.db
102+
** test/indexedby.test
103+
** test/manydb.test
104+
** test/memdb.test
105+
** test/memdb1.test
106+
** test/memdb2.test
107+
** test/optfuzz-db01.c
108+
** test/optfuzz-db01.txt
84109
** test/permutations.test
110+
** test/resetdb.test
85111
** test/rowvaluevtab.test
112+
** test/sessionfuzz-data1.db
113+
** test/tempdb.test
114+
** test/tempdb2.test
115+
** test/tkt-94c04eaadb.test
86116
** tool/mkkeywordhash.c
87117
** tool/mksqlite3c-noext.tcl
88118
** tool/mksqlite3c.tcl
@@ -10991,7 +11021,7 @@ SQLITE_API int libsql_wal_insert_end(sqlite3*);
1099111021
** CAPI3REF: Insert a frame into the WAL
1099211022
** METHOD: sqlite3
1099311023
*/
10994-
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int);
11024+
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int, int *);
1099511025

1099611026
/*
1099711027
** CAPI3REF: Low-level system error code
@@ -16441,7 +16471,7 @@ SQLITE_PRIVATE int sqlite3PagerWalFrameCount(Pager *, unsigned int *);
1644116471
SQLITE_PRIVATE int sqlite3PagerWalReadFrame(Pager *, unsigned int, void *, unsigned int);
1644216472
SQLITE_PRIVATE int sqlite3PagerWalBeginCommit(Pager*);
1644316473
SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager*);
16444-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int);
16474+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int, int *);
1644516475

1644616476
SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
1644716477
SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);
@@ -65340,9 +65370,12 @@ SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager *pPager) {
6534065370
return rc;
6534165371
}
6534265372

65343-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf) {
65373+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf, int *pConflict) {
6534465374
int rc = SQLITE_OK;
6534565375

65376+
if( pConflict ) {
65377+
*pConflict = 0;
65378+
}
6534665379
if (!pagerUseWal(pPager)) {
6534765380
return SQLITE_ERROR;
6534865381
}
@@ -65352,6 +65385,22 @@ SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, voi
6535265385
return rc;
6535365386
}
6535465387
if (iFrame <= mxFrame) {
65388+
unsigned long frame_len = nBuf-24;
65389+
unsigned char current[frame_len];
65390+
rc = pPager->wal->methods.xReadFrame(pPager->wal->pData, iFrame, frame_len, current);
65391+
if (rc != SQLITE_OK) {
65392+
return rc;
65393+
}
65394+
int conflict = 0;
65395+
if (memcmp(pBuf+24, current, frame_len) != 0) {
65396+
conflict = 1;
65397+
}
65398+
if (pConflict) {
65399+
*pConflict = conflict;
65400+
}
65401+
if (conflict) {
65402+
return SQLITE_ERROR;
65403+
}
6535565404
return SQLITE_OK;
6535665405
}
6535765406
u8 *aFrame = (u8*)pBuf;
@@ -183347,7 +183396,8 @@ int libsql_wal_insert_frame(
183347183396
sqlite3* db,
183348183397
unsigned int iFrame,
183349183398
void *pBuf,
183350-
unsigned int nBuf
183399+
unsigned int nBuf,
183400+
int *pConflict
183351183401
){
183352183402
int rc = SQLITE_OK;
183353183403
Pager *pPager;
@@ -183362,7 +183412,7 @@ int libsql_wal_insert_frame(
183362183412

183363183413
sqlite3_mutex_enter(db->mutex);
183364183414
pPager = sqlite3BtreePager(db->aDb[0].pBt);
183365-
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf);
183415+
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf, pConflict);
183366183416
if (rc != SQLITE_OK) {
183367183417
goto out_unlock;
183368183418
}

libsql-ffi/bundled/src/sqlite3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10602,7 +10602,7 @@ SQLITE_API int libsql_wal_insert_end(sqlite3*);
1060210602
** CAPI3REF: Insert a frame into the WAL
1060310603
** METHOD: sqlite3
1060410604
*/
10605-
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int);
10605+
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int, int *);
1060610606

1060710607
/*
1060810608
** CAPI3REF: Low-level system error code

0 commit comments

Comments
 (0)