From 05e87b8d8d6ba3e891be1db914df52715980ffc3 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 9 Feb 2020 11:47:01 +0100 Subject: [PATCH 1/3] Add missing constants --- libsqlite3-sys/src/error.rs | 32 ++++++++++++++++++++++++++++++++ src/config.rs | 6 ++++++ src/lib.rs | 1 + 3 files changed, 39 insertions(+) diff --git a/libsqlite3-sys/src/error.rs b/libsqlite3-sys/src/error.rs index f289af2..38186a7 100644 --- a/libsqlite3-sys/src/error.rs +++ b/libsqlite3-sys/src/error.rs @@ -125,6 +125,10 @@ const SQLITE_WARNING: c_int = 28; // Extended result codes. +const SQLITE_ERROR_MISSING_COLLSEQ: c_int = (super::SQLITE_ERROR | (1 << 8)); +const SQLITE_ERROR_RETRY: c_int = (super::SQLITE_ERROR | (2 << 8)); +const SQLITE_ERROR_SNAPSHOT: c_int = (super::SQLITE_ERROR | (3 << 8)); + const SQLITE_IOERR_SHMOPEN: c_int = (super::SQLITE_IOERR | (18 << 8)); const SQLITE_IOERR_SHMSIZE: c_int = (super::SQLITE_IOERR | (19 << 8)); const SQLITE_IOERR_SHMLOCK: c_int = (super::SQLITE_IOERR | (20 << 8)); @@ -139,23 +143,31 @@ const SQLITE_IOERR_AUTH: c_int = (super::SQLITE_IOERR | (28 << 8)); const SQLITE_IOERR_BEGIN_ATOMIC: c_int = (super::SQLITE_IOERR | (29 << 8)); const SQLITE_IOERR_COMMIT_ATOMIC: c_int = (super::SQLITE_IOERR | (30 << 8)); const SQLITE_IOERR_ROLLBACK_ATOMIC: c_int = (super::SQLITE_IOERR | (31 << 8)); + const SQLITE_LOCKED_SHAREDCACHE: c_int = (super::SQLITE_LOCKED | (1 << 8)); const SQLITE_LOCKED_VTAB: c_int = (super::SQLITE_LOCKED | (2 << 8)); + const SQLITE_BUSY_RECOVERY: c_int = (super::SQLITE_BUSY | (1 << 8)); const SQLITE_BUSY_SNAPSHOT: c_int = (super::SQLITE_BUSY | (2 << 8)); + const SQLITE_CANTOPEN_NOTEMPDIR: c_int = (super::SQLITE_CANTOPEN | (1 << 8)); const SQLITE_CANTOPEN_ISDIR: c_int = (super::SQLITE_CANTOPEN | (2 << 8)); const SQLITE_CANTOPEN_FULLPATH: c_int = (super::SQLITE_CANTOPEN | (3 << 8)); const SQLITE_CANTOPEN_CONVPATH: c_int = (super::SQLITE_CANTOPEN | (4 << 8)); +const SQLITE_CANTOPEN_SYMLINK: c_int = (super::SQLITE_CANTOPEN | (6 << 8)); + const SQLITE_CORRUPT_VTAB: c_int = (super::SQLITE_CORRUPT | (1 << 8)); const SQLITE_CORRUPT_SEQUENCE: c_int = (super::SQLITE_CORRUPT | (2 << 8)); + const SQLITE_READONLY_RECOVERY: c_int = (super::SQLITE_READONLY | (1 << 8)); const SQLITE_READONLY_CANTLOCK: c_int = (super::SQLITE_READONLY | (2 << 8)); const SQLITE_READONLY_ROLLBACK: c_int = (super::SQLITE_READONLY | (3 << 8)); const SQLITE_READONLY_DBMOVED: c_int = (super::SQLITE_READONLY | (4 << 8)); const SQLITE_READONLY_CANTINIT: c_int = (super::SQLITE_READONLY | (5 << 8)); const SQLITE_READONLY_DIRECTORY: c_int = (super::SQLITE_READONLY | (6 << 8)); + const SQLITE_ABORT_ROLLBACK: c_int = (super::SQLITE_ABORT | (2 << 8)); + const SQLITE_CONSTRAINT_CHECK: c_int = (super::SQLITE_CONSTRAINT | (1 << 8)); const SQLITE_CONSTRAINT_COMMITHOOK: c_int = (super::SQLITE_CONSTRAINT | (2 << 8)); const SQLITE_CONSTRAINT_FOREIGNKEY: c_int = (super::SQLITE_CONSTRAINT | (3 << 8)); @@ -166,9 +178,13 @@ const SQLITE_CONSTRAINT_TRIGGER: c_int = (super::SQLITE_CONSTRAINT | (7 << 8)); const SQLITE_CONSTRAINT_UNIQUE: c_int = (super::SQLITE_CONSTRAINT | (8 << 8)); const SQLITE_CONSTRAINT_VTAB: c_int = (super::SQLITE_CONSTRAINT | (9 << 8)); const SQLITE_CONSTRAINT_ROWID: c_int = (super::SQLITE_CONSTRAINT | (10 << 8)); +const SQLITE_CONSTRAINT_PINNED: c_int = (super::SQLITE_CONSTRAINT | (11 << 8)); + const SQLITE_NOTICE_RECOVER_WAL: c_int = (SQLITE_NOTICE | (1 << 8)); const SQLITE_NOTICE_RECOVER_ROLLBACK: c_int = (SQLITE_NOTICE | (2 << 8)); + const SQLITE_WARNING_AUTOINDEX: c_int = (SQLITE_WARNING | (1 << 8)); + const SQLITE_AUTH_USER: c_int = (super::SQLITE_AUTH | (1 << 8)); pub fn code_to_str(code: c_int) -> &'static str { @@ -205,6 +221,10 @@ pub fn code_to_str(code: c_int) -> &'static str { super::SQLITE_ROW => "sqlite3_step() has another row ready", super::SQLITE_DONE => "sqlite3_step() has finished executing", + SQLITE_ERROR_MISSING_COLLSEQ => "SQLITE_ERROR_MISSING_COLLSEQ", + SQLITE_ERROR_RETRY => "SQLITE_ERROR_RETRY", + SQLITE_ERROR_SNAPSHOT => "SQLITE_ERROR_SNAPSHOT", + super::SQLITE_IOERR_READ => "Error reading from disk", super::SQLITE_IOERR_SHORT_READ => "Unable to obtain number of requested bytes (file truncated?)", super::SQLITE_IOERR_WRITE => "Error writing to disk", @@ -236,23 +256,31 @@ pub fn code_to_str(code: c_int) -> &'static str { SQLITE_IOERR_BEGIN_ATOMIC => "SQLITE_IOERR_BEGIN_ATOMIC", SQLITE_IOERR_COMMIT_ATOMIC => "SQLITE_IOERR_COMMIT_ATOMIC", SQLITE_IOERR_ROLLBACK_ATOMIC => "SQLITE_IOERR_ROLLBACK_ATOMIC", + SQLITE_LOCKED_SHAREDCACHE => "Locking conflict due to another connection with a shared cache", SQLITE_LOCKED_VTAB => "SQLITE_LOCKED_VTAB", + SQLITE_BUSY_RECOVERY => "Another process is recovering a WAL mode database file", SQLITE_BUSY_SNAPSHOT => "Cannot promote read transaction to write transaction because of writes by another connection", + SQLITE_CANTOPEN_NOTEMPDIR => "SQLITE_CANTOPEN_NOTEMPDIR", // no longer used SQLITE_CANTOPEN_ISDIR => "Attempted to open directory as file", SQLITE_CANTOPEN_FULLPATH => "Unable to convert filename into full pathname", SQLITE_CANTOPEN_CONVPATH => "cygwin_conv_path() system call failed", + SQLITE_CANTOPEN_SYMLINK => "SQLITE_CANTOPEN_SYMLINK", + SQLITE_CORRUPT_VTAB => "Content in the virtual table is corrupt", SQLITE_CORRUPT_SEQUENCE => "SQLITE_CORRUPT_SEQUENCE", + SQLITE_READONLY_RECOVERY => "WAL mode database file needs recovery (requires write access)", SQLITE_READONLY_CANTLOCK => "Shared-memory file associated with WAL mode database is read-only", SQLITE_READONLY_ROLLBACK => "Database has hot journal that must be rolled back (requires write access)", SQLITE_READONLY_DBMOVED => "Database cannot be modified because database file has moved", SQLITE_READONLY_CANTINIT => "SQLITE_READONLY_CANTINIT", SQLITE_READONLY_DIRECTORY => "SQLITE_READONLY_DIRECTORY", + SQLITE_ABORT_ROLLBACK => "Transaction was rolled back", + SQLITE_CONSTRAINT_CHECK => "A CHECK constraint failed", SQLITE_CONSTRAINT_COMMITHOOK => "Commit hook caused rollback", SQLITE_CONSTRAINT_FOREIGNKEY => "Foreign key constraint failed", @@ -263,9 +291,13 @@ pub fn code_to_str(code: c_int) -> &'static str { SQLITE_CONSTRAINT_UNIQUE => "A UNIQUE constraint failed", SQLITE_CONSTRAINT_VTAB => "An application-defined virtual table error occurred", SQLITE_CONSTRAINT_ROWID => "A non-unique rowid occurred", + SQLITE_CONSTRAINT_PINNED => "SQLITE_CONSTRAINT_PINNED", + SQLITE_NOTICE_RECOVER_WAL => "A WAL mode database file was recovered", SQLITE_NOTICE_RECOVER_ROLLBACK => "Hot journal was rolled back", + SQLITE_WARNING_AUTOINDEX => "Automatic indexing used - database might benefit from additional indexes", + SQLITE_AUTH_USER => "SQLITE_AUTH_USER", // not documented? _ => "Unknown error code", diff --git a/src/config.rs b/src/config.rs index 8e216e2..a11aa3b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,6 +28,12 @@ pub enum DbConfig { SQLITE_DBCONFIG_DQS_DML = 1013, // 3.29.0 #[cfg(feature = "modern_sqlite")] SQLITE_DBCONFIG_DQS_DDL = 1014, // 3.29.0 + #[cfg(feature = "modern_sqlite")] + SQLITE_DBCONFIG_ENABLE_VIEW = 1015, // 3.30.0 + #[cfg(feature = "modern_sqlite")] + SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016, // 3.31.0 + #[cfg(feature = "modern_sqlite")] + SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017, // 3.31.0 } impl Connection { diff --git a/src/lib.rs b/src/lib.rs index 20db262..e3b8bce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -778,6 +778,7 @@ bitflags::bitflags! { const SQLITE_OPEN_FULL_MUTEX = ffi::SQLITE_OPEN_FULLMUTEX; const SQLITE_OPEN_SHARED_CACHE = 0x0002_0000; const SQLITE_OPEN_PRIVATE_CACHE = 0x0004_0000; + const SQLITE_OPEN_NOFOLLOW = 0x0100_0000; } } From 922228f6045ff0c67cf30286b4f9c882e8c9fc4e Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 9 Feb 2020 11:48:08 +0100 Subject: [PATCH 2/3] Fix clippy warnings --- src/busy.rs | 1 - src/lib.rs | 1 - src/types/mod.rs | 2 -- src/types/serde_json.rs | 1 - src/types/time.rs | 3 --- src/vtab/csvtab.rs | 1 - 6 files changed, 9 deletions(-) diff --git a/src/busy.rs b/src/busy.rs index 76f6abe..223df78 100644 --- a/src/busy.rs +++ b/src/busy.rs @@ -81,7 +81,6 @@ mod test { use std::sync::mpsc::sync_channel; use std::thread; use std::time::Duration; - use tempfile; use crate::{Connection, Error, ErrorCode, Result, TransactionBehavior, NO_PARAMS}; diff --git a/src/lib.rs b/src/lib.rs index e3b8bce..775110e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -870,7 +870,6 @@ mod test { use fallible_iterator::FallibleIterator; use std::error::Error as StdError; use std::fmt; - use tempfile; // this function is never called, but is still type checked; in // particular, calls with specific instantiations will require diff --git a/src/types/mod.rs b/src/types/mod.rs index 93214cc..d79ff82 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -105,8 +105,6 @@ impl fmt::Display for Type { #[cfg(test)] mod test { - use time; - use super::Value; use crate::{Connection, Error, NO_PARAMS}; use std::f64::EPSILON; diff --git a/src/types/serde_json.rs b/src/types/serde_json.rs index a221b67..abaecda 100644 --- a/src/types/serde_json.rs +++ b/src/types/serde_json.rs @@ -28,7 +28,6 @@ impl FromSql for Value { mod test { use crate::types::ToSql; use crate::{Connection, NO_PARAMS}; - use serde_json; fn checked_memory_handle() -> Connection { let db = Connection::open_in_memory().unwrap(); diff --git a/src/types/time.rs b/src/types/time.rs index 62075c7..097b22a 100644 --- a/src/types/time.rs +++ b/src/types/time.rs @@ -1,5 +1,3 @@ -use time; - use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use crate::Result; @@ -37,7 +35,6 @@ impl FromSql for time::Timespec { #[cfg(test)] mod test { use crate::{Connection, Result, NO_PARAMS}; - use time; fn checked_memory_handle() -> Connection { let db = Connection::open_in_memory().unwrap(); diff --git a/src/vtab/csvtab.rs b/src/vtab/csvtab.rs index 8c3edd7..cb6aeac 100644 --- a/src/vtab/csvtab.rs +++ b/src/vtab/csvtab.rs @@ -1,7 +1,6 @@ //! CSV Virtual Table. //! //! Port of [csv](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/csv.c) C extension. -use csv; use std::fs::File; use std::os::raw::c_int; use std::path::Path; From 953906aab9b7912106c7a8849c7422d49de2d783 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 9 Feb 2020 11:48:45 +0100 Subject: [PATCH 3/3] Rustfmt --- src/vtab/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index d589ba2..908c5f5 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -254,14 +254,14 @@ pub enum IndexConstraintOp { SQLITE_INDEX_CONSTRAINT_LT, SQLITE_INDEX_CONSTRAINT_GE, SQLITE_INDEX_CONSTRAINT_MATCH, - SQLITE_INDEX_CONSTRAINT_LIKE, // 3.10.0 - SQLITE_INDEX_CONSTRAINT_GLOB, // 3.10.0 - SQLITE_INDEX_CONSTRAINT_REGEXP, // 3.10.0 - SQLITE_INDEX_CONSTRAINT_NE, // 3.21.0 - SQLITE_INDEX_CONSTRAINT_ISNOT, // 3.21.0 - SQLITE_INDEX_CONSTRAINT_ISNOTNULL, // 3.21.0 - SQLITE_INDEX_CONSTRAINT_ISNULL, // 3.21.0 - SQLITE_INDEX_CONSTRAINT_IS, // 3.21.0 + SQLITE_INDEX_CONSTRAINT_LIKE, // 3.10.0 + SQLITE_INDEX_CONSTRAINT_GLOB, // 3.10.0 + SQLITE_INDEX_CONSTRAINT_REGEXP, // 3.10.0 + SQLITE_INDEX_CONSTRAINT_NE, // 3.21.0 + SQLITE_INDEX_CONSTRAINT_ISNOT, // 3.21.0 + SQLITE_INDEX_CONSTRAINT_ISNOTNULL, // 3.21.0 + SQLITE_INDEX_CONSTRAINT_ISNULL, // 3.21.0 + SQLITE_INDEX_CONSTRAINT_IS, // 3.21.0 SQLITE_INDEX_CONSTRAINT_FUNCTION(u8), // 3.25.0 }