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 97b50b9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sqlx-core/src/sqlite/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use std::ffi::CStr;
use std::os::raw::c_int;

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,
SQLITE_ROW,
sqlite3_bind_parameter_count, sqlite3_clear_bindings, 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, SQLITE_ROW,
};

use crate::sqlite::worker::Worker;
Expand Down Expand Up @@ -160,12 +160,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 97b50b9

Please sign in to comment.