Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libsql-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ sqlean-extensions = [
"sqlean-extension-text",
]
libsql-disable-checkpoint-downgrade = []
libsql-checkpoint-callback-on-any-frame-written = []
libsql-checkpoint-only-full= []
4 changes: 2 additions & 2 deletions libsql-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ pub fn build_bundled(out_dir: &str, out_path: &Path) {
if cfg!(feature = "libsql-disable-checkpoint-downgrade") {
cfg.flag("-DLIBSQL_DISABLE_CHECKPOINT_DOWNGRADE=1");
}
if cfg!(feature = "libsql-checkpoint-callback-on-any-frame-written") {
cfg.flag("-DLIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN=1");
if cfg!(feature = "libsql-checkpoint-only-full") {
cfg.flag("-DLIBSQL_CHECKPOINT_ONLY_FULL=1");
}

if cfg!(feature = "bundled-sqlcipher") {
Expand Down
19 changes: 14 additions & 5 deletions libsql-ffi/bundled/bindings/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern "C" {
) -> ::std::os::raw::c_int;
}

pub const __GNUC_VA_LIST: i32 = 1;
pub const SQLITE_VERSION: &[u8; 7] = b"3.45.1\0";
pub const SQLITE_VERSION_NUMBER: i32 = 3045001;
pub const SQLITE_SOURCE_ID: &[u8; 85] =
Expand Down Expand Up @@ -501,8 +502,8 @@ pub const FTS5_TOKENIZE_DOCUMENT: i32 = 4;
pub const FTS5_TOKENIZE_AUX: i32 = 8;
pub const FTS5_TOKEN_COLOCATED: i32 = 1;
pub const WAL_SAVEPOINT_NDATA: i32 = 4;
pub type __gnuc_va_list = __builtin_va_list;
pub type va_list = __builtin_va_list;
pub type __gnuc_va_list = __builtin_va_list;
extern "C" {
pub static sqlite3_version: [::std::os::raw::c_char; 0usize];
}
Expand Down Expand Up @@ -939,7 +940,7 @@ extern "C" {
extern "C" {
pub fn sqlite3_vmprintf(
arg1: *const ::std::os::raw::c_char,
arg2: va_list,
arg2: *mut __va_list_tag,
) -> *mut ::std::os::raw::c_char;
}
extern "C" {
Expand All @@ -955,7 +956,7 @@ extern "C" {
arg1: ::std::os::raw::c_int,
arg2: *mut ::std::os::raw::c_char,
arg3: *const ::std::os::raw::c_char,
arg4: va_list,
arg4: *mut __va_list_tag,
) -> *mut ::std::os::raw::c_char;
}
extern "C" {
Expand Down Expand Up @@ -2505,7 +2506,7 @@ extern "C" {
pub fn sqlite3_str_vappendf(
arg1: *mut sqlite3_str,
zFormat: *const ::std::os::raw::c_char,
arg2: va_list,
arg2: *mut __va_list_tag,
);
}
extern "C" {
Expand Down Expand Up @@ -3573,4 +3574,12 @@ extern "C" {
extern "C" {
pub static sqlite3_wal_manager: libsql_wal_manager;
}
pub type __builtin_va_list = *mut ::std::os::raw::c_char;
pub type __builtin_va_list = [__va_list_tag; 1usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __va_list_tag {
pub gp_offset: ::std::os::raw::c_uint,
pub fp_offset: ::std::os::raw::c_uint,
pub overflow_arg_area: *mut ::std::os::raw::c_void,
pub reg_save_area: *mut ::std::os::raw::c_void,
}
17 changes: 9 additions & 8 deletions libsql-ffi/bundled/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -67613,6 +67613,15 @@ static int walCheckpoint(
}
}


#ifdef LIBSQL_CHECKPOINT_ONLY_FULL
// in case of LIBSQL_CHECKPOINT_ONLY_FULL option we want to either checkpoint whole WAL or quickly abort the checkpoint
if( mxSafeFrame!=walIndexHdr(pWal)->mxFrame ){
rc = SQLITE_BUSY;
goto walcheckpoint_out;
}
#endif

/* Allocate the iterator */
if( pInfo->nBackfill<mxSafeFrame ){
rc = walIteratorRevInit(pWal, pInfo->nBackfill, &pIter, mxSafeFrame, xCb == NULL);
Expand Down Expand Up @@ -67677,18 +67686,10 @@ static int walCheckpoint(

/* If work was actually accomplished... */
if( rc==SQLITE_OK ){
#ifdef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
if (xCb) {
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
}
#endif

if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
#ifndef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
if (xCb) {
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
}
#endif
if( rc==SQLITE_OK ){
i64 szDb = pWal->hdr.nPage*(i64)szPage;
testcase( IS_BIG_INT(szDb) );
Expand Down
17 changes: 9 additions & 8 deletions libsql-sqlite3/src/wal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,15 @@ static int walCheckpoint(
}
}


#ifdef LIBSQL_CHECKPOINT_ONLY_FULL
// in case of LIBSQL_CHECKPOINT_ONLY_FULL option we want to either checkpoint whole WAL or quickly abort the checkpoint
if( mxSafeFrame!=walIndexHdr(pWal)->mxFrame ){
rc = SQLITE_BUSY;
goto walcheckpoint_out;
}
#endif

/* Allocate the iterator */
if( pInfo->nBackfill<mxSafeFrame ){
rc = walIteratorRevInit(pWal, pInfo->nBackfill, &pIter, mxSafeFrame, xCb == NULL);
Expand Down Expand Up @@ -2130,18 +2139,10 @@ static int walCheckpoint(

/* If work was actually accomplished... */
if( rc==SQLITE_OK ){
#ifdef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
if (xCb) {
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
}
#endif

if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
#ifndef LIBSQL_CHECKPOINT_CALLBACK_ON_ANY_FRAME_WRITTEN
if (xCb) {
rc = (xCb)(pCbData, mxSafeFrame, NULL, 0, 0, 0);
}
#endif
if( rc==SQLITE_OK ){
i64 szDb = pWal->hdr.nPage*(i64)szPage;
testcase( IS_BIG_INT(szDb) );
Expand Down
Loading