Merge remote-tracking branch 'upstream/master' into modern_vtab

# Conflicts:
#	src/vtab/mod.rs
This commit is contained in:
gwenn 2022-09-02 20:33:21 +02:00
commit 79b6fd6e61
19 changed files with 3048 additions and 8275 deletions

View File

@ -35,16 +35,16 @@ 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 = []
# sqlite3_blob_reopen: 3.7.4 # sqlite3_blob_reopen: 3.7.4
blob = ["libsqlite3-sys/min_sqlite_version_3_7_7"] blob = []
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 = []
# 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 = []
# 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 = []
bundled = ["libsqlite3-sys/bundled", "modern_sqlite"] bundled = ["libsqlite3-sys/bundled", "modern_sqlite"]
bundled-sqlcipher = ["libsqlite3-sys/bundled-sqlcipher", "bundled"] bundled-sqlcipher = ["libsqlite3-sys/bundled-sqlcipher", "bundled"]
bundled-sqlcipher-vendored-openssl = ["libsqlite3-sys/bundled-sqlcipher-vendored-openssl", "bundled-sqlcipher"] bundled-sqlcipher-vendored-openssl = ["libsqlite3-sys/bundled-sqlcipher-vendored-openssl", "bundled-sqlcipher"]
@ -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 = []
csvtab = ["csv", "vtab"] csvtab = ["csv", "vtab"]
# pointer passing interfaces: 3.20.0 # pointer passing interfaces: 3.20.0
array = ["vtab"] array = ["vtab"]
@ -67,6 +67,7 @@ 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"]
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"]

View File

