Activate SQLITE_OPEN_EXRESCODE by default

I am not completly sure that it is fine to activate this flag with an old
SQLite version.
See http://sqlite.org/c3ref/open.html
> If the 3rd parameter to sqlite3_open_v2() is not one of the required combinations shown above optionally combined with other SQLITE_OPEN_* bits then the behavior is undefined.
This commit is contained in:
gwenn 2024-03-28 20:32:07 +01:00
parent b41bd80571
commit a016ed111b
2 changed files with 5 additions and 2 deletions

View File

@ -12,6 +12,7 @@ use super::{Connection, InterruptHandle, OpenFlags, PrepFlags, Result};
use crate::error::{error_from_handle, error_from_sqlite_code, error_with_offset, Error};
use crate::raw_statement::RawStatement;
use crate::statement::Statement;
use crate::version_number;
pub struct InnerConnection {
pub db: *mut ffi::sqlite3,
@ -99,7 +100,9 @@ impl InnerConnection {
}
// attempt to turn on extended results code; don't fail if we can't.
ffi::sqlite3_extended_result_codes(db, 1);
if version_number() < 3_037_000 || !flags.contains(OpenFlags::SQLITE_OPEN_EXRESCODE) {
ffi::sqlite3_extended_result_codes(db, 1);
}
let r = ffi::sqlite3_busy_timeout(db, 5000);
if r != ffi::SQLITE_OK {
@ -210,7 +213,6 @@ impl InnerConnection {
let mut c_stmt: *mut ffi::sqlite3_stmt = ptr::null_mut();
let (c_sql, len, _) = str_for_sqlite(sql.as_bytes())?;
let mut c_tail: *const c_char = ptr::null();
// TODO sqlite3_prepare_v3 (https://sqlite.org/c3ref/c_prepare_normalize.html) // 3.20.0, #728
#[cfg(not(feature = "unlock_notify"))]
let r = unsafe { self.prepare_(c_sql, len, flags, &mut c_stmt, &mut c_tail) };
#[cfg(feature = "unlock_notify")]

View File

@ -1214,6 +1214,7 @@ impl Default for OpenFlags {
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_NO_MUTEX
| OpenFlags::SQLITE_OPEN_URI
| OpenFlags::SQLITE_OPEN_EXRESCODE
}
}