mirror of
https://github.com/isar/rusqlite.git
synced 2025-02-01 07:30:52 +08:00
Merge remote-tracking branch 'jgallagher/master' into vtab
This commit is contained in:
commit
8b9437ff35
@ -33,7 +33,7 @@ serde_json = { version = "0.8", optional = true }
|
||||
[dev-dependencies]
|
||||
tempdir = "0.3"
|
||||
lazy_static = "0.2"
|
||||
regex = "0.1"
|
||||
regex = "0.2"
|
||||
|
||||
[dependencies.libsqlite3-sys]
|
||||
path = "libsqlite3-sys"
|
||||
|
17
src/lib.rs
17
src/lib.rs
@ -90,6 +90,7 @@ pub use error::Error;
|
||||
pub use cache::CachedStatement;
|
||||
|
||||
#[cfg(feature = "load_extension")]
|
||||
#[allow(deprecated)]
|
||||
pub use load_extension_guard::{SqliteLoadExtensionGuard, LoadExtensionGuard};
|
||||
|
||||
pub mod types;
|
||||
@ -615,8 +616,11 @@ impl InnerConnection {
|
||||
fn close(&mut self) -> Result<()> {
|
||||
unsafe {
|
||||
let r = ffi::sqlite3_close(self.db());
|
||||
self.db = ptr::null_mut();
|
||||
self.decode_result(r)
|
||||
let r = self.decode_result(r);
|
||||
if r.is_ok() {
|
||||
self.db = ptr::null_mut();
|
||||
}
|
||||
r
|
||||
}
|
||||
}
|
||||
|
||||
@ -1286,13 +1290,14 @@ mod test {
|
||||
raw_stmt
|
||||
};
|
||||
|
||||
let result = db.close();
|
||||
assert!(result.is_err());
|
||||
// now that we have an open statement, trying (and retrying) to close should fail.
|
||||
let (db, _) = db.close().unwrap_err();
|
||||
let (db, _) = db.close().unwrap_err();
|
||||
let (db, _) = db.close().unwrap_err();
|
||||
|
||||
// finalize the open statement so a second close will succeed
|
||||
// finalize the open statement so a final close will succeed
|
||||
assert_eq!(ffi::SQLITE_OK, unsafe { ffi::sqlite3_finalize(raw_stmt) });
|
||||
|
||||
let (db, _) = result.unwrap_err();
|
||||
db.close().unwrap();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user