@ -81,7 +81,7 @@ fn main() -> Result<()> {
### Supported SQLite Versions ### 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 support for older versions, please file an issue. Some cargo features require a
newer SQLite version; see details below. newer SQLite version; see details below.
@ -191,9 +191,7 @@ 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_14_0` - SQLite 3.14.0 bindings (this is the default)
* `min_sqlite_version_3_6_23` - SQLite 3.6.23 bindings
* `min_sqlite_version_3_7_7` - SQLite 3.7.7 bindings
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

View File

@ -12,17 +12,14 @@ 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"]
bundled-sqlcipher-vendored-openssl = ["bundled-sqlcipher", "openssl-sys/vendored"] 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_14_0 = ["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"]
# 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 = []
@ -41,7 +38,7 @@ wasm32-wasi-vfs = []
# Note that because `winsqlite3.dll` exports SQLite functions using a atypical # Note that because `winsqlite3.dll` exports SQLite functions using a atypical
# ABI on 32-bit systems, this is currently unsupported on these. This may change # ABI on 32-bit systems, this is currently unsupported on these. This may change
# in the future. # in the future.
winsqlite3 = ["min_sqlite_version_3_7_16"] winsqlite3 = []
[dependencies] [dependencies]
openssl-sys = { version = "0.9", optional = true } openssl-sys = { version = "0.9", optional = true }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -473,15 +473,7 @@ mod bindings {
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
static PREBUILT_BINDGEN_PATHS: &[&str] = &[ static PREBUILT_BINDGEN_PATHS: &[&str] = &["bindgen-bindings/bindgen_3.14.0.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")]
"bindgen-bindings/bindgen_3.7.16.rs",
];
pub fn write_to_out_dir(_header: HeaderLocation, out_path: &Path) { pub fn write_to_out_dir(_header: HeaderLocation, out_path: &Path) {
let in_path = PREBUILT_BINDGEN_PATHS[PREBUILT_BINDGEN_PATHS.len() - 1]; let in_path = PREBUILT_BINDGEN_PATHS[PREBUILT_BINDGEN_PATHS.len() - 1];

View File

@ -408,13 +408,13 @@ pub unsafe fn error_from_handle(db: *mut ffi::sqlite3, code: c_int) -> Error {
} }
#[cold] #[cold]
#[cfg(not(all(feature = "modern_sqlite", not(feature = "bundled-sqlcipher"))))] // SQLite >= 3.38.0 #[cfg(not(feature = "modern_sqlite"))] // SQLite >= 3.38.0
pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, _sql: &str) -> Error { pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, _sql: &str) -> Error {
error_from_handle(db, code) error_from_handle(db, code)
} }
#[cold] #[cold]
#[cfg(all(feature = "modern_sqlite", not(feature = "bundled-sqlcipher")))] // SQLite >= 3.38.0 #[cfg(feature = "modern_sqlite")] // SQLite >= 3.38.0
pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, sql: &str) -> Error { pub unsafe fn error_with_offset(db: *mut ffi::sqlite3, code: c_int, sql: &str) -> Error {
if db.is_null() { if db.is_null() {
error_from_sqlite_code(code, None) error_from_sqlite_code(code, None)

View File

@ -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. // 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")]
fn constraint_error_code() -> i32 { fn constraint_error_code() -> i32 {
ffi::SQLITE_CONSTRAINT_FUNCTION ffi::SQLITE_CONSTRAINT_FUNCTION
} }
#[cfg(not(feature = "modern_sqlite"))]
fn constraint_error_code() -> i32 {
ffi::SQLITE_CONSTRAINT
}
if let Error::SqliteFailure(ref err, ref s) = *err { if let Error::SqliteFailure(ref err, ref s) = *err {
ffi::sqlite3_result_error_code(ctx, err.extended_code); 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 /// 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_attr(docsrs, doc(cfg(feature = "modern_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 +242,6 @@ impl Context<'_> {
} }
/// Set the Subtype of an SQL function /// Set the Subtype of an SQL function
#[cfg(feature = "modern_sqlite")] // 3.9.0
#[cfg_attr(docsrs, doc(cfg(feature = "modern_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) };
} }

View File

@ -181,7 +181,6 @@ pub enum AuthAction<'c> {
operation: TransactionOperation, operation: TransactionOperation,
savepoint_name: &'c str, savepoint_name: &'c str,
}, },
#[cfg(feature = "modern_sqlite")]
Recursive, Recursive,
} }
@ -285,7 +284,6 @@ 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
(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 },
} }

View File

@ -295,7 +295,6 @@ 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
pub fn is_busy(&self) -> bool { pub fn is_busy(&self) -> bool {
let db = self.db(); let db = self.db();
unsafe { unsafe {
@ -310,7 +309,6 @@ impl InnerConnection {
false false
} }
#[cfg(feature = "modern_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 +317,6 @@ impl InnerConnection {
#[inline] #[inline]
fn remove_hooks(&mut self) {} fn remove_hooks(&mut self) {}
#[cfg(feature = "modern_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()) };

View File

@ -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 // Currently DatabaseName is only used by the backup and blob mods, so hide
// this (private) impl to avoid dead code warnings. // this (private) impl to avoid dead code warnings.
#[cfg(any(
feature = "backup",
feature = "blob",
feature = "session",
feature = "modern_sqlite"
))]
impl DatabaseName<'_> { impl DatabaseName<'_> {
#[inline] #[inline]
fn as_cstring(&self) -> Result<SmallCString> { fn as_cstring(&self) -> Result<SmallCString> {
@ -961,22 +955,16 @@ 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_attr(docsrs, doc(cfg(feature = "modern_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_attr(docsrs, doc(cfg(feature = "modern_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_attr(docsrs, doc(cfg(feature = "modern_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 +1164,6 @@ impl InterruptHandle {
} }
} }
#[cfg(feature = "modern_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,10 +1173,6 @@ 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"))]
unsafe fn db_filename(_: *mut ffi::sqlite3) -> Option<PathBuf> {
None
}
#[cfg(doctest)] #[cfg(doctest)]
doc_comment::doctest!("../README.md"); doc_comment::doctest!("../README.md");
@ -1664,7 +1647,6 @@ mod test {
} }
#[test] #[test]
#[cfg(feature = "modern_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,12 +1677,9 @@ 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")]
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"))]
fn check_extended_code(_extended_code: c_int) {}
let db = Connection::open_in_memory()?; let db = Connection::open_in_memory()?;
db.execute_batch("CREATE TABLE foo(x NOT NULL)")?; db.execute_batch("CREATE TABLE foo(x NOT NULL)")?;
@ -2109,14 +2088,12 @@ mod test {
} }
#[test] #[test]
#[cfg(feature = "modern_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")]
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)?);

View File

@ -1,7 +1,6 @@
use super::ffi; use super::ffi;
use super::StatementStatus; use super::StatementStatus;
use crate::util::ParamIndexCache; use crate::util::ParamIndexCache;
#[cfg(feature = "modern_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;
@ -196,14 +195,13 @@ impl RawStatement {
} }
// does not work for PRAGMA // does not work for PRAGMA
#[cfg(feature = "extra_check")]
#[inline] #[inline]
#[cfg(all(feature = "extra_check", feature = "modern_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
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)) }
} }

View File

@ -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(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,16 +806,6 @@ impl Statement<'_> {
Ok(()) Ok(())
} }
#[cfg(all(not(feature = "modern_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"))] #[cfg(not(feature = "extra_check"))]
#[inline] #[inline]
#[allow(clippy::unnecessary_wraps)] #[allow(clippy::unnecessary_wraps)]
@ -825,8 +815,6 @@ 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_attr(docsrs, doc(cfg(feature = "modern_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 +1395,6 @@ mod test {
} }
#[test] #[test]
#[cfg(feature = "modern_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 +1524,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()?;

View File

@ -5,7 +5,5 @@ 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"))]
mod sqlite_string; mod sqlite_string;
#[cfg(any(feature = "modern_sqlite", feature = "vtab"))]
pub(crate) use sqlite_string::SqliteMallocString; pub(crate) use sqlite_string::SqliteMallocString;

View File

@ -1,10 +1,7 @@
// This is used when either vtab or modern-sqlite is on. Different methods are // 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 // 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(feature = "vtab"), allow(dead_code))]
not(all(feature = "vtab", feature = "modern-sqlite")),
allow(dead_code)
)]
use crate::ffi; use crate::ffi;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::os::raw::{c_char, c_int}; use std::os::raw::{c_char, c_int};

View File

@ -187,7 +187,6 @@ 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(any(feature = "modern_sqlite", feature = "buildtime_bindgen"))] // 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 +202,6 @@ 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(any(feature = "modern_sqlite", feature = "buildtime_bindgen"))] // 3.7.7
#[cfg_attr(docsrs, doc(cfg(feature = "modern_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 +366,6 @@ impl From<u8> for IndexConstraintOp {
} }
} }
#[cfg(any(feature = "modern_sqlite", feature = "buildtime_bindgen"))] // 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 +470,6 @@ impl IndexInfo {
} }
/// Estimated number of rows returned. /// Estimated number of rows returned.
#[cfg(any(feature = "modern_sqlite", feature = "buildtime_bindgen"))] // SQLite >= 3.8.2
#[cfg_attr(docsrs, doc(cfg(feature = "modern_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 +478,12 @@ impl IndexInfo {
} }
/// Mask of SQLITE_INDEX_SCAN_* flags. /// Mask of SQLITE_INDEX_SCAN_* flags.
#[cfg(any(feature = "modern_sqlite", feature = "buildtime_bindgen"))] // SQLite >= 3.9.0
#[cfg_attr(docsrs, doc(cfg(feature = "modern_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(any(feature = "modern_sqlite", feature = "buildtime_bindgen"))] // SQLite >= 3.10.0
#[cfg_attr(docsrs, doc(cfg(feature = "modern_sqlite")))]
#[inline] #[inline]
pub fn col_used(&self) -> u64 { pub fn col_used(&self) -> u64 {
unsafe { (*self.0).colUsed } unsafe { (*self.0).colUsed }