mirror of
https://github.com/isar/rusqlite.git
synced 2025-01-19 22:10:50 +08:00
Change default minimal SQLite API version
From 3.6.8 to 3.14.0. Use `old_sqlite` feature to keep 3.6.8 (or 3.7.16) as the minimal version. Use `modern_sqlite` for SQLite API > 3.14.0. Also remove old 3.6.23 and 3.7.7 bindings.
This commit is contained in:
parent
5ea4c3b7d6
commit
6e740d0611
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -170,6 +170,8 @@ jobs:
|
|||||||
- run: cargo clippy --all-targets --workspace --features bundled -- -D warnings
|
- run: cargo clippy --all-targets --workspace --features bundled -- -D warnings
|
||||||
# Clippy with all non-conflicting features
|
# Clippy with all non-conflicting features
|
||||||
- run: cargo clippy --all-targets --workspace --features 'bundled-full session buildtime_bindgen' -- -D warnings
|
- 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.
|
# Ensure patch is formatted.
|
||||||
fmt:
|
fmt:
|
||||||
|
13
Cargo.toml
13
Cargo.toml
@ -35,14 +35,14 @@ members = ["libsqlite3-sys"]
|
|||||||
[features]
|
[features]
|
||||||
load_extension = []
|
load_extension = []
|
||||||
# hot-backup interface: 3.6.11 (2009-02-18)
|
# hot-backup interface: 3.6.11 (2009-02-18)
|
||||||
backup = ["libsqlite3-sys/min_sqlite_version_3_6_23"]
|
backup = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
||||||
# sqlite3_blob_reopen: 3.7.4
|
# sqlite3_blob_reopen: 3.7.4
|
||||||
blob = ["libsqlite3-sys/min_sqlite_version_3_7_7"]
|
blob = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
||||||
collation = []
|
collation = []
|
||||||
# sqlite3_create_function_v2: 3.7.3 (2010-10-08)
|
# sqlite3_create_function_v2: 3.7.3 (2010-10-08)
|
||||||
functions = ["libsqlite3-sys/min_sqlite_version_3_7_7"]
|
functions = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
||||||
# sqlite3_log: 3.6.23 (2010-03-09)
|
# sqlite3_log: 3.6.23 (2010-03-09)
|
||||||
trace = ["libsqlite3-sys/min_sqlite_version_3_6_23"]
|
trace = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
||||||
# sqlite3_db_release_memory: 3.7.10 (2012-01-16)
|
# sqlite3_db_release_memory: 3.7.10 (2012-01-16)
|
||||||
release_memory = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
release_memory = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
||||||
bundled = ["libsqlite3-sys/bundled", "modern_sqlite"]
|
bundled = ["libsqlite3-sys/bundled", "modern_sqlite"]
|
||||||
@ -55,7 +55,7 @@ i128_blob = []
|
|||||||
sqlcipher = ["libsqlite3-sys/sqlcipher"]
|
sqlcipher = ["libsqlite3-sys/sqlcipher"]
|
||||||
unlock_notify = ["libsqlite3-sys/unlock_notify"]
|
unlock_notify = ["libsqlite3-sys/unlock_notify"]
|
||||||
# xSavepoint, xRelease and xRollbackTo: 3.7.7 (2011-06-23)
|
# xSavepoint, xRelease and xRollbackTo: 3.7.7 (2011-06-23)
|
||||||
vtab = ["libsqlite3-sys/min_sqlite_version_3_7_7"]
|
vtab = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
||||||
csvtab = ["csv", "vtab"]
|
csvtab = ["csv", "vtab"]
|
||||||
# pointer passing interfaces: 3.20.0
|
# pointer passing interfaces: 3.20.0
|
||||||
array = ["vtab"]
|
array = ["vtab"]
|
||||||
@ -67,7 +67,10 @@ window = ["functions"]
|
|||||||
series = ["vtab"]
|
series = ["vtab"]
|
||||||
# check for invalid query.
|
# check for invalid query.
|
||||||
extra_check = []
|
extra_check = []
|
||||||
|
# ]3.14.0, last]
|
||||||
modern_sqlite = ["libsqlite3-sys/bundled_bindings"]
|
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"]
|
in_gecko = ["modern_sqlite", "libsqlite3-sys/in_gecko"]
|
||||||
bundled-windows = ["libsqlite3-sys/bundled-windows"]
|
bundled-windows = ["libsqlite3-sys/bundled-windows"]
|
||||||
# Build bundled sqlite with -fsanitize=address
|
# Build bundled sqlite with -fsanitize=address
|
||||||
|
@ -191,9 +191,9 @@ minimum SQLite version that supports your chosen features. If you are using
|
|||||||
`libsqlite3-sys` directly, you can use the same features to choose which
|
`libsqlite3-sys` directly, you can use the same features to choose which
|
||||||
pregenerated bindings are chosen:
|
pregenerated bindings are chosen:
|
||||||
|
|
||||||
* `min_sqlite_version_3_6_8` - SQLite 3.6.8 bindings (this is the default)
|
* `min_sqlite_version_3_6_8` - SQLite 3.6.8 bindings
|
||||||
* `min_sqlite_version_3_6_23` - SQLite 3.6.23 bindings
|
* `min_sqlite_version_3_7_16` - SQLite 3.7.16 bindings
|
||||||
* `min_sqlite_version_3_7_7` - SQLite 3.7.7 bindings
|
* `min_sqlite_version_3_14_0` - SQLite 3.14.0 bindings (this is the default)
|
||||||
|
|
||||||
If you use any of the `bundled` features, you will get pregenerated bindings for the
|
If you use any of the `bundled` features, you will get pregenerated bindings for the
|
||||||
bundled version of SQLite/SQLCipher. If you need other specific pregenerated binding
|
bundled version of SQLite/SQLCipher. If you need other specific pregenerated binding
|
||||||
|
@ -12,7 +12,7 @@ keywords = ["sqlite", "sqlcipher", "ffi"]
|
|||||||
categories = ["external-ffi-bindings"]
|
categories = ["external-ffi-bindings"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["min_sqlite_version_3_6_8"]
|
default = ["min_sqlite_version_3_14_0"]
|
||||||
bundled = ["cc", "bundled_bindings"]
|
bundled = ["cc", "bundled_bindings"]
|
||||||
bundled-windows = ["cc", "bundled_bindings"]
|
bundled-windows = ["cc", "bundled_bindings"]
|
||||||
bundled-sqlcipher = ["bundled"]
|
bundled-sqlcipher = ["bundled"]
|
||||||
@ -20,9 +20,8 @@ bundled-sqlcipher-vendored-openssl = ["bundled-sqlcipher", "openssl-sys/vendored
|
|||||||
buildtime_bindgen = ["bindgen", "pkg-config", "vcpkg"]
|
buildtime_bindgen = ["bindgen", "pkg-config", "vcpkg"]
|
||||||
sqlcipher = []
|
sqlcipher = []
|
||||||
min_sqlite_version_3_6_8 = ["pkg-config", "vcpkg"]
|
min_sqlite_version_3_6_8 = ["pkg-config", "vcpkg"]
|
||||||
min_sqlite_version_3_6_23 = ["pkg-config", "vcpkg"]
|
|
||||||
min_sqlite_version_3_7_7 = ["pkg-config", "vcpkg"]
|
|
||||||
min_sqlite_version_3_7_16 = ["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
|
# Bundle only the bindings file. Note that this does nothing if
|
||||||
# `buildtime_bindgen` is enabled.
|
# `buildtime_bindgen` is enabled.
|
||||||
bundled_bindings = []
|
bundled_bindings = []
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -474,13 +474,18 @@ mod bindings {
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
static PREBUILT_BINDGEN_PATHS: &[&str] = &[
|
static PREBUILT_BINDGEN_PATHS: &[&str] = &[
|
||||||
|
#[cfg(feature = "min_sqlite_version_3_6_8")]
|
||||||
"bindgen-bindings/bindgen_3.6.8.rs",
|
"bindgen-bindings/bindgen_3.6.8.rs",
|
||||||
#[cfg(feature = "min_sqlite_version_3_6_23")]
|
|
||||||
"bindgen-bindings/bindgen_3.6.23.rs",
|
|
||||||
#[cfg(feature = "min_sqlite_version_3_7_7")]
|
|
||||||
"bindgen-bindings/bindgen_3.7.7.rs",
|
|
||||||
#[cfg(feature = "min_sqlite_version_3_7_16")]
|
#[cfg(feature = "min_sqlite_version_3_7_16")]
|
||||||
"bindgen-bindings/bindgen_3.7.16.rs",
|
"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"
|
||||||
|
))
|
||||||
|
))]
|
||||||
|
"bindgen-bindings/bindgen_3.14.0.rs",
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn write_to_out_dir(_header: HeaderLocation, out_path: &Path) {
|
pub fn write_to_out_dir(_header: HeaderLocation, out_path: &Path) {
|
||||||
|
@ -75,11 +75,11 @@ unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
|||||||
// an explicit feature check for that, and this doesn't really warrant one.
|
// 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
|
// 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.
|
// at least 3.17.0) and the normal constraint error code if not.
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
fn constraint_error_code() -> i32 {
|
fn constraint_error_code() -> i32 {
|
||||||
ffi::SQLITE_CONSTRAINT_FUNCTION
|
ffi::SQLITE_CONSTRAINT_FUNCTION
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "modern_sqlite"))]
|
#[cfg(feature = "old_sqlite")]
|
||||||
fn constraint_error_code() -> i32 {
|
fn constraint_error_code() -> i32 {
|
||||||
ffi::SQLITE_CONSTRAINT
|
ffi::SQLITE_CONSTRAINT
|
||||||
}
|
}
|
||||||
@ -168,8 +168,8 @@ impl Context<'_> {
|
|||||||
///
|
///
|
||||||
/// Will panic if `idx` is greater than or equal to
|
/// Will panic if `idx` is greater than or equal to
|
||||||
/// [`self.len()`](Context::len).
|
/// [`self.len()`](Context::len).
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.9.0
|
#[cfg(not(feature = "old_sqlite"))] // 3.9.0
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
pub fn get_subtype(&self, idx: usize) -> std::os::raw::c_uint {
|
pub fn get_subtype(&self, idx: usize) -> std::os::raw::c_uint {
|
||||||
let arg = self.args[idx];
|
let arg = self.args[idx];
|
||||||
unsafe { ffi::sqlite3_value_subtype(arg) }
|
unsafe { ffi::sqlite3_value_subtype(arg) }
|
||||||
@ -249,8 +249,8 @@ impl Context<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set the Subtype of an SQL function
|
/// Set the Subtype of an SQL function
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.9.0
|
#[cfg(not(feature = "old_sqlite"))] // 3.9.0
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
pub fn set_result_subtype(&self, sub_type: std::os::raw::c_uint) {
|
pub fn set_result_subtype(&self, sub_type: std::os::raw::c_uint) {
|
||||||
unsafe { ffi::sqlite3_result_subtype(self.ctx, sub_type) };
|
unsafe { ffi::sqlite3_result_subtype(self.ctx, sub_type) };
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ pub enum AuthAction<'c> {
|
|||||||
operation: TransactionOperation,
|
operation: TransactionOperation,
|
||||||
savepoint_name: &'c str,
|
savepoint_name: &'c str,
|
||||||
},
|
},
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
Recursive,
|
Recursive,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ impl<'c> AuthAction<'c> {
|
|||||||
operation: TransactionOperation::from_str(operation_str),
|
operation: TransactionOperation::from_str(operation_str),
|
||||||
savepoint_name,
|
savepoint_name,
|
||||||
},
|
},
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.8.3
|
#[cfg(not(feature = "old_sqlite"))] // 3.8.3
|
||||||
(ffi::SQLITE_RECURSIVE, ..) => Self::Recursive,
|
(ffi::SQLITE_RECURSIVE, ..) => Self::Recursive,
|
||||||
(code, arg1, arg2) => Self::Unknown { code, arg1, arg2 },
|
(code, arg1, arg2) => Self::Unknown { code, arg1, arg2 },
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ impl InnerConnection {
|
|||||||
unsafe { ffi::sqlite3_get_autocommit(self.db()) != 0 }
|
unsafe { ffi::sqlite3_get_autocommit(self.db()) != 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.8.6
|
#[cfg(not(feature = "old_sqlite"))] // 3.8.6
|
||||||
pub fn is_busy(&self) -> bool {
|
pub fn is_busy(&self) -> bool {
|
||||||
let db = self.db();
|
let db = self.db();
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -310,7 +310,7 @@ impl InnerConnection {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.10.0
|
#[cfg(not(feature = "old_sqlite"))] // 3.10.0
|
||||||
pub fn cache_flush(&mut self) -> Result<()> {
|
pub fn cache_flush(&mut self) -> Result<()> {
|
||||||
crate::error::check(unsafe { ffi::sqlite3_db_cacheflush(self.db()) })
|
crate::error::check(unsafe { ffi::sqlite3_db_cacheflush(self.db()) })
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ impl InnerConnection {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn remove_hooks(&mut self) {}
|
fn remove_hooks(&mut self) {}
|
||||||
|
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.7.11
|
#[cfg(not(feature = "old_sqlite"))] // 3.7.11
|
||||||
pub fn db_readonly(&self, db_name: super::DatabaseName<'_>) -> Result<bool> {
|
pub fn db_readonly(&self, db_name: super::DatabaseName<'_>) -> Result<bool> {
|
||||||
let name = db_name.as_cstring()?;
|
let name = db_name.as_cstring()?;
|
||||||
let r = unsafe { ffi::sqlite3_db_readonly(self.db, name.as_ptr()) };
|
let r = unsafe { ffi::sqlite3_db_readonly(self.db, name.as_ptr()) };
|
||||||
|
28
src/lib.rs
28
src/lib.rs
@ -318,7 +318,7 @@ pub const TEMP_DB: DatabaseName<'static> = DatabaseName::Temp;
|
|||||||
feature = "backup",
|
feature = "backup",
|
||||||
feature = "blob",
|
feature = "blob",
|
||||||
feature = "session",
|
feature = "session",
|
||||||
feature = "modern_sqlite"
|
not(feature = "old_sqlite")
|
||||||
))]
|
))]
|
||||||
impl DatabaseName<'_> {
|
impl DatabaseName<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -961,22 +961,22 @@ impl Connection {
|
|||||||
|
|
||||||
/// Determine if all associated prepared statements have been reset.
|
/// Determine if all associated prepared statements have been reset.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.8.6
|
#[cfg(not(feature = "old_sqlite"))] // 3.8.6
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
pub fn is_busy(&self) -> bool {
|
pub fn is_busy(&self) -> bool {
|
||||||
self.db.borrow().is_busy()
|
self.db.borrow().is_busy()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flush caches to disk mid-transaction
|
/// Flush caches to disk mid-transaction
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.10.0
|
#[cfg(not(feature = "old_sqlite"))] // 3.10.0
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
pub fn cache_flush(&self) -> Result<()> {
|
pub fn cache_flush(&self) -> Result<()> {
|
||||||
self.db.borrow_mut().cache_flush()
|
self.db.borrow_mut().cache_flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine if a database is read-only
|
/// Determine if a database is read-only
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.7.11
|
#[cfg(not(feature = "old_sqlite"))] // 3.7.11
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
pub fn is_readonly(&self, db_name: DatabaseName<'_>) -> Result<bool> {
|
pub fn is_readonly(&self, db_name: DatabaseName<'_>) -> Result<bool> {
|
||||||
self.db.borrow().db_readonly(db_name)
|
self.db.borrow().db_readonly(db_name)
|
||||||
}
|
}
|
||||||
@ -1176,7 +1176,7 @@ impl InterruptHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.7.10
|
#[cfg(not(feature = "old_sqlite"))] // 3.7.10
|
||||||
unsafe fn db_filename(db: *mut ffi::sqlite3) -> Option<PathBuf> {
|
unsafe fn db_filename(db: *mut ffi::sqlite3) -> Option<PathBuf> {
|
||||||
let db_name = DatabaseName::Main.as_cstring().unwrap();
|
let db_name = DatabaseName::Main.as_cstring().unwrap();
|
||||||
let db_filename = ffi::sqlite3_db_filename(db, db_name.as_ptr());
|
let db_filename = ffi::sqlite3_db_filename(db, db_name.as_ptr());
|
||||||
@ -1186,7 +1186,7 @@ unsafe fn db_filename(db: *mut ffi::sqlite3) -> Option<PathBuf> {
|
|||||||
CStr::from_ptr(db_filename).to_str().ok().map(PathBuf::from)
|
CStr::from_ptr(db_filename).to_str().ok().map(PathBuf::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "modern_sqlite"))]
|
#[cfg(feature = "old_sqlite")]
|
||||||
unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option<PathBuf> {
|
unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option<PathBuf> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -1664,7 +1664,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
fn test_is_busy() -> Result<()> {
|
fn test_is_busy() -> Result<()> {
|
||||||
let db = Connection::open_in_memory()?;
|
let db = Connection::open_in_memory()?;
|
||||||
assert!(!db.is_busy());
|
assert!(!db.is_busy());
|
||||||
@ -1695,11 +1695,11 @@ mod test {
|
|||||||
fn test_notnull_constraint_error() -> Result<()> {
|
fn test_notnull_constraint_error() -> Result<()> {
|
||||||
// extended error codes for constraints were added in SQLite 3.7.16; if we're
|
// 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.
|
// running on our bundled version, we know the extended error code exists.
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
fn check_extended_code(extended_code: c_int) {
|
fn check_extended_code(extended_code: c_int) {
|
||||||
assert_eq!(extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL);
|
assert_eq!(extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL);
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "modern_sqlite"))]
|
#[cfg(feature = "old_sqlite")]
|
||||||
fn check_extended_code(_extended_code: c_int) {}
|
fn check_extended_code(_extended_code: c_int) {}
|
||||||
|
|
||||||
let db = Connection::open_in_memory()?;
|
let db = Connection::open_in_memory()?;
|
||||||
@ -2109,14 +2109,14 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
fn test_cache_flush() -> Result<()> {
|
fn test_cache_flush() -> Result<()> {
|
||||||
let db = Connection::open_in_memory()?;
|
let db = Connection::open_in_memory()?;
|
||||||
db.cache_flush()
|
db.cache_flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
pub fn db_readonly() -> Result<()> {
|
pub fn db_readonly() -> Result<()> {
|
||||||
let db = Connection::open_in_memory()?;
|
let db = Connection::open_in_memory()?;
|
||||||
assert!(!db.is_readonly(MAIN_DB)?);
|
assert!(!db.is_readonly(MAIN_DB)?);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::ffi;
|
use super::ffi;
|
||||||
use super::StatementStatus;
|
use super::StatementStatus;
|
||||||
use crate::util::ParamIndexCache;
|
use crate::util::ParamIndexCache;
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
use crate::util::SqliteMallocString;
|
use crate::util::SqliteMallocString;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
@ -197,13 +197,13 @@ impl RawStatement {
|
|||||||
|
|
||||||
// does not work for PRAGMA
|
// does not work for PRAGMA
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(all(feature = "extra_check", feature = "modern_sqlite"))] // 3.7.4
|
#[cfg(all(feature = "extra_check", not(feature = "old_sqlite")))] // 3.7.4
|
||||||
pub fn readonly(&self) -> bool {
|
pub fn readonly(&self) -> bool {
|
||||||
unsafe { ffi::sqlite3_stmt_readonly(self.ptr) != 0 }
|
unsafe { ffi::sqlite3_stmt_readonly(self.ptr) != 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.14.0
|
#[cfg(not(feature = "old_sqlite"))] // 3.14.0
|
||||||
pub(crate) fn expanded_sql(&self) -> Option<SqliteMallocString> {
|
pub(crate) fn expanded_sql(&self) -> Option<SqliteMallocString> {
|
||||||
unsafe { SqliteMallocString::from_raw(ffi::sqlite3_expanded_sql(self.ptr)) }
|
unsafe { SqliteMallocString::from_raw(ffi::sqlite3_expanded_sql(self.ptr)) }
|
||||||
}
|
}
|
||||||
|
@ -796,7 +796,7 @@ impl Statement<'_> {
|
|||||||
self.conn.decode_result(stmt.finalize())
|
self.conn.decode_result(stmt.finalize())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "modern_sqlite", feature = "extra_check"))]
|
#[cfg(all(not(feature = "old_sqlite"), feature = "extra_check"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn check_update(&self) -> Result<()> {
|
fn check_update(&self) -> Result<()> {
|
||||||
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
||||||
@ -806,7 +806,7 @@ impl Statement<'_> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(not(feature = "modern_sqlite"), feature = "extra_check"))]
|
#[cfg(all(feature = "old_sqlite", feature = "extra_check"))]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn check_update(&self) -> Result<()> {
|
fn check_update(&self) -> Result<()> {
|
||||||
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
// sqlite3_column_count works for DML but not for DDL (ie ALTER)
|
||||||
@ -825,8 +825,8 @@ impl Statement<'_> {
|
|||||||
|
|
||||||
/// Returns a string containing the SQL text of prepared statement with
|
/// Returns a string containing the SQL text of prepared statement with
|
||||||
/// bound parameters expanded.
|
/// bound parameters expanded.
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
pub fn expanded_sql(&self) -> Option<String> {
|
pub fn expanded_sql(&self) -> Option<String> {
|
||||||
self.stmt
|
self.stmt
|
||||||
.expanded_sql()
|
.expanded_sql()
|
||||||
@ -1407,7 +1407,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "modern_sqlite")]
|
#[cfg(not(feature = "old_sqlite"))]
|
||||||
fn test_expanded_sql() -> Result<()> {
|
fn test_expanded_sql() -> Result<()> {
|
||||||
let db = Connection::open_in_memory()?;
|
let db = Connection::open_in_memory()?;
|
||||||
let stmt = db.prepare("SELECT ?")?;
|
let stmt = db.prepare("SELECT ?")?;
|
||||||
@ -1537,7 +1537,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(feature = "modern_sqlite", not(feature = "bundled-sqlcipher")))] // SQLite >= 3.38.0
|
#[cfg(feature = "modern_sqlite")] // SQLite >= 3.38.0
|
||||||
fn test_error_offset() -> Result<()> {
|
fn test_error_offset() -> Result<()> {
|
||||||
use crate::ffi::ErrorCode;
|
use crate::ffi::ErrorCode;
|
||||||
let db = Connection::open_in_memory()?;
|
let db = Connection::open_in_memory()?;
|
||||||
|
@ -5,7 +5,7 @@ pub(crate) use param_cache::ParamIndexCache;
|
|||||||
pub(crate) use small_cstr::SmallCString;
|
pub(crate) use small_cstr::SmallCString;
|
||||||
|
|
||||||
// Doesn't use any modern features or vtab stuff, but is only used by them.
|
// Doesn't use any modern features or vtab stuff, but is only used by them.
|
||||||
#[cfg(any(feature = "modern_sqlite", feature = "vtab"))]
|
#[cfg(any(not(feature = "old_sqlite"), feature = "vtab"))]
|
||||||
mod sqlite_string;
|
mod sqlite_string;
|
||||||
#[cfg(any(feature = "modern_sqlite", feature = "vtab"))]
|
#[cfg(any(not(feature = "old_sqlite"), feature = "vtab"))]
|
||||||
pub(crate) use sqlite_string::SqliteMallocString;
|
pub(crate) use sqlite_string::SqliteMallocString;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// used in each feature. Avoid having to track this for each function. We will
|
// 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.
|
// still warn for anything that's not used by either, though.
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
not(all(feature = "vtab", feature = "modern-sqlite")),
|
not(all(feature = "vtab", not(feature = "old_sqlite"))),
|
||||||
allow(dead_code)
|
allow(dead_code)
|
||||||
)]
|
)]
|
||||||
use crate::ffi;
|
use crate::ffi;
|
||||||
|
@ -187,7 +187,7 @@ pub fn eponymous_only_module<'vtab, T: VTab<'vtab>>() -> &'static Module<'vtab,
|
|||||||
/// Virtual table configuration options
|
/// Virtual table configuration options
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.7.7
|
#[cfg(not(feature = "old_sqlite"))] // 3.7.7
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||||
pub enum VTabConfig {
|
pub enum VTabConfig {
|
||||||
/// Equivalent to SQLITE_VTAB_CONSTRAINT_SUPPORT
|
/// Equivalent to SQLITE_VTAB_CONSTRAINT_SUPPORT
|
||||||
@ -203,8 +203,8 @@ pub struct VTabConnection(*mut ffi::sqlite3);
|
|||||||
|
|
||||||
impl VTabConnection {
|
impl VTabConnection {
|
||||||
/// Configure various facets of the virtual table interface
|
/// Configure various facets of the virtual table interface
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.7.7
|
#[cfg(not(feature = "old_sqlite"))] // 3.7.7
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
pub fn config(&mut self, config: VTabConfig) -> Result<()> {
|
pub fn config(&mut self, config: VTabConfig) -> Result<()> {
|
||||||
crate::error::check(unsafe { ffi::sqlite3_vtab_config(self.0, config as c_int) })
|
crate::error::check(unsafe { ffi::sqlite3_vtab_config(self.0, config as c_int) })
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ impl From<u8> for IndexConstraintOp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "modern_sqlite")] // 3.9.0
|
#[cfg(not(feature = "old_sqlite"))] // 3.9.0
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
/// Virtual table scan flags
|
/// Virtual table scan flags
|
||||||
/// See [Function Flags](https://sqlite.org/c3ref/c_index_scan_unique.html) for details.
|
/// See [Function Flags](https://sqlite.org/c3ref/c_index_scan_unique.html) for details.
|
||||||
@ -474,8 +474,8 @@ impl IndexInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Estimated number of rows returned.
|
/// Estimated number of rows returned.
|
||||||
#[cfg(feature = "modern_sqlite")] // SQLite >= 3.8.2
|
#[cfg(not(feature = "old_sqlite"))] // SQLite >= 3.8.2
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_estimated_rows(&mut self, estimated_rows: i64) {
|
pub fn set_estimated_rows(&mut self, estimated_rows: i64) {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -484,16 +484,16 @@ impl IndexInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Mask of SQLITE_INDEX_SCAN_* flags.
|
/// Mask of SQLITE_INDEX_SCAN_* flags.
|
||||||
#[cfg(feature = "modern_sqlite")] // SQLite >= 3.9.0
|
#[cfg(not(feature = "old_sqlite"))] // SQLite >= 3.9.0
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_idx_flags(&mut self, flags: IndexFlags) {
|
pub fn set_idx_flags(&mut self, flags: IndexFlags) {
|
||||||
unsafe { (*self.0).idxFlags = flags.bits() };
|
unsafe { (*self.0).idxFlags = flags.bits() };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mask of columns used by statement
|
/// Mask of columns used by statement
|
||||||
#[cfg(feature = "modern_sqlite")] // SQLite >= 3.10.0
|
#[cfg(not(feature = "old_sqlite"))] // SQLite >= 3.10.0
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
|
#[cfg_attr(docsrs, doc(cfg(not(feature = "old_sqlite"))))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn col_used(&self) -> u64 {
|
pub fn col_used(&self) -> u64 {
|
||||||
unsafe { (*self.0).colUsed }
|
unsafe { (*self.0).colUsed }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user