mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-29 05:21:37 +08:00
Fix errors relative to OpenFlags
Also handle extended error codes.
This commit is contained in:
parent
5fd76aa54b
commit
c612a44207
@ -38,6 +38,7 @@ script:
|
||||
- cargo test --features serde_json
|
||||
- cargo test --features bundled
|
||||
- cargo test --features sqlcipher
|
||||
- cargo test --features "unlock_notify bundled"
|
||||
- cargo test --features "backup blob chrono functions hooks limits load_extension serde_json trace"
|
||||
- cargo test --features "backup blob chrono functions hooks limits load_extension serde_json trace buildtime_bindgen"
|
||||
- cargo test --features "backup blob chrono functions hooks limits load_extension serde_json trace bundled"
|
||||
|
@ -875,7 +875,7 @@ impl InnerConnection {
|
||||
&mut c_stmt,
|
||||
ptr::null_mut(),
|
||||
);
|
||||
if rc != ffi::SQLITE_LOCKED {
|
||||
if (rc & 0xFF) != ffi::SQLITE_LOCKED {
|
||||
break;
|
||||
}
|
||||
rc = unlock_notify::wait_for_unlock_notify(self.db);
|
||||
|
@ -71,7 +71,9 @@ pub fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int {
|
||||
&mut un as *mut UnlockNotification as *mut c_void,
|
||||
)
|
||||
};
|
||||
debug_assert!(rc == ffi::SQLITE_LOCKED || rc == ffi::SQLITE_OK);
|
||||
debug_assert!(rc == ffi::SQLITE_LOCKED ||
|
||||
rc == ffi::SQLITE_LOCKED_SHAREDCACHE ||
|
||||
rc == ffi::SQLITE_OK);
|
||||
if rc == ffi::SQLITE_OK {
|
||||
un.wait();
|
||||
}
|
||||
@ -89,27 +91,25 @@ mod test {
|
||||
use std::sync::mpsc::sync_channel;
|
||||
use std::thread;
|
||||
use std::time;
|
||||
use {Connection, Result, Transaction, TransactionBehavior, SQLITE_OPEN_READ_WRITE,
|
||||
SQLITE_OPEN_URI};
|
||||
use {Connection, OpenFlags, Result, Transaction, TransactionBehavior};
|
||||
|
||||
#[test]
|
||||
fn test_unlock_notify() {
|
||||
let url = "file::memory:?cache=shared";
|
||||
let flags = SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_URI;
|
||||
let flags = OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_URI;
|
||||
let db1 = Connection::open_with_flags(url, flags).unwrap();
|
||||
db1.execute_batch("CREATE TABLE foo (x)").unwrap();
|
||||
let (sender, receiver) = sync_channel(0);
|
||||
let sender2 = sender.clone();
|
||||
let (rx, tx) = sync_channel(0);
|
||||
let child = thread::spawn(move || {
|
||||
let mut db2 = Connection::open_with_flags(url, flags).unwrap();
|
||||
let tx2 = Transaction::new(&mut db2, TransactionBehavior::Immediate).unwrap();
|
||||
tx2.execute_batch("INSERT INTO foo VALUES (42)").unwrap();
|
||||
sender2.send(1).unwrap();
|
||||
rx.send(1).unwrap();
|
||||
let ten_millis = time::Duration::from_millis(10);
|
||||
thread::sleep(ten_millis);
|
||||
tx2.commit().unwrap();
|
||||
});
|
||||
assert_eq!(receiver.recv().unwrap(), 1);
|
||||
assert_eq!(tx.recv().unwrap(), 1);
|
||||
let the_answer: Result<i64> = db1.query_row("SELECT x FROM foo", &[], |r| r.get(0));
|
||||
assert_eq!(42i64, the_answer.unwrap());
|
||||
child.join().unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user