mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Merge pull request #71 from jgallagher/gwenn-reset_asap
Reset SQLite statement ASAP after executing.
This commit is contained in:
commit
3e8530a364
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rusqlite"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
authors = ["John Gallagher <jgallagher@bignerdranch.com>"]
|
||||
description = "Ergonomic wrapper for SQLite"
|
||||
repository = "https://github.com/jgallagher/rusqlite"
|
||||
|
@ -1,3 +1,8 @@
|
||||
# Version 0.3.1 (2015-09-22)
|
||||
|
||||
* Reset underlying SQLite statements as soon as possible after executing, as recommended by
|
||||
http://www.sqlite.org/cvstrac/wiki?p=ScrollingCursor.
|
||||
|
||||
# Version 0.3.0 (2015-09-21)
|
||||
|
||||
* Removes `get_opt`. Use `get_checked` instead.
|
||||
|
16
src/lib.rs
16
src/lib.rs
@ -652,20 +652,11 @@ impl<'conn> SqliteStatement<'conn> {
|
||||
/// }
|
||||
/// ```
|
||||
pub fn execute(&mut self, params: &[&ToSql]) -> SqliteResult<c_int> {
|
||||
self.reset_if_needed();
|
||||
|
||||
unsafe {
|
||||
assert!(params.len() as c_int == ffi::sqlite3_bind_parameter_count(self.stmt),
|
||||
"incorrect number of parameters to execute(): expected {}, got {}",
|
||||
ffi::sqlite3_bind_parameter_count(self.stmt),
|
||||
params.len());
|
||||
try!(self.bind_parameters(params));
|
||||
|
||||
for (i, p) in params.iter().enumerate() {
|
||||
try!(self.conn.decode_result(p.bind_parameter(self.stmt, (i + 1) as c_int)));
|
||||
}
|
||||
|
||||
self.needs_reset = true;
|
||||
let r = ffi::sqlite3_step(self.stmt);
|
||||
ffi::sqlite3_reset(self.stmt);
|
||||
match r {
|
||||
ffi::SQLITE_DONE => {
|
||||
if self.column_count != 0 {
|
||||
@ -708,6 +699,7 @@ impl<'conn> SqliteStatement<'conn> {
|
||||
try!(self.bind_parameters(params));
|
||||
}
|
||||
|
||||
self.needs_reset = true;
|
||||
Ok(SqliteRows::new(self))
|
||||
}
|
||||
|
||||
@ -765,8 +757,6 @@ impl<'conn> SqliteStatement<'conn> {
|
||||
try!(self.conn.decode_result(p.bind_parameter(self.stmt, (i + 1) as c_int)));
|
||||
}
|
||||
|
||||
self.needs_reset = true;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user