Skip to content

Commit 28c8d4a

Browse files
committed
libsql-ffi: Update bundled SQLite
1 parent dec027e commit 28c8d4a

4 files changed

Lines changed: 116 additions & 23 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
@@ -10989,7 +11019,7 @@ SQLITE_API int libsql_wal_insert_end(sqlite3*);
1098911019
** CAPI3REF: Insert a frame into the WAL
1099011020
** METHOD: sqlite3
1099111021
*/
10992-
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int);
11022+
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int, int *);
1099311023

1099411024
/*
1099511025
** CAPI3REF: Low-level system error code
@@ -16439,7 +16469,7 @@ SQLITE_PRIVATE int sqlite3PagerWalFrameCount(Pager *, unsigned int *);
1643916469
SQLITE_PRIVATE int sqlite3PagerWalReadFrame(Pager *, unsigned int, void *, unsigned int);
1644016470
SQLITE_PRIVATE int sqlite3PagerWalBeginCommit(Pager*);
1644116471
SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager*);
16442-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int);
16472+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int, int *);
1644316473

1644416474
SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
1644516475
SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);
@@ -65337,9 +65367,12 @@ SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager *pPager) {
6533765367
return rc;
6533865368
}
6533965369

65340-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf) {
65370+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf, int *pConflict) {
6534165371
int rc = SQLITE_OK;
6534265372

65373+
if( pConflict ) {
65374+
*pConflict = 0;
65375+
}
6534365376
if (!pagerUseWal(pPager)) {
6534465377
return SQLITE_ERROR;
6534565378
}
@@ -65349,6 +65382,22 @@ SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, voi
6534965382
return rc;
6535065383
}
6535165384
if (iFrame <= mxFrame) {
65385+
unsigned long frame_len = nBuf-24;
65386+
unsigned char current[frame_len];
65387+
rc = pPager->wal->methods.xReadFrame(pPager->wal->pData, iFrame, frame_len, current);
65388+
if (rc != SQLITE_OK) {
65389+
return rc;
65390+
}
65391+
int conflict = 0;
65392+
if (memcmp(pBuf+24, current, frame_len) != 0) {
65393+
conflict = 1;
65394+
}
65395+
if (pConflict) {
65396+
*pConflict = conflict;
65397+
}
65398+
if (conflict) {
65399+
return SQLITE_ERROR;
65400+
}
6535265401
return SQLITE_OK;
6535365402
}
6535465403
u8 *aFrame = (u8*)pBuf;
@@ -183315,7 +183364,8 @@ int libsql_wal_insert_frame(
183315183364
sqlite3* db,
183316183365
unsigned int iFrame,
183317183366
void *pBuf,
183318-
unsigned int nBuf
183367+
unsigned int nBuf,
183368+
int *pConflict
183319183369
){
183320183370
int rc = SQLITE_OK;
183321183371
Pager *pPager;
@@ -183330,7 +183380,7 @@ int libsql_wal_insert_frame(
183330183380

183331183381
sqlite3_mutex_enter(db->mutex);
183332183382
pPager = sqlite3BtreePager(db->aDb[0].pBt);
183333-
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf);
183383+
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf, pConflict);
183334183384
if (rc != SQLITE_OK) {
183335183385
goto out_unlock;
183336183386
}

libsql-ffi/bundled/bindings/bindgen.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ extern "C" {
940940
extern "C" {
941941
pub fn sqlite3_vmprintf(
942942
arg1: *const ::std::os::raw::c_char,
943-
arg2: *mut __va_list_tag,
943+
arg2: va_list,
944944
) -> *mut ::std::os::raw::c_char;
945945
}
946946
extern "C" {
@@ -956,7 +956,7 @@ extern "C" {
956956
arg1: ::std::os::raw::c_int,
957957
arg2: *mut ::std::os::raw::c_char,
958958
arg3: *const ::std::os::raw::c_char,
959-
arg4: *mut __va_list_tag,
959+
arg4: va_list,
960960
) -> *mut ::std::os::raw::c_char;
961961
}
962962
extern "C" {
@@ -2503,7 +2503,7 @@ extern "C" {
25032503
pub fn sqlite3_str_vappendf(
25042504
arg1: *mut sqlite3_str,
25052505
zFormat: *const ::std::os::raw::c_char,
2506-
arg2: *mut __va_list_tag,
2506+
arg2: va_list,
25072507
);
25082508
}
25092509
extern "C" {
@@ -2892,6 +2892,7 @@ extern "C" {
28922892
arg2: ::std::os::raw::c_uint,
28932893
arg3: *mut ::std::os::raw::c_void,
28942894
arg4: ::std::os::raw::c_uint,
2895+
arg5: *mut ::std::os::raw::c_int,
28952896
) -> ::std::os::raw::c_int;
28962897
}
28972898
extern "C" {
@@ -3570,12 +3571,4 @@ extern "C" {
35703571
extern "C" {
35713572
pub static sqlite3_wal_manager: libsql_wal_manager;
35723573
}
3573-
pub type __builtin_va_list = [__va_list_tag; 1usize];
3574-
#[repr(C)]
3575-
#[derive(Debug, Copy, Clone)]
3576-
pub struct __va_list_tag {
3577-
pub gp_offset: ::std::os::raw::c_uint,
3578-
pub fp_offset: ::std::os::raw::c_uint,
3579-
pub overflow_arg_area: *mut ::std::os::raw::c_void,
3580-
pub reg_save_area: *mut ::std::os::raw::c_void,
3581-
}
3574+
pub type __builtin_va_list = *mut ::std::os::raw::c_char;

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
@@ -10989,7 +11019,7 @@ SQLITE_API int libsql_wal_insert_end(sqlite3*);
1098911019
** CAPI3REF: Insert a frame into the WAL
1099011020
** METHOD: sqlite3
1099111021
*/
10992-
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int);
11022+
SQLITE_API int libsql_wal_insert_frame(sqlite3*, unsigned int, void *, unsigned int, int *);
1099311023

