mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-24 18:01:37 +08:00
Merge pull request #1223 from gwenn/const
Reuse constants already defined in SQLite <= 3.14.0
This commit is contained in:
commit
ff1b3d5ed4
@ -122,77 +122,32 @@ impl error::Error for Error {
|
||||
// so we don't have to worry about which version of SQLite added which
|
||||
// constants, and we only use them to implement code_to_str below.
|
||||
|
||||
const SQLITE_NOTICE: c_int = 27;
|
||||
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);
|
||||
const SQLITE_IOERR_SHMMAP: c_int = super::SQLITE_IOERR | (21 << 8);
|
||||
const SQLITE_IOERR_SEEK: c_int = super::SQLITE_IOERR | (22 << 8);
|
||||
const SQLITE_IOERR_DELETE_NOENT: c_int = super::SQLITE_IOERR | (23 << 8);
|
||||
const SQLITE_IOERR_MMAP: c_int = super::SQLITE_IOERR | (24 << 8);
|
||||
const SQLITE_IOERR_GETTEMPPATH: c_int = super::SQLITE_IOERR | (25 << 8);
|
||||
const SQLITE_IOERR_CONVPATH: c_int = super::SQLITE_IOERR | (26 << 8);
|
||||
const SQLITE_IOERR_VNODE: c_int = super::SQLITE_IOERR | (27 << 8);
|
||||
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_IOERR_DATA: c_int = super::SQLITE_IOERR | (32 << 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_BUSY_TIMEOUT: c_int = super::SQLITE_BUSY | (3 << 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_CORRUPT_INDEX: c_int = super::SQLITE_CORRUPT | (3 << 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);
|
||||
const SQLITE_CONSTRAINT_FUNCTION: c_int = super::SQLITE_CONSTRAINT | (4 << 8);
|
||||
const SQLITE_CONSTRAINT_NOTNULL: c_int = super::SQLITE_CONSTRAINT | (5 << 8);
|
||||
const SQLITE_CONSTRAINT_PRIMARYKEY: c_int = super::SQLITE_CONSTRAINT | (6 << 8);
|
||||
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_CONSTRAINT_DATATYPE: c_int = super::SQLITE_CONSTRAINT | (12 << 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);
|
||||
|
||||
#[must_use]
|
||||
pub fn code_to_str(code: c_int) -> &'static str {
|
||||
match code {
|
||||
@ -223,8 +178,8 @@ pub fn code_to_str(code: c_int) -> &'static str {
|
||||
super::SQLITE_FORMAT => "Auxiliary database format error",
|
||||
super::SQLITE_RANGE => "2nd parameter to sqlite3_bind out of range",
|
||||
super::SQLITE_NOTADB => "File opened that is not a database file",
|
||||
SQLITE_NOTICE => "Notifications from sqlite3_log()",
|
||||
SQLITE_WARNING => "Warnings from sqlite3_log()",
|
||||
super::SQLITE_NOTICE => "Notifications from sqlite3_log()",
|
||||
super::SQLITE_WARNING => "Warnings from sqlite3_log()",
|
||||
super::SQLITE_ROW => "sqlite3_step() has another row ready",
|
||||
super::SQLITE_DONE => "sqlite3_step() has finished executing",
|
||||
|
||||
@ -249,67 +204,67 @@ pub fn code_to_str(code: c_int) -> &'static str {
|
||||
super::SQLITE_IOERR_LOCK => "I/O error in the advisory file locking layer",
|
||||
super::SQLITE_IOERR_CLOSE => "I/O error within the xClose method",
|
||||
super::SQLITE_IOERR_DIR_CLOSE => "SQLITE_IOERR_DIR_CLOSE", // no longer used
|
||||
SQLITE_IOERR_SHMOPEN => "I/O error within the xShmMap method (trying to open a new shared-memory segment)",
|
||||
SQLITE_IOERR_SHMSIZE => "I/O error within the xShmMap method (trying to resize an existing shared-memory segment)",
|
||||
SQLITE_IOERR_SHMLOCK => "SQLITE_IOERR_SHMLOCK", // no longer used
|
||||
SQLITE_IOERR_SHMMAP => "I/O error within the xShmMap method (trying to map a shared-memory segment into process address space)",
|
||||
SQLITE_IOERR_SEEK => "I/O error within the xRead or xWrite (trying to seek within a file)",
|
||||
SQLITE_IOERR_DELETE_NOENT => "File being deleted does not exist",
|
||||
SQLITE_IOERR_MMAP => "I/O error while trying to map or unmap part of the database file into process address space",
|
||||
SQLITE_IOERR_GETTEMPPATH => "VFS is unable to determine a suitable directory for temporary files",
|
||||
SQLITE_IOERR_CONVPATH => "cygwin_conv_path() system call failed",
|
||||
SQLITE_IOERR_VNODE => "SQLITE_IOERR_VNODE", // not documented?
|
||||
SQLITE_IOERR_AUTH => "SQLITE_IOERR_AUTH",
|
||||
super::SQLITE_IOERR_SHMOPEN => "I/O error within the xShmMap method (trying to open a new shared-memory segment)",
|
||||
super::SQLITE_IOERR_SHMSIZE => "I/O error within the xShmMap method (trying to resize an existing shared-memory segment)",
|
||||
super::SQLITE_IOERR_SHMLOCK => "SQLITE_IOERR_SHMLOCK", // no longer used
|
||||
super::SQLITE_IOERR_SHMMAP => "I/O error within the xShmMap method (trying to map a shared-memory segment into process address space)",
|
||||
super::SQLITE_IOERR_SEEK => "I/O error within the xRead or xWrite (trying to seek within a file)",
|
||||
super::SQLITE_IOERR_DELETE_NOENT => "File being deleted does not exist",
|
||||
super::SQLITE_IOERR_MMAP => "I/O error while trying to map or unmap part of the database file into process address space",
|
||||
super::SQLITE_IOERR_GETTEMPPATH => "VFS is unable to determine a suitable directory for temporary files",
|
||||
super::SQLITE_IOERR_CONVPATH => "cygwin_conv_path() system call failed",
|
||||
super::SQLITE_IOERR_VNODE => "SQLITE_IOERR_VNODE", // not documented?
|
||||
super::SQLITE_IOERR_AUTH => "SQLITE_IOERR_AUTH",
|
||||
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_IOERR_DATA => "SQLITE_IOERR_DATA",
|
||||
|
||||
SQLITE_LOCKED_SHAREDCACHE => "Locking conflict due to another connection with a shared cache",
|
||||
super::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",
|
||||
super::SQLITE_BUSY_RECOVERY => "Another process is recovering a WAL mode database file",
|
||||
super::SQLITE_BUSY_SNAPSHOT => "Cannot promote read transaction to write transaction because of writes by another connection",
|
||||
SQLITE_BUSY_TIMEOUT => "SQLITE_BUSY_TIMEOUT",
|
||||
|
||||
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",
|
||||
super::SQLITE_CANTOPEN_NOTEMPDIR => "SQLITE_CANTOPEN_NOTEMPDIR", // no longer used
|
||||
super::SQLITE_CANTOPEN_ISDIR => "Attempted to open directory as file",
|
||||
super::SQLITE_CANTOPEN_FULLPATH => "Unable to convert filename into full pathname",
|
||||
super::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",
|
||||
super::SQLITE_CORRUPT_VTAB => "Content in the virtual table is corrupt",
|
||||
SQLITE_CORRUPT_SEQUENCE => "SQLITE_CORRUPT_SEQUENCE",
|
||||
SQLITE_CORRUPT_INDEX => "SQLITE_CORRUPT_INDEX",
|
||||
|
||||
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",
|
||||
super::SQLITE_READONLY_RECOVERY => "WAL mode database file needs recovery (requires write access)",
|
||||
super::SQLITE_READONLY_CANTLOCK => "Shared-memory file associated with WAL mode database is read-only",
|
||||
super::SQLITE_READONLY_ROLLBACK => "Database has hot journal that must be rolled back (requires write access)",
|
||||
super::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",
|
||||
super::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",
|
||||
SQLITE_CONSTRAINT_FUNCTION => "Error returned from extension function",
|
||||
SQLITE_CONSTRAINT_NOTNULL => "A NOT NULL constraint failed",
|
||||
SQLITE_CONSTRAINT_PRIMARYKEY => "A PRIMARY KEY constraint failed",
|
||||
SQLITE_CONSTRAINT_TRIGGER => "A RAISE function within a trigger fired",
|
||||
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",
|
||||
super::SQLITE_CONSTRAINT_CHECK => "A CHECK constraint failed",
|
||||
super::SQLITE_CONSTRAINT_COMMITHOOK => "Commit hook caused rollback",
|
||||
super::SQLITE_CONSTRAINT_FOREIGNKEY => "Foreign key constraint failed",
|
||||
super::SQLITE_CONSTRAINT_FUNCTION => "Error returned from extension function",
|
||||
super::SQLITE_CONSTRAINT_NOTNULL => "A NOT NULL constraint failed",
|
||||
super::SQLITE_CONSTRAINT_PRIMARYKEY => "A PRIMARY KEY constraint failed",
|
||||
super::SQLITE_CONSTRAINT_TRIGGER => "A RAISE function within a trigger fired",
|
||||
super::SQLITE_CONSTRAINT_UNIQUE => "A UNIQUE constraint failed",
|
||||
super::SQLITE_CONSTRAINT_VTAB => "An application-defined virtual table error occurred",
|
||||
super::SQLITE_CONSTRAINT_ROWID => "A non-unique rowid occurred",
|
||||
SQLITE_CONSTRAINT_PINNED => "SQLITE_CONSTRAINT_PINNED",
|
||||
SQLITE_CONSTRAINT_DATATYPE => "SQLITE_CONSTRAINT_DATATYPE",
|
||||
|
||||
SQLITE_NOTICE_RECOVER_WAL => "A WAL mode database file was recovered",
|
||||
SQLITE_NOTICE_RECOVER_ROLLBACK => "Hot journal was rolled back",
|
||||
super::SQLITE_NOTICE_RECOVER_WAL => "A WAL mode database file was recovered",
|
||||
super::SQLITE_NOTICE_RECOVER_ROLLBACK => "Hot journal was rolled back",
|
||||
|
||||
SQLITE_WARNING_AUTOINDEX => "Automatic indexing used - database might benefit from additional indexes",
|
||||
super::SQLITE_WARNING_AUTOINDEX => "Automatic indexing used - database might benefit from additional indexes",
|
||||
|
||||
SQLITE_AUTH_USER => "SQLITE_AUTH_USER", // not documented?
|
||||
super::SQLITE_AUTH_USER => "SQLITE_AUTH_USER", // not documented?
|
||||
|
||||
_ => "Unknown error code",
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ pub enum DbConfig {
|
||||
//SQLITE_DBCONFIG_MAINDBNAME = 1000, /* const char* */
|
||||
//SQLITE_DBCONFIG_LOOKASIDE = 1001, /* void* int int */
|
||||
/// Enable or disable the enforcement of foreign key constraints.
|
||||
SQLITE_DBCONFIG_ENABLE_FKEY = 1002,
|
||||
SQLITE_DBCONFIG_ENABLE_FKEY = ffi::SQLITE_DBCONFIG_ENABLE_FKEY,
|
||||
/// Enable or disable triggers.
|
||||
SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003,
|
||||
SQLITE_DBCONFIG_ENABLE_TRIGGER = ffi::SQLITE_DBCONFIG_ENABLE_TRIGGER,
|
||||
/// Enable or disable the fts3_tokenizer() function which is part of the
|
||||
/// FTS3 full-text search engine extension.
|
||||
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004, // 3.12.0
|
||||
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = ffi::SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, // 3.12.0
|
||||
//SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005,
|
||||
/// In WAL mode, enable or disable the checkpoint operation before closing
|
||||
/// the connection.
|
||||
|
@ -1058,9 +1058,9 @@ bitflags::bitflags! {
|
||||
/// The database is created if it does not already exist
|
||||
const SQLITE_OPEN_CREATE = ffi::SQLITE_OPEN_CREATE;
|
||||
/// The filename can be interpreted as a URI if this flag is set.
|
||||
const SQLITE_OPEN_URI = 0x0000_0040;
|
||||
const SQLITE_OPEN_URI = ffi::SQLITE_OPEN_URI;
|
||||
/// The database will be opened as an in-memory database.
|
||||
const SQLITE_OPEN_MEMORY = 0x0000_0080;
|
||||
const SQLITE_OPEN_MEMORY = ffi::SQLITE_OPEN_MEMORY;
|
||||
/// The new database connection will not use a per-connection mutex (the
|
||||
/// connection will use the "multi-thread" threading mode, in SQLite
|
||||
/// parlance).
|
||||
|
@ -39,10 +39,10 @@ pub enum Limit {
|
||||
/// The maximum index number of any parameter in an SQL statement.
|
||||
SQLITE_LIMIT_VARIABLE_NUMBER = ffi::SQLITE_LIMIT_VARIABLE_NUMBER,
|
||||
/// The maximum depth of recursion for triggers.
|
||||
SQLITE_LIMIT_TRIGGER_DEPTH = 10,
|
||||
SQLITE_LIMIT_TRIGGER_DEPTH = ffi::SQLITE_LIMIT_TRIGGER_DEPTH,
|
||||
/// The maximum number of auxiliary worker threads that a single prepared
|
||||
/// statement may start.
|
||||
SQLITE_LIMIT_WORKER_THREADS = 11,
|
||||
SQLITE_LIMIT_WORKER_THREADS = ffi::SQLITE_LIMIT_WORKER_THREADS,
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
|
Loading…
Reference in New Issue
Block a user