From 653e64ab98b2b66e95d48c1d45bda996bc401c36 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 3 Jul 2021 16:41:55 +0200 Subject: [PATCH] Access to sqlite3_db_cacheflush via Connection Fix #984 --- src/inner_connection.rs | 6 ++++++ src/lib.rs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/inner_connection.rs b/src/inner_connection.rs index 1bd641c..47dd7ea 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -302,6 +302,12 @@ impl InnerConnection { false } + #[cfg(feature = "modern_sqlite")] // 3.10.0 + pub fn cache_flush(&mut self) -> Result<()> { + check!(unsafe { ffi::sqlite3_db_cacheflush(self.db()) }); + Ok(()) + } + #[cfg(not(feature = "hooks"))] #[inline] fn remove_hooks(&mut self) {} diff --git a/src/lib.rs b/src/lib.rs index f7f463c..e642ed0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -868,6 +868,13 @@ impl Connection { pub fn is_busy(&self) -> bool { self.db.borrow().is_busy() } + + /// Flush caches to disk mid-transaction + #[cfg(feature = "modern_sqlite")] // 3.10.0 + #[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))] + pub fn cache_flush(&self) -> Result<()> { + self.db.borrow_mut().cache_flush() + } } impl fmt::Debug for Connection {