Skip to content

Commit

Permalink
sqlite: ensure that we additionally clear the bindings when resetting…
Browse files Browse the repository at this point in the history
… the statement
  • Loading branch information
mehcode committed Mar 15, 2020
1 parent 2abc451 commit e65e31c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sqlx-core/src/sqlite/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use libsqlite3_sys::{
sqlite3_bind_parameter_count, sqlite3_column_count, sqlite3_column_decltype,
sqlite3_column_name, sqlite3_finalize, sqlite3_prepare_v3, sqlite3_reset, sqlite3_step,
sqlite3_stmt, SQLITE_DONE, SQLITE_OK, SQLITE_PREPARE_NO_VTAB, SQLITE_PREPARE_PERSISTENT,
sqlite3_clear_bindings,
SQLITE_ROW,
};

Expand Down Expand Up @@ -160,12 +161,16 @@ impl SqliteStatement {

pub(super) fn reset(&mut self) {
// https://sqlite.org/c3ref/reset.html
// https://sqlite.org/c3ref/clear_bindings.html

// the status value of reset is ignored because it merely propagates
// the status of the most recently invoked step function

#[allow(unsafe_code)]
let _ = unsafe { sqlite3_reset(self.handle()) };

#[allow(unsafe_code)]
let _ = unsafe { sqlite3_clear_bindings(self.handle()) };
}

pub(super) async fn step(&mut self) -> crate::Result<Step> {
Expand Down

0 comments on commit e65e31c

Please sign in to comment.