mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-29 21:52:12 +08:00
Retrieve error message from database connection handle
This commit is contained in:
parent
10da56788c
commit
2dea70304d
@ -40,7 +40,7 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use crate::ffi;
|
use crate::ffi;
|
||||||
|
|
||||||
use crate::error::{error_from_handle, error_from_sqlite_code};
|
use crate::error::error_from_handle;
|
||||||
use crate::{Connection, DatabaseName, Result};
|
use crate::{Connection, DatabaseName, Result};
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
@ -169,7 +169,7 @@ pub struct Progress {
|
|||||||
/// A handle to an online backup.
|
/// A handle to an online backup.
|
||||||
pub struct Backup<'a, 'b> {
|
pub struct Backup<'a, 'b> {
|
||||||
phantom_from: PhantomData<&'a Connection>,
|
phantom_from: PhantomData<&'a Connection>,
|
||||||
phantom_to: PhantomData<&'b Connection>,
|
to: &'b Connection,
|
||||||
b: *mut ffi::sqlite3_backup,
|
b: *mut ffi::sqlite3_backup,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ impl Backup<'_, '_> {
|
|||||||
|
|
||||||
Ok(Backup {
|
Ok(Backup {
|
||||||
phantom_from: PhantomData,
|
phantom_from: PhantomData,
|
||||||
phantom_to: PhantomData,
|
to,
|
||||||
b,
|
b,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ impl Backup<'_, '_> {
|
|||||||
ffi::SQLITE_OK => Ok(More),
|
ffi::SQLITE_OK => Ok(More),
|
||||||
ffi::SQLITE_BUSY => Ok(Busy),
|
ffi::SQLITE_BUSY => Ok(Busy),
|
||||||
ffi::SQLITE_LOCKED => Ok(Locked),
|
ffi::SQLITE_LOCKED => Ok(Locked),
|
||||||
_ => Err(error_from_sqlite_code(rc, None)),
|
_ => self.to.decode_result(rc).map(|_| More),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,15 +44,14 @@ impl<'conn> Blob<'conn> {
|
|||||||
// losslessly converted to i32, since `len` came from an i32.
|
// losslessly converted to i32, since `len` came from an i32.
|
||||||
// Sanity check the above.
|
// Sanity check the above.
|
||||||
debug_assert!(i32::try_from(write_start).is_ok() && i32::try_from(buf.len()).is_ok());
|
debug_assert!(i32::try_from(write_start).is_ok() && i32::try_from(buf.len()).is_ok());
|
||||||
unsafe {
|
self.conn.decode_result(unsafe {
|
||||||
check!(ffi::sqlite3_blob_write(
|
ffi::sqlite3_blob_write(
|
||||||
self.blob,
|
self.blob,
|
||||||
buf.as_ptr() as *const _,
|
buf.as_ptr() as *const _,
|
||||||
buf.len() as i32,
|
buf.len() as i32,
|
||||||
write_start as i32,
|
write_start as i32,
|
||||||
));
|
)
|
||||||
}
|
})
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An alias for `write_at` provided for compatibility with the conceptually
|
/// An alias for `write_at` provided for compatibility with the conceptually
|
||||||
@ -151,12 +150,12 @@ impl<'conn> Blob<'conn> {
|
|||||||
debug_assert!(i32::try_from(read_len).is_ok());
|
debug_assert!(i32::try_from(read_len).is_ok());
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
check!(ffi::sqlite3_blob_read(
|
self.conn.decode_result(ffi::sqlite3_blob_read(
|
||||||
self.blob,
|
self.blob,
|
||||||
buf.as_mut_ptr() as *mut _,
|
buf.as_mut_ptr() as *mut _,
|
||||||
read_len as i32,
|
read_len as i32,
|
||||||
read_start as i32,
|
read_start as i32,
|
||||||
));
|
))?;
|
||||||
|
|
||||||
Ok(from_raw_parts_mut(buf.as_mut_ptr() as *mut u8, read_len))
|
Ok(from_raw_parts_mut(buf.as_mut_ptr() as *mut u8, read_len))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user