From d67c0e09ddfba3a74a70ab8074674ca39955405f Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Sat, 8 Jan 2022 11:23:57 -0800 Subject: [PATCH] Remove the SQLite version check --- src/inner_connection.rs | 51 ----------------------------------------- src/lib.rs | 15 ------------ 2 files changed, 66 deletions(-) diff --git a/src/inner_connection.rs b/src/inner_connection.rs index f57541d..bf2bab5 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -63,8 +63,6 @@ impl InnerConnection { flags: OpenFlags, vfs: Option<&CStr>, ) -> Result { - #[cfg(not(feature = "bundled"))] - ensure_valid_sqlite_version(); ensure_safe_sqlite_threading_mode()?; // Replicate the check for sane open flags from SQLite, because the check in @@ -326,55 +324,6 @@ impl Drop for InnerConnection { } } -#[cfg(not(feature = "bundled"))] -static SQLITE_VERSION_CHECK: std::sync::Once = std::sync::Once::new(); -#[cfg(not(feature = "bundled"))] -pub static BYPASS_VERSION_CHECK: AtomicBool = AtomicBool::new(false); - -#[cfg(not(feature = "bundled"))] -fn ensure_valid_sqlite_version() { - use crate::version::version; - - SQLITE_VERSION_CHECK.call_once(|| { - let version_number = version_number(); - - // Check our hard floor. - if version_number < 3_006_008 { - panic!("rusqlite requires SQLite 3.6.8 or newer"); - } - - // Check that the major version number for runtime and buildtime match. - let buildtime_major = ffi::SQLITE_VERSION_NUMBER / 1_000_000; - let runtime_major = version_number / 1_000_000; - if buildtime_major != runtime_major { - panic!( - "rusqlite was built against SQLite {} but is running with SQLite {}", - str::from_utf8(ffi::SQLITE_VERSION).unwrap(), - version() - ); - } - - if BYPASS_VERSION_CHECK.load(Ordering::Relaxed) { - return; - } - - // Check that the runtime version number is compatible with the version number - // we found at build-time. - if version_number < ffi::SQLITE_VERSION_NUMBER { - panic!( - "\ -rusqlite was built against SQLite {} but the runtime SQLite version is {}. To fix this, either: -* Recompile rusqlite and link against the SQLite version you are using at runtime, or -* Call rusqlite::bypass_sqlite_version_check() prior to your first connection attempt. Doing this - means you're sure everything will work correctly even though the runtime version is older than - the version we found at build time.", - str::from_utf8(ffi::SQLITE_VERSION).unwrap(), - version() - ); - } - }); -} - #[cfg(not(any(target_arch = "wasm32")))] static SQLITE_INIT: std::sync::Once = std::sync::Once::new(); diff --git a/src/lib.rs b/src/lib.rs index cbd0677..1fa7a33 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1064,21 +1064,6 @@ pub unsafe fn bypass_sqlite_initialization() { BYPASS_SQLITE_INIT.store(true, Ordering::Relaxed); } -/// rusqlite performs a one-time check that the runtime SQLite version is at -/// least as new as the version of SQLite found when rusqlite was built. -/// Bypassing this check may be dangerous; e.g., if you use features of SQLite -/// that are not present in the runtime version. -/// -/// # Safety -/// -/// If you are sure the runtime version is compatible with the -/// build-time version for your usage, you can bypass the version check by -/// calling this function before your first connection attempt. -pub unsafe fn bypass_sqlite_version_check() { - #[cfg(not(feature = "bundled"))] - inner_connection::BYPASS_VERSION_CHECK.store(true, Ordering::Relaxed); -} - /// Allows interrupting a long-running computation. pub struct InterruptHandle { db_lock: Arc>,