mirror of
https://github.com/isar/rusqlite.git
synced 2025-03-31 19:12:58 +08:00
Always activate SQLITE_OPEN_EXRESCODE for SQLite >= 3.37.0
This commit is contained in:
parent
a016ed111b
commit
f6dd9c3a2c
@ -61,7 +61,7 @@ impl InnerConnection {
|
||||
|
||||
pub fn open_with_flags(
|
||||
c_path: &CStr,
|
||||
flags: OpenFlags,
|
||||
mut flags: OpenFlags,
|
||||
vfs: Option<&CStr>,
|
||||
) -> Result<InnerConnection> {
|
||||
ensure_safe_sqlite_threading_mode()?;
|
||||
@ -71,6 +71,16 @@ impl InnerConnection {
|
||||
None => ptr::null(),
|
||||
};
|
||||
|
||||
// turn on extended results code before opening database to have a better diagnostic if a failure happens
|
||||
let exrescode = if version_number() >= 3_037_000 {
|
||||
if !flags.contains(OpenFlags::SQLITE_OPEN_EXRESCODE) {
|
||||
flags |= OpenFlags::SQLITE_OPEN_EXRESCODE;
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false // flag SQLITE_OPEN_EXRESCODE is ignored by SQLite version < 3.37.0
|
||||
};
|
||||
|
||||
unsafe {
|
||||
let mut db: *mut ffi::sqlite3 = ptr::null_mut();
|
||||
let r = ffi::sqlite3_open_v2(c_path.as_ptr(), &mut db, flags.bits(), z_vfs);
|
||||
@ -100,7 +110,7 @@ impl InnerConnection {
|
||||
}
|
||||
|
||||
// attempt to turn on extended results code; don't fail if we can't.
|
||||
if version_number() < 3_037_000 || !flags.contains(OpenFlags::SQLITE_OPEN_EXRESCODE) {
|
||||
if !exrescode {
|
||||
ffi::sqlite3_extended_result_codes(db, 1);
|
||||
}
|
||||
|
||||
|
@ -1214,7 +1214,6 @@ impl Default for OpenFlags {
|
||||
| OpenFlags::SQLITE_OPEN_CREATE
|
||||
| OpenFlags::SQLITE_OPEN_NO_MUTEX
|
||||
| OpenFlags::SQLITE_OPEN_URI
|
||||
| OpenFlags::SQLITE_OPEN_EXRESCODE
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user