mirror of
https://github.com/isar/rusqlite.git
synced 2025-01-19 19:30:50 +08:00
Remove old_sqlite
feature
And associated bindgen_3.6.8.rs
This commit is contained in:
parent
15d56bcb52
commit
6766d6a6cd
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -170,8 +170,6 @@ jobs:
|
||||
- run: cargo clippy --all-targets --workspace --features bundled -- -D warnings
|
||||
# Clippy with all non-conflicting features
|
||||
- run: cargo clippy --all-targets --workspace --features 'bundled-full session buildtime_bindgen' -- -D warnings
|
||||
# Clippy with SQLite 3.6.8
|
||||
- run: cargo clippy --all-targets --workspace --no-default-features --features 'old_sqlite' -- -D warnings
|
||||
|
||||
# Ensure patch is formatted.
|
||||
fmt:
|
||||
|
@ -69,8 +69,6 @@ series = ["vtab"]
|
||||
extra_check = []
|
||||
# ]3.14.0, last]
|
||||
modern_sqlite = ["libsqlite3-sys/bundled_bindings"]
|
||||
# [3.6.8, 3.14.0[
|
||||
old_sqlite = ["libsqlite3-sys/min_sqlite_version_3_6_8"]
|
||||
in_gecko = ["modern_sqlite", "libsqlite3-sys/in_gecko"]
|
||||
bundled-windows = ["libsqlite3-sys/bundled-windows"]
|
||||
# Build bundled sqlite with -fsanitize=address
|
||||
|
@ -81,7 +81,7 @@ fn main() -> Result<()> {
|
||||
|
||||
### Supported SQLite Versions
|
||||
|
||||
The base `rusqlite` package supports SQLite version 3.6.8 or newer. If you need
|
||||
The base `rusqlite` package supports SQLite version 3.14.0 or newer. If you need
|
||||
support for older versions, please file an issue. Some cargo features require a
|
||||
newer SQLite version; see details below.
|
||||
|
||||
@ -191,7 +191,6 @@ minimum SQLite version that supports your chosen features. If you are using
|
||||
`libsqlite3-sys` directly, you can use the same features to choose which
|
||||
pregenerated bindings are chosen:
|
||||
|
||||
* `min_sqlite_version_3_6_8` - SQLite 3.6.8 bindings
|
||||
* `min_sqlite_version_3_7_16` - SQLite 3.7.16 bindings
|
||||
* `min_sqlite_version_3_14_0` - SQLite 3.14.0 bindings (this is the default)
|
||||
|
||||
|
@ -19,7 +19,6 @@ bundled-sqlcipher = ["bundled"]
|
||||
bundled-sqlcipher-vendored-openssl = ["bundled-sqlcipher", "openssl-sys/vendored"]
|
||||
buildtime_bindgen = ["bindgen", "pkg-config", "vcpkg"]
|
||||
sqlcipher = []
|
||||
min_sqlite_version_3_6_8 = ["pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_7_16 = ["pkg-config", "vcpkg"]
|
||||
min_sqlite_version_3_14_0 = ["pkg-config", "vcpkg"]
|
||||
# Bundle only the bindings file. Note that this does nothing if
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -474,16 +474,11 @@ mod bindings {
|
||||
use std::path::Path;
|
||||
|
||||
static PREBUILT_BINDGEN_PATHS: &[&str] = &[
|
||||
#[cfg(feature = "min_sqlite_version_3_6_8")]
|
||||
"bindgen-bindings/bindgen_3.6.8.rs",
|
||||
#[cfg(feature = "min_sqlite_version_3_7_16")]
|
||||
"bindgen-bindings/bindgen_3.7.16.rs",
|
||||
#[cfg(any(
|
||||
feature = "min_sqlite_version_3_14_0",
|
||||
not(any(
|
||||
feature = "min_sqlite_version_3_7_16",
|
||||
feature = "min_sqlite_version_3_6_8"
|
||||
))
|
||||
not(any(feature = "min_sqlite_version_3_7_16",))
|
||||
))]
|
||||
"bindgen-bindings/bindgen_3.14.0.rs",
|
||||
];
|
||||
|
@ -75,14 +75,9 @@ unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
||||
// an explicit feature check for that, and this doesn't really warrant one.
|
||||
// We'll use the extended code if we're on the bundled version (since it's
|
||||
// at least 3.17.0) and the normal constraint error code if not.
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
fn constraint_error_code() -> i32 {
|
||||
ffi::SQLITE_CONSTRAINT_FUNCTION
|
||||
}
|
||||
#[cfg(feature = "old_sqlite")]
|
||||
fn constraint_error_code() -> i32 {
|
||||
ffi::SQLITE_CONSTRAINT
|
||||
}
|
||||
|
||||
if let Error::SqliteFailure(ref err, ref s) = *err {
|
||||
ffi::sqlite3_result_error_code(ctx, err.extended_code);
|
||||
@ -168,8 +163,6 @@ impl Context<'_> {
|
||||
///
|
||||
/// Will panic if `idx` is greater than or equal to
|
||||
/// [`self.len()`](Context::len).
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.9.0
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
pub fn get_subtype(&self, idx: usize) -> std::os::raw::c_uint {
|
||||
let arg = self.args[idx];
|
||||
unsafe { ffi::sqlite3_value_subtype(arg) }
|
||||
@ -249,8 +242,6 @@ impl Context<'_> {
|
||||
}
|
||||
|
||||
/// Set the Subtype of an SQL function
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.9.0
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
pub fn set_result_subtype(&self, sub_type: std::os::raw::c_uint) {
|
||||
unsafe { ffi::sqlite3_result_subtype(self.ctx, sub_type) };
|
||||
}
|
||||
|
@ -181,7 +181,6 @@ pub enum AuthAction<'c> {
|
||||
operation: TransactionOperation,
|
||||
savepoint_name: &'c str,
|
||||
},
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
Recursive,
|
||||
}
|
||||
|
||||
@ -285,7 +284,6 @@ impl<'c> AuthAction<'c> {
|
||||
operation: TransactionOperation::from_str(operation_str),
|
||||
savepoint_name,
|
||||
},
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.8.3
|
||||
(ffi::SQLITE_RECURSIVE, ..) => Self::Recursive,
|
||||
(code, arg1, arg2) => Self::Unknown { code, arg1, arg2 },
|
||||
}
|
||||
|
@ -295,7 +295,6 @@ impl InnerConnection {
|
||||
unsafe { ffi::sqlite3_get_autocommit(self.db()) != 0 }
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.8.6
|
||||
pub fn is_busy(&self) -> bool {
|
||||
let db = self.db();
|
||||
unsafe {
|
||||
@ -310,7 +309,6 @@ impl InnerConnection {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.10.0
|
||||
pub fn cache_flush(&mut self) -> Result<()> {
|
||||
crate::error::check(unsafe { ffi::sqlite3_db_cacheflush(self.db()) })
|
||||
}
|
||||
@ -319,7 +317,6 @@ impl InnerConnection {
|
||||
#[inline]
|
||||
fn remove_hooks(&mut self) {}
|
||||
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.7.11
|
||||
pub fn db_readonly(&self, db_name: super::DatabaseName<'_>) -> Result<bool> {
|
||||
let name = db_name.as_cstring()?;
|
||||
let r = unsafe { ffi::sqlite3_db_readonly(self.db, name.as_ptr()) };
|
||||
|
23
src/lib.rs
23
src/lib.rs
@ -314,12 +314,6 @@ pub const TEMP_DB: DatabaseName<'static> = DatabaseName::Temp;
|
||||
|
||||
// Currently DatabaseName is only used by the backup and blob mods, so hide
|
||||
// this (private) impl to avoid dead code warnings.
|
||||
#[cfg(any(
|
||||
feature = "backup",
|
||||
feature = "blob",
|
||||
feature = "session",
|
||||
not(feature = "old_sqlite")
|
||||
))]
|
||||
impl DatabaseName<'_> {
|
||||
#[inline]
|
||||
fn as_cstring(&self) -> Result<SmallCString> {
|
||||
@ -961,22 +955,16 @@ impl Connection {
|
||||
|
||||
/// Determine if all associated prepared statements have been reset.
|
||||
#[inline]
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.8.6
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
pub fn is_busy(&self) -> bool {
|
||||
self.db.borrow().is_busy()
|
||||
}
|
||||
|
||||
/// Flush caches to disk mid-transaction
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.10.0
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
pub fn cache_flush(&self) -> Result<()> {
|
||||
self.db.borrow_mut().cache_flush()
|
||||
}
|
||||
|
||||
/// Determine if a database is read-only
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.7.11
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
pub fn is_readonly(&self, db_name: DatabaseName<'_>) -> Result<bool> {
|
||||
self.db.borrow().db_readonly(db_name)
|
||||
}
|
||||
@ -1176,7 +1164,6 @@ impl InterruptHandle {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.7.10
|
||||
unsafe fn db_filename(db: *mut ffi::sqlite3) -> Option<PathBuf> {
|
||||
let db_name = DatabaseName::Main.as_cstring().unwrap();
|
||||
let db_filename = ffi::sqlite3_db_filename(db, db_name.as_ptr());
|
||||
@ -1186,10 +1173,6 @@ unsafe fn db_filename(db: *mut ffi::sqlite3) -> Option<PathBuf> {
|
||||
CStr::from_ptr(db_filename).to_str().ok().map(PathBuf::from)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "old_sqlite")]
|
||||
unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(doctest)]
|
||||
doc_comment::doctest!("../README.md");
|
||||
@ -1664,7 +1647,6 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
fn test_is_busy() -> Result<()> {
|
||||
let db = Connection::open_in_memory()?;
|
||||
assert!(!db.is_busy());
|
||||
@ -1695,12 +1677,9 @@ mod test {
|
||||
fn test_notnull_constraint_error() -> Result<()> {
|
||||
// extended error codes for constraints were added in SQLite 3.7.16; if we're
|
||||
// running on our bundled version, we know the extended error code exists.
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
fn check_extended_code(extended_code: c_int) {
|
||||
assert_eq!(extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL);
|
||||
}
|
||||
#[cfg(feature = "old_sqlite")]
|
||||
fn check_extended_code(_extended_code: c_int) {}
|
||||
|
||||
let db = Connection::open_in_memory()?;
|
||||
db.execute_batch("CREATE TABLE foo(x NOT NULL)")?;
|
||||
@ -2109,14 +2088,12 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
fn test_cache_flush() -> Result<()> {
|
||||
let db = Connection::open_in_memory()?;
|
||||
db.cache_flush()
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
pub fn db_readonly() -> Result<()> {
|
||||
let db = Connection::open_in_memory()?;
|
||||
assert!(!db.is_readonly(MAIN_DB)?);
|
||||
|
@ -1,7 +1,6 @@
|
||||
use super::ffi;
|
||||
use super::StatementStatus;
|
||||
use crate::util::ParamIndexCache;
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
use crate::util::SqliteMallocString;
|
||||
use std::ffi::CStr;
|
||||
use std::os::raw::c_int;
|
||||
@ -196,14 +195,13 @@ impl RawStatement {
|
||||
}
|
||||
|
||||
// does not work for PRAGMA
|
||||
#[cfg(feature = "extra_check")]
|
||||
#[inline]
|
||||
#[cfg(all(feature = "extra_check", not(feature = "old_sqlite")))] // 3.7.4
|
||||
pub fn readonly(&self) -> bool {
|
||||
unsafe { ffi::sqlite3_stmt_readonly(self.ptr) != 0 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.14.0
|
||||
pub(crate) fn expanded_sql(&self) -> Option<SqliteMallocString> {
|
||||
unsafe { SqliteMallocString::from_raw(ffi::sqlite3_expanded_sql(self.ptr)) }
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ impl Statement<'_> {
|
||||
self.conn.decode_result(stmt.finalize())
|
||||
}
|
||||
|
||||
#[cfg(all(not(feature = "old_sqlite"), feature = "extra_check"))]
|
||||
#[cfg(feature = "extra_check")]
|
||||
#[inline]
|
||||
fn check_update(&self) -> Result<()> {
|
||||
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
||||
@ -806,16 +806,6 @@ impl Statement<'_> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "old_sqlite", feature = "extra_check"))]
|
||||
#[inline]
|
||||
fn check_update(&self) -> Result<()> {
|
||||
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
||||
if self.column_count() > 0 {
|
||||
return Err(Error::ExecuteReturnedResults);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "extra_check"))]
|
||||
#[inline]
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
@ -825,8 +815,6 @@ impl Statement<'_> {
|
||||
|
||||
/// Returns a string containing the SQL text of prepared statement with
|
||||
/// bound parameters expanded.
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
pub fn expanded_sql(&self) -> Option<String> {
|
||||
self.stmt
|
||||
.expanded_sql()
|
||||
@ -1407,7 +1395,6 @@ mod test {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "old_sqlite"))]
|
||||
fn test_expanded_sql() -> Result<()> {
|
||||
let db = Connection::open_in_memory()?;
|
||||
let stmt = db.prepare("SELECT ?")?;
|
||||
|
@ -5,7 +5,5 @@ pub(crate) use param_cache::ParamIndexCache;
|
||||
pub(crate) use small_cstr::SmallCString;
|
||||
|
||||
// Doesn't use any modern features or vtab stuff, but is only used by them.
|
||||
#[cfg(any(not(feature = "old_sqlite"), feature = "vtab"))]
|
||||
mod sqlite_string;
|
||||
#[cfg(any(not(feature = "old_sqlite"), feature = "vtab"))]
|
||||
pub(crate) use sqlite_string::SqliteMallocString;
|
||||
|
@ -1,10 +1,7 @@
|
||||
// This is used when either vtab or modern-sqlite is on. Different methods are
|
||||
// used in each feature. Avoid having to track this for each function. We will
|
||||
// still warn for anything that's not used by either, though.
|
||||
#![cfg_attr(
|
||||
not(all(feature = "vtab", not(feature = "old_sqlite"))),
|
||||
allow(dead_code)
|
||||
)]
|
||||
#![cfg_attr(not(feature = "vtab"), allow(dead_code))]
|
||||
use crate::ffi;
|
||||
use std::marker::PhantomData;
|
||||
use std::os::raw::{c_char, c_int};
|
||||
|
@ -187,7 +187,6 @@ pub fn eponymous_only_module<'vtab, T: VTab<'vtab>>() -> &'static Module<'vtab,
|
||||
/// Virtual table configuration options
|
||||
#[repr(i32)]
|
||||
#[non_exhaustive]
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.7.7
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
pub enum VTabConfig {
|
||||
/// Equivalent to SQLITE_VTAB_CONSTRAINT_SUPPORT
|
||||
@ -203,8 +202,6 @@ pub struct VTabConnection(*mut ffi::sqlite3);
|
||||
|
||||
impl VTabConnection {
|
||||
/// Configure various facets of the virtual table interface
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.7.7
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
pub fn config(&mut self, config: VTabConfig) -> Result<()> {
|
||||
crate::error::check(unsafe { ffi::sqlite3_vtab_config(self.0, config as c_int) })
|
||||
}
|
||||
@ -369,7 +366,6 @@ impl From<u8> for IndexConstraintOp {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "old_sqlite"))] // 3.9.0
|
||||
bitflags::bitflags! {
|
||||
/// Virtual table scan flags
|
||||
/// See [Function Flags](https://sqlite.org/c3ref/c_index_scan_unique.html) for details.
|
||||
@ -474,8 +470,6 @@ impl IndexInfo {
|
||||
}
|
||||
|
||||
/// Estimated number of rows returned.
|
||||
#[cfg(not(feature = "old_sqlite"))] // SQLite >= 3.8.2
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
#[inline]
|
||||
pub fn set_estimated_rows(&mut self, estimated_rows: i64) {
|
||||
unsafe {
|
||||
@ -484,16 +478,12 @@ impl IndexInfo {
|
||||
}
|
||||
|
||||
/// Mask of SQLITE_INDEX_SCAN_* flags.
|
||||
#[cfg(not(feature = "old_sqlite"))] // SQLite >= 3.9.0
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
#[inline]
|
||||
pub fn set_idx_flags(&mut self, flags: IndexFlags) {
|
||||
unsafe { (*self.0).idxFlags = flags.bits() };
|
||||
}
|
||||
|
||||
/// Mask of columns used by statement
|
||||
#[cfg(not(feature = "old_sqlite"))] // SQLite >= 3.10.0
|
||||
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||
#[inline]
|
||||
pub fn col_used(&self) -> u64 {
|
||||
unsafe { (*self.0).colUsed }
|
||||
|
Loading…
x
Reference in New Issue
Block a user