mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-16 12:42:18 +08:00
Check sqlite3_reset result
https://sqlite.org/c3ref/reset.html > Therefore, it is important that applications check the return code from sqlite3_reset(S) even if no prior call to sqlite3_step(S) indicated a problem.
This commit is contained in:
@@ -650,9 +650,12 @@ impl Statement<'_> {
|
||||
fn execute_with_bound_parameters(&mut self) -> Result<usize> {
|
||||
self.check_update()?;
|
||||
let r = self.stmt.step();
|
||||
self.stmt.reset();
|
||||
let rr = self.stmt.reset();
|
||||
match r {
|
||||
ffi::SQLITE_DONE => Ok(self.conn.changes() as usize),
|
||||
ffi::SQLITE_DONE => match rr {
|
||||
ffi::SQLITE_OK => Ok(self.conn.changes() as usize),
|
||||
_ => Err(self.conn.decode_result(rr).unwrap_err()),
|
||||
},
|
||||
ffi::SQLITE_ROW => Err(Error::ExecuteReturnedResults),
|
||||
_ => Err(self.conn.decode_result(r).unwrap_err()),
|
||||
}
|
||||
@@ -847,8 +850,11 @@ impl Statement<'_> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn reset(&self) -> c_int {
|
||||
self.stmt.reset()
|
||||
pub(super) fn reset(&self) -> Result<()> {
|
||||
match self.stmt.reset() {
|
||||
ffi::SQLITE_OK => Ok(()),
|
||||
code => Err(self.conn.decode_result(code).unwrap_err()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1274,7 +1280,7 @@ mod test {
|
||||
assert_eq!(0, stmt.column_count());
|
||||
stmt.parameter_index("test").unwrap();
|
||||
stmt.step().unwrap_err();
|
||||
stmt.reset();
|
||||
stmt.reset().unwrap(); // SQLITE_OMIT_AUTORESET = false
|
||||
stmt.execute([]).unwrap_err();
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user