mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-23 09:18:54 +08:00
Fix incorrect ffi constant accesses.
This commit is contained in:
@@ -114,6 +114,15 @@ fn set_result<'a>(ctx: *mut sqlite3_context, result: &ToSqlOutput<'a>) {
|
||||
}
|
||||
|
||||
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 {
|
||||
Error::SqliteFailure(ref err, ref s) => {
|
||||
ffi::sqlite3_result_error_code(ctx, err.extended_code);
|
||||
@@ -122,7 +131,7 @@ 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()) {
|
||||
ffi::sqlite3_result_error(ctx, cstr.as_ptr(), -1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user