mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 09:09:19 +08:00
Merge remote-tracking branch 'jgallagher/master' into vtab
This commit is contained in:
commit
1d684ae653
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rusqlite"
|
name = "rusqlite"
|
||||||
version = "0.10.1"
|
version = "0.11.0"
|
||||||
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
||||||
description = "Ergonomic wrapper for SQLite"
|
description = "Ergonomic wrapper for SQLite"
|
||||||
repository = "https://github.com/jgallagher/rusqlite"
|
repository = "https://github.com/jgallagher/rusqlite"
|
||||||
@ -43,7 +43,7 @@ regex = "0.2"
|
|||||||
|
|
||||||
[dependencies.libsqlite3-sys]
|
[dependencies.libsqlite3-sys]
|
||||||
path = "libsqlite3-sys"
|
path = "libsqlite3-sys"
|
||||||
version = "0.7"
|
version = "0.8"
|
||||||
|
|
||||||
[dependencies.csv]
|
[dependencies.csv]
|
||||||
version = "0.14"
|
version = "0.14"
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
# Version 0.11.0 (2017-04-06)
|
||||||
|
|
||||||
|
* Avoid publicly exporting SQLite constants multiple times from libsqlite3-sys.
|
||||||
|
* Adds `FromSql` and `ToSql` impls for `isize`. Documents why `usize` and `u64` are not included.
|
||||||
|
|
||||||
# Version 0.10.1 (2017-03-03)
|
# Version 0.10.1 (2017-03-03)
|
||||||
|
|
||||||
* Updates the `bundled` SQLite version to 3.17.0.
|
* Updates the `bundled` SQLite version to 3.17.0.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.7.1"
|
version = "0.8.0"
|
||||||
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
||||||
repository = "https://github.com/jgallagher/rusqlite"
|
repository = "https://github.com/jgallagher/rusqlite"
|
||||||
description = "Native bindings to the libsqlite3 library"
|
description = "Native bindings to the libsqlite3 library"
|
||||||
@ -20,6 +20,7 @@ min_sqlite_version_3_6_23 = ["pkg-config"]
|
|||||||
min_sqlite_version_3_7_3 = ["pkg-config"]
|
min_sqlite_version_3_7_3 = ["pkg-config"]
|
||||||
min_sqlite_version_3_7_4 = ["pkg-config"]
|
min_sqlite_version_3_7_4 = ["pkg-config"]
|
||||||
min_sqlite_version_3_7_7 = ["pkg-config"]
|
min_sqlite_version_3_7_7 = ["pkg-config"]
|
||||||
|
min_sqlite_version_3_7_16 = ["pkg-config"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
bindgen = { version = "0.21", optional = true }
|
bindgen = { version = "0.21", optional = true }
|
||||||
|
2297
libsqlite3-sys/bindgen-bindings/bindgen_3.7.16.rs
Normal file
2297
libsqlite3-sys/bindgen-bindings/bindgen_3.7.16.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -125,6 +125,9 @@ mod build {
|
|||||||
|
|
||||||
#[cfg(feature = "min_sqlite_version_3_7_7")]
|
#[cfg(feature = "min_sqlite_version_3_7_7")]
|
||||||
"bindgen-bindings/bindgen_3.7.7.rs",
|
"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) {
|
pub fn write_to_out_dir(_header: HeaderLocation) {
|
||||||
|
@ -110,95 +110,98 @@ impl error::Error for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Result codes.
|
// Result codes.
|
||||||
|
// Note: These are not public because our bindgen bindings export whichever constants are present
|
||||||
|
// in the current version of SQLite. We repeat them here 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.
|
||||||
|
|
||||||
pub const SQLITE_OK : c_int = 0;
|
const SQLITE_OK : c_int = 0;
|
||||||
pub const SQLITE_ERROR : c_int = 1;
|
const SQLITE_ERROR : c_int = 1;
|
||||||
pub const SQLITE_INTERNAL : c_int = 2;
|
const SQLITE_INTERNAL : c_int = 2;
|
||||||
pub const SQLITE_PERM : c_int = 3;
|
const SQLITE_PERM : c_int = 3;
|
||||||
pub const SQLITE_ABORT : c_int = 4;
|
const SQLITE_ABORT : c_int = 4;
|
||||||
pub const SQLITE_BUSY : c_int = 5;
|
const SQLITE_BUSY : c_int = 5;
|
||||||
pub const SQLITE_LOCKED : c_int = 6;
|
const SQLITE_LOCKED : c_int = 6;
|
||||||
pub const SQLITE_NOMEM : c_int = 7;
|
const SQLITE_NOMEM : c_int = 7;
|
||||||
pub const SQLITE_READONLY : c_int = 8;
|
const SQLITE_READONLY : c_int = 8;
|
||||||
pub const SQLITE_INTERRUPT : c_int = 9;
|
const SQLITE_INTERRUPT : c_int = 9;
|
||||||
pub const SQLITE_IOERR : c_int = 10;
|
const SQLITE_IOERR : c_int = 10;
|
||||||
pub const SQLITE_CORRUPT : c_int = 11;
|
const SQLITE_CORRUPT : c_int = 11;
|
||||||
pub const SQLITE_NOTFOUND : c_int = 12;
|
const SQLITE_NOTFOUND : c_int = 12;
|
||||||
pub const SQLITE_FULL : c_int = 13;
|
const SQLITE_FULL : c_int = 13;
|
||||||
pub const SQLITE_CANTOPEN : c_int = 14;
|
const SQLITE_CANTOPEN : c_int = 14;
|
||||||
pub const SQLITE_PROTOCOL : c_int = 15;
|
const SQLITE_PROTOCOL : c_int = 15;
|
||||||
pub const SQLITE_EMPTY : c_int = 16;
|
const SQLITE_EMPTY : c_int = 16;
|
||||||
pub const SQLITE_SCHEMA : c_int = 17;
|
const SQLITE_SCHEMA : c_int = 17;
|
||||||
pub const SQLITE_TOOBIG : c_int = 18;
|
const SQLITE_TOOBIG : c_int = 18;
|
||||||
pub const SQLITE_CONSTRAINT: c_int = 19;
|
const SQLITE_CONSTRAINT: c_int = 19;
|
||||||
pub const SQLITE_MISMATCH : c_int = 20;
|
const SQLITE_MISMATCH : c_int = 20;
|
||||||
pub const SQLITE_MISUSE : c_int = 21;
|
const SQLITE_MISUSE : c_int = 21;
|
||||||
pub const SQLITE_NOLFS : c_int = 22;
|
const SQLITE_NOLFS : c_int = 22;
|
||||||
pub const SQLITE_AUTH : c_int = 23;
|
const SQLITE_AUTH : c_int = 23;
|
||||||
pub const SQLITE_FORMAT : c_int = 24;
|
const SQLITE_FORMAT : c_int = 24;
|
||||||
pub const SQLITE_RANGE : c_int = 25;
|
const SQLITE_RANGE : c_int = 25;
|
||||||
pub const SQLITE_NOTADB : c_int = 26;
|
const SQLITE_NOTADB : c_int = 26;
|
||||||
pub const SQLITE_NOTICE : c_int = 27;
|
const SQLITE_NOTICE : c_int = 27;
|
||||||
pub const SQLITE_WARNING : c_int = 28;
|
const SQLITE_WARNING : c_int = 28;
|
||||||
pub const SQLITE_ROW : c_int = 100;
|
const SQLITE_ROW : c_int = 100;
|
||||||
pub const SQLITE_DONE : c_int = 101;
|
const SQLITE_DONE : c_int = 101;
|
||||||
|
|
||||||
// Extended result codes.
|
// Extended result codes.
|
||||||
|
|
||||||
pub const SQLITE_IOERR_READ : c_int = (SQLITE_IOERR | (1<<8));
|
const SQLITE_IOERR_READ : c_int = (SQLITE_IOERR | (1<<8));
|
||||||
pub const SQLITE_IOERR_SHORT_READ : c_int = (SQLITE_IOERR | (2<<8));
|
const SQLITE_IOERR_SHORT_READ : c_int = (SQLITE_IOERR | (2<<8));
|
||||||
pub const SQLITE_IOERR_WRITE : c_int = (SQLITE_IOERR | (3<<8));
|
const SQLITE_IOERR_WRITE : c_int = (SQLITE_IOERR | (3<<8));
|
||||||
pub const SQLITE_IOERR_FSYNC : c_int = (SQLITE_IOERR | (4<<8));
|
const SQLITE_IOERR_FSYNC : c_int = (SQLITE_IOERR | (4<<8));
|
||||||
pub const SQLITE_IOERR_DIR_FSYNC : c_int = (SQLITE_IOERR | (5<<8));
|
const SQLITE_IOERR_DIR_FSYNC : c_int = (SQLITE_IOERR | (5<<8));
|
||||||
pub const SQLITE_IOERR_TRUNCATE : c_int = (SQLITE_IOERR | (6<<8));
|
const SQLITE_IOERR_TRUNCATE : c_int = (SQLITE_IOERR | (6<<8));
|
||||||
pub const SQLITE_IOERR_FSTAT : c_int = (SQLITE_IOERR | (7<<8));
|
const SQLITE_IOERR_FSTAT : c_int = (SQLITE_IOERR | (7<<8));
|
||||||
pub const SQLITE_IOERR_UNLOCK : c_int = (SQLITE_IOERR | (8<<8));
|
const SQLITE_IOERR_UNLOCK : c_int = (SQLITE_IOERR | (8<<8));
|
||||||
pub const SQLITE_IOERR_RDLOCK : c_int = (SQLITE_IOERR | (9<<8));
|
const SQLITE_IOERR_RDLOCK : c_int = (SQLITE_IOERR | (9<<8));
|
||||||
pub const SQLITE_IOERR_DELETE : c_int = (SQLITE_IOERR | (10<<8));
|
const SQLITE_IOERR_DELETE : c_int = (SQLITE_IOERR | (10<<8));
|
||||||
pub const SQLITE_IOERR_BLOCKED : c_int = (SQLITE_IOERR | (11<<8));
|
const SQLITE_IOERR_BLOCKED : c_int = (SQLITE_IOERR | (11<<8));
|
||||||
pub const SQLITE_IOERR_NOMEM : c_int = (SQLITE_IOERR | (12<<8));
|
const SQLITE_IOERR_NOMEM : c_int = (SQLITE_IOERR | (12<<8));
|
||||||
pub const SQLITE_IOERR_ACCESS : c_int = (SQLITE_IOERR | (13<<8));
|
const SQLITE_IOERR_ACCESS : c_int = (SQLITE_IOERR | (13<<8));
|
||||||
pub const SQLITE_IOERR_CHECKRESERVEDLOCK : c_int = (SQLITE_IOERR | (14<<8));
|
const SQLITE_IOERR_CHECKRESERVEDLOCK : c_int = (SQLITE_IOERR | (14<<8));
|
||||||
pub const SQLITE_IOERR_LOCK : c_int = (SQLITE_IOERR | (15<<8));
|
const SQLITE_IOERR_LOCK : c_int = (SQLITE_IOERR | (15<<8));
|
||||||
pub const SQLITE_IOERR_CLOSE : c_int = (SQLITE_IOERR | (16<<8));
|
const SQLITE_IOERR_CLOSE : c_int = (SQLITE_IOERR | (16<<8));
|
||||||
pub const SQLITE_IOERR_DIR_CLOSE : c_int = (SQLITE_IOERR | (17<<8));
|
const SQLITE_IOERR_DIR_CLOSE : c_int = (SQLITE_IOERR | (17<<8));
|
||||||
pub const SQLITE_IOERR_SHMOPEN : c_int = (SQLITE_IOERR | (18<<8));
|
const SQLITE_IOERR_SHMOPEN : c_int = (SQLITE_IOERR | (18<<8));
|
||||||
pub const SQLITE_IOERR_SHMSIZE : c_int = (SQLITE_IOERR | (19<<8));
|
const SQLITE_IOERR_SHMSIZE : c_int = (SQLITE_IOERR | (19<<8));
|
||||||
pub const SQLITE_IOERR_SHMLOCK : c_int = (SQLITE_IOERR | (20<<8));
|
const SQLITE_IOERR_SHMLOCK : c_int = (SQLITE_IOERR | (20<<8));
|
||||||
pub const SQLITE_IOERR_SHMMAP : c_int = (SQLITE_IOERR | (21<<8));
|
const SQLITE_IOERR_SHMMAP : c_int = (SQLITE_IOERR | (21<<8));
|
||||||
pub const SQLITE_IOERR_SEEK : c_int = (SQLITE_IOERR | (22<<8));
|
const SQLITE_IOERR_SEEK : c_int = (SQLITE_IOERR | (22<<8));
|
||||||
pub const SQLITE_IOERR_DELETE_NOENT : c_int = (SQLITE_IOERR | (23<<8));
|
const SQLITE_IOERR_DELETE_NOENT : c_int = (SQLITE_IOERR | (23<<8));
|
||||||
pub const SQLITE_IOERR_MMAP : c_int = (SQLITE_IOERR | (24<<8));
|
const SQLITE_IOERR_MMAP : c_int = (SQLITE_IOERR | (24<<8));
|
||||||
pub const SQLITE_IOERR_GETTEMPPATH : c_int = (SQLITE_IOERR | (25<<8));
|
const SQLITE_IOERR_GETTEMPPATH : c_int = (SQLITE_IOERR | (25<<8));
|
||||||
pub const SQLITE_IOERR_CONVPATH : c_int = (SQLITE_IOERR | (26<<8));
|
const SQLITE_IOERR_CONVPATH : c_int = (SQLITE_IOERR | (26<<8));
|
||||||
pub const SQLITE_IOERR_VNODE : c_int = (SQLITE_IOERR | (27<<8));
|
const SQLITE_IOERR_VNODE : c_int = (SQLITE_IOERR | (27<<8));
|
||||||
pub const SQLITE_LOCKED_SHAREDCACHE : c_int = (SQLITE_LOCKED | (1<<8));
|
const SQLITE_LOCKED_SHAREDCACHE : c_int = (SQLITE_LOCKED | (1<<8));
|
||||||
pub const SQLITE_BUSY_RECOVERY : c_int = (SQLITE_BUSY | (1<<8));
|
const SQLITE_BUSY_RECOVERY : c_int = (SQLITE_BUSY | (1<<8));
|
||||||
pub const SQLITE_BUSY_SNAPSHOT : c_int = (SQLITE_BUSY | (2<<8));
|
const SQLITE_BUSY_SNAPSHOT : c_int = (SQLITE_BUSY | (2<<8));
|
||||||
pub const SQLITE_CANTOPEN_NOTEMPDIR : c_int = (SQLITE_CANTOPEN | (1<<8));
|
const SQLITE_CANTOPEN_NOTEMPDIR : c_int = (SQLITE_CANTOPEN | (1<<8));
|
||||||
pub const SQLITE_CANTOPEN_ISDIR : c_int = (SQLITE_CANTOPEN | (2<<8));
|
const SQLITE_CANTOPEN_ISDIR : c_int = (SQLITE_CANTOPEN | (2<<8));
|
||||||
pub const SQLITE_CANTOPEN_FULLPATH : c_int = (SQLITE_CANTOPEN | (3<<8));
|
const SQLITE_CANTOPEN_FULLPATH : c_int = (SQLITE_CANTOPEN | (3<<8));
|
||||||
pub const SQLITE_CANTOPEN_CONVPATH : c_int = (SQLITE_CANTOPEN | (4<<8));
|
const SQLITE_CANTOPEN_CONVPATH : c_int = (SQLITE_CANTOPEN | (4<<8));
|
||||||
pub const SQLITE_CORRUPT_VTAB : c_int = (SQLITE_CORRUPT | (1<<8));
|
const SQLITE_CORRUPT_VTAB : c_int = (SQLITE_CORRUPT | (1<<8));
|
||||||
pub const SQLITE_READONLY_RECOVERY : c_int = (SQLITE_READONLY | (1<<8));
|
const SQLITE_READONLY_RECOVERY : c_int = (SQLITE_READONLY | (1<<8));
|
||||||
pub const SQLITE_READONLY_CANTLOCK : c_int = (SQLITE_READONLY | (2<<8));
|
const SQLITE_READONLY_CANTLOCK : c_int = (SQLITE_READONLY | (2<<8));
|
||||||
pub const SQLITE_READONLY_ROLLBACK : c_int = (SQLITE_READONLY | (3<<8));
|
const SQLITE_READONLY_ROLLBACK : c_int = (SQLITE_READONLY | (3<<8));
|
||||||
pub const SQLITE_READONLY_DBMOVED : c_int = (SQLITE_READONLY | (4<<8));
|
const SQLITE_READONLY_DBMOVED : c_int = (SQLITE_READONLY | (4<<8));
|
||||||
pub const SQLITE_ABORT_ROLLBACK : c_int = (SQLITE_ABORT | (2<<8));
|
const SQLITE_ABORT_ROLLBACK : c_int = (SQLITE_ABORT | (2<<8));
|
||||||
pub const SQLITE_CONSTRAINT_CHECK : c_int = (SQLITE_CONSTRAINT | (1<<8));
|
const SQLITE_CONSTRAINT_CHECK : c_int = (SQLITE_CONSTRAINT | (1<<8));
|
||||||
pub const SQLITE_CONSTRAINT_COMMITHOOK : c_int = (SQLITE_CONSTRAINT | (2<<8));
|
const SQLITE_CONSTRAINT_COMMITHOOK : c_int = (SQLITE_CONSTRAINT | (2<<8));
|
||||||
pub const SQLITE_CONSTRAINT_FOREIGNKEY : c_int = (SQLITE_CONSTRAINT | (3<<8));
|
const SQLITE_CONSTRAINT_FOREIGNKEY : c_int = (SQLITE_CONSTRAINT | (3<<8));
|
||||||
pub const SQLITE_CONSTRAINT_FUNCTION : c_int = (SQLITE_CONSTRAINT | (4<<8));
|
const SQLITE_CONSTRAINT_FUNCTION : c_int = (SQLITE_CONSTRAINT | (4<<8));
|
||||||
pub const SQLITE_CONSTRAINT_NOTNULL : c_int = (SQLITE_CONSTRAINT | (5<<8));
|
const SQLITE_CONSTRAINT_NOTNULL : c_int = (SQLITE_CONSTRAINT | (5<<8));
|
||||||
pub const SQLITE_CONSTRAINT_PRIMARYKEY : c_int = (SQLITE_CONSTRAINT | (6<<8));
|
const SQLITE_CONSTRAINT_PRIMARYKEY : c_int = (SQLITE_CONSTRAINT | (6<<8));
|
||||||
pub const SQLITE_CONSTRAINT_TRIGGER : c_int = (SQLITE_CONSTRAINT | (7<<8));
|
const SQLITE_CONSTRAINT_TRIGGER : c_int = (SQLITE_CONSTRAINT | (7<<8));
|
||||||
pub const SQLITE_CONSTRAINT_UNIQUE : c_int = (SQLITE_CONSTRAINT | (8<<8));
|
const SQLITE_CONSTRAINT_UNIQUE : c_int = (SQLITE_CONSTRAINT | (8<<8));
|
||||||
pub const SQLITE_CONSTRAINT_VTAB : c_int = (SQLITE_CONSTRAINT | (9<<8));
|
const SQLITE_CONSTRAINT_VTAB : c_int = (SQLITE_CONSTRAINT | (9<<8));
|
||||||
pub const SQLITE_CONSTRAINT_ROWID : c_int = (SQLITE_CONSTRAINT |(10<<8));
|
const SQLITE_CONSTRAINT_ROWID : c_int = (SQLITE_CONSTRAINT |(10<<8));
|
||||||
pub const SQLITE_NOTICE_RECOVER_WAL : c_int = (SQLITE_NOTICE | (1<<8));
|
const SQLITE_NOTICE_RECOVER_WAL : c_int = (SQLITE_NOTICE | (1<<8));
|
||||||
pub const SQLITE_NOTICE_RECOVER_ROLLBACK : c_int = (SQLITE_NOTICE | (2<<8));
|
const SQLITE_NOTICE_RECOVER_ROLLBACK : c_int = (SQLITE_NOTICE | (2<<8));
|
||||||
pub const SQLITE_WARNING_AUTOINDEX : c_int = (SQLITE_WARNING | (1<<8));
|
const SQLITE_WARNING_AUTOINDEX : c_int = (SQLITE_WARNING | (1<<8));
|
||||||
pub const SQLITE_AUTH_USER : c_int = (SQLITE_AUTH | (1<<8));
|
const SQLITE_AUTH_USER : c_int = (SQLITE_AUTH | (1<<8));
|
||||||
|
|
||||||
pub fn code_to_str(code: c_int) -> &'static str {
|
pub fn code_to_str(code: c_int) -> &'static str {
|
||||||
match code {
|
match code {
|
||||||
|
@ -114,6 +114,15 @@ pub fn set_result<'a>(ctx: *mut sqlite3_context, result: &ToSqlOutput<'a>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
pub unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
||||||
|
// Extended constraint error codes were added in SQLite 3.7.16. We don't have 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(feature = "bundled")]
|
||||||
|
fn constraint_error_code() -> i32 { ffi::SQLITE_CONSTRAINT_FUNCTION }
|
||||||
|
#[cfg(not(feature = "bundled"))]
|
||||||
|
fn constraint_error_code() -> i32 { ffi::SQLITE_CONSTRAINT }
|
||||||
|
|
||||||
match *err {
|
match *err {
|
||||||
Error::SqliteFailure(ref err, ref s) => {
|
Error::SqliteFailure(ref err, ref s) => {
|
||||||
ffi::sqlite3_result_error_code(ctx, err.extended_code);
|
ffi::sqlite3_result_error_code(ctx, err.extended_code);
|
||||||
@ -122,7 +131,7 @@ pub unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
ffi::sqlite3_result_error_code(ctx, ffi::SQLITE_CONSTRAINT_FUNCTION);
|
ffi::sqlite3_result_error_code(ctx, constraint_error_code());
|
||||||
if let Ok(cstr) = str_to_cstring(err.description()) {
|
if let Ok(cstr) = str_to_cstring(err.description()) {
|
||||||
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
|
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
|
||||||
}
|
}
|
||||||
|
18
src/lib.rs
18
src/lib.rs
@ -56,7 +56,7 @@ extern crate libsqlite3_sys as ffi;
|
|||||||
extern crate lru_cache;
|
extern crate lru_cache;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[cfg(test)]
|
#[cfg(all(test, feature = "trace"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
@ -1171,6 +1171,15 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_notnull_constraint_error() {
|
fn test_notnull_constraint_error() {
|
||||||
|
// 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(feature = "bundled")]
|
||||||
|
fn check_extended_code(extended_code: c_int) {
|
||||||
|
assert_eq!(extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL);
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "bundled"))]
|
||||||
|
fn check_extended_code(_extended_code: c_int) {}
|
||||||
|
|
||||||
let db = checked_memory_handle();
|
let db = checked_memory_handle();
|
||||||
db.execute_batch("CREATE TABLE foo(x NOT NULL)").unwrap();
|
db.execute_batch("CREATE TABLE foo(x NOT NULL)").unwrap();
|
||||||
|
|
||||||
@ -1180,12 +1189,7 @@ mod test {
|
|||||||
match result.unwrap_err() {
|
match result.unwrap_err() {
|
||||||
Error::SqliteFailure(err, _) => {
|
Error::SqliteFailure(err, _) => {
|
||||||
assert_eq!(err.code, ErrorCode::ConstraintViolation);
|
assert_eq!(err.code, ErrorCode::ConstraintViolation);
|
||||||
|
check_extended_code(err.extended_code);
|
||||||
// extended error codes for constraints were added in SQLite 3.7.16; if we're
|
|
||||||
// running on a version at least that new, check for the extended code
|
|
||||||
if version_number() >= 3007016 {
|
|
||||||
assert_eq!(err.extended_code, ffi::SQLITE_CONSTRAINT_NOTNULL)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {}", err),
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,14 @@ impl Error for FromSqlError {
|
|||||||
pub type FromSqlResult<T> = Result<T, FromSqlError>;
|
pub type FromSqlResult<T> = Result<T, FromSqlError>;
|
||||||
|
|
||||||
/// A trait for types that can be created from a SQLite value.
|
/// A trait for types that can be created from a SQLite value.
|
||||||
|
///
|
||||||
|
/// Note that `FromSql` and `ToSql` are defined for most integral types, but not `u64` or `usize`.
|
||||||
|
/// This is intentional; SQLite returns integers as signed 64-bit values, which cannot fully
|
||||||
|
/// represent the range of these types. Rusqlite would have to decide how to handle negative
|
||||||
|
/// values: return an error or reinterpret as a very large postive numbers, neither of which is
|
||||||
|
/// guaranteed to be correct for everyone. Callers can work around this by fetching values as i64
|
||||||
|
/// and then doing the interpretation themselves or by defining a newtype and implementing
|
||||||
|
/// `FromSql`/`ToSql` for it.
|
||||||
pub trait FromSql: Sized {
|
pub trait FromSql: Sized {
|
||||||
fn column_result(value: ValueRef) -> FromSqlResult<Self>;
|
fn column_result(value: ValueRef) -> FromSqlResult<Self>;
|
||||||
}
|
}
|
||||||
@ -72,6 +80,7 @@ macro_rules! from_sql_integral(
|
|||||||
from_sql_integral!(i8);
|
from_sql_integral!(i8);
|
||||||
from_sql_integral!(i16);
|
from_sql_integral!(i16);
|
||||||
from_sql_integral!(i32);
|
from_sql_integral!(i32);
|
||||||
|
from_sql_integral!(isize);
|
||||||
from_sql_integral!(u8);
|
from_sql_integral!(u8);
|
||||||
from_sql_integral!(u16);
|
from_sql_integral!(u16);
|
||||||
from_sql_integral!(u32);
|
from_sql_integral!(u32);
|
||||||
|
@ -74,6 +74,7 @@ to_sql_self!(i8);
|
|||||||
to_sql_self!(i16);
|
to_sql_self!(i16);
|
||||||
to_sql_self!(i32);
|
to_sql_self!(i32);
|
||||||
to_sql_self!(i64);
|
to_sql_self!(i64);
|
||||||
|
to_sql_self!(isize);
|
||||||
to_sql_self!(u8);
|
to_sql_self!(u8);
|
||||||
to_sql_self!(u16);
|
to_sql_self!(u16);
|
||||||
to_sql_self!(u32);
|
to_sql_self!(u32);
|
||||||
|
@ -43,6 +43,7 @@ macro_rules! from_i64(
|
|||||||
from_i64!(i8);
|
from_i64!(i8);
|
||||||
from_i64!(i16);
|
from_i64!(i16);
|
||||||
from_i64!(i32);
|
from_i64!(i32);
|
||||||
|
from_i64!(isize);
|
||||||
from_i64!(u8);
|
from_i64!(u8);
|
||||||
from_i64!(u16);
|
from_i64!(u16);
|
||||||
from_i64!(u32);
|
from_i64!(u32);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! This file contains unit tests for rusqlite::trace::config_log. This function affects
|
//! This file contains unit tests for rusqlite::trace::config_log. This function affects
|
||||||
//! SQLite process-wide and so is not safe to run as a normal #[test] in the library.
|
//! SQLite process-wide and so is not safe to run as a normal #[test] in the library.
|
||||||
|
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
extern crate rusqlite;
|
extern crate rusqlite;
|
||||||
|
Loading…
Reference in New Issue
Block a user