1099411024
/*
1099511025
** CAPI3REF: Low-level system error code
@@ -16439,7 +16469,7 @@ SQLITE_PRIVATE int sqlite3PagerWalFrameCount(Pager *, unsigned int *);
1643916469
SQLITE_PRIVATE int sqlite3PagerWalReadFrame(Pager *, unsigned int, void *, unsigned int);
1644016470
SQLITE_PRIVATE int sqlite3PagerWalBeginCommit(Pager*);
1644116471
SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager*);
16442-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int);
16472+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager*, unsigned int, void *, unsigned int, int *);
1644316473

1644416474
SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
1644516475
SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);
@@ -65337,9 +65367,12 @@ SQLITE_PRIVATE int sqlite3PagerWalEndCommit(Pager *pPager) {
6533765367
return rc;
6533865368
}
6533965369

65340-
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf) {
65370+
SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, void *pBuf, unsigned int nBuf, int *pConflict) {
6534165371
int rc = SQLITE_OK;
6534265372

65373+
if( pConflict ) {
65374+
*pConflict = 0;
65375+
}
6534365376
if (!pagerUseWal(pPager)) {
6534465377
return SQLITE_ERROR;
6534565378
}
@@ -65349,6 +65382,22 @@ SQLITE_PRIVATE int sqlite3PagerWalInsert(Pager *pPager, unsigned int iFrame, voi
6534965382
return rc;
6535065383
}
6535165384
if (iFrame <= mxFrame) {
65385+
unsigned long frame_len = nBuf-24;
65386+
unsigned char current[frame_len];
65387+
rc = pPager->wal->methods.xReadFrame(pPager->wal->pData, iFrame, frame_len, current);
65388+
if (rc != SQLITE_OK) {
65389+
return rc;
65390+
}
65391+
int conflict = 0;
65392+
if (memcmp(pBuf+24, current, frame_len) != 0) {
65393+
conflict = 1;
65394+
}
65395+
if (pConflict) {
65396+
*pConflict = conflict;
65397+
}
65398+
if (conflict) {
65399+
return SQLITE_ERROR;
65400+
}
6535265401
return SQLITE_OK;
6535365402
}
6535465403
u8 *aFrame = (u8*)pBuf;
@@ -183315,7 +183364,8 @@ int libsql_wal_insert_frame(
183315183364
sqlite3* db,
183316183365
unsigned int iFrame,
183317183366
void *pBuf,
183318-
unsigned int nBuf
183367+
unsigned int nBuf,
183368+
int *pConflict
183319183369
){
183320183370
int rc = SQLITE_OK;
183321183371
Pager *pPager;
@@ -183330,7 +183380,7 @@ int libsql_wal_insert_frame(
183330183380

183331183381
sqlite3_mutex_enter(db->mutex);
183332183382
pPager = sqlite3BtreePager(db->aDb[0].pBt);
183333-
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf);
183383+
rc = sqlite3PagerWalInsert(pPager, iFrame, pBuf, nBuf, pConflict);
183334183384
if (rc != SQLITE_OK) {
183335183385
goto out_unlock;
183336183386
}

libsql-ffi/bundled/src/sqlite3.h

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

1060510605
/*
1060610606
** CAPI3REF: Low-level system error code

0 commit comments

Comments
 (0)