Skip to content

Commit

Permalink
libsql: sync checkpoint wip
Browse files Browse the repository at this point in the history
  • Loading branch information
penberg committed Jan 22, 2025
1 parent 6a3ea26 commit 86493c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions libsql/src/local/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,17 @@ impl Connection {
}
}

pub(crate) fn wal_checkpoint(&self, truncate: bool) -> Result<()> {
let rc = unsafe { libsql_sys::ffi::sqlite3_wal_checkpoint_v2(self.handle(), std::ptr::null(), truncate as i32, std::ptr::null_mut(), std::ptr::null_mut()) };
if rc != 0 {
return Err(crate::errors::Error::SqliteFailure(
rc as std::ffi::c_int,
format!("Failed to checkpoint WAL"),
));
}
Ok(())
}

pub(crate) fn wal_checkpoint_seq_count(&self) -> Result<u32> {
let mut ret: std::os::raw::c_uint = 0;
let rc = unsafe { libsql_sys::ffi::libsql_wal_checkpoint_seq_count(self.handle(), &mut ret) };
Expand Down
2 changes: 1 addition & 1 deletion libsql/src/local/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ impl Database {
sync_ctx.reset_durable_frame_num();
frame_no = 1;
sync_ctx.write_metadata().await?;
conn.query("PRAGMA wal_checkpoint(truncate)", crate::params::Params::None)?;
conn.wal_checkpoint(true)?;
sync_ctx.increment_local_generation();
}
}
Expand Down

0 comments on commit 86493c6

Please sign in to comment.