Skip to content

Commit 97b50b9

Browse files
committed
sqlite: ensure that we additionally clear the bindings when resetting the statement
1 parent 2abc451 commit 97b50b9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sqlx-core/src/sqlite/statement.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use std::ffi::CStr;
55
use std::os::raw::c_int;
66

77
use libsqlite3_sys::{
8-
sqlite3_bind_parameter_count, sqlite3_column_count, sqlite3_column_decltype,
9-
sqlite3_column_name, sqlite3_finalize, sqlite3_prepare_v3, sqlite3_reset, sqlite3_step,
10-
sqlite3_stmt, SQLITE_DONE, SQLITE_OK, SQLITE_PREPARE_NO_VTAB, SQLITE_PREPARE_PERSISTENT,
11-
SQLITE_ROW,
8+
sqlite3_bind_parameter_count, sqlite3_clear_bindings, sqlite3_column_count,
9+
sqlite3_column_decltype, sqlite3_column_name, sqlite3_finalize, sqlite3_prepare_v3,
10+
sqlite3_reset, sqlite3_step, sqlite3_stmt, SQLITE_DONE, SQLITE_OK, SQLITE_PREPARE_NO_VTAB,
11+
SQLITE_PREPARE_PERSISTENT, SQLITE_ROW,
1212
};
1313

1414
use crate::sqlite::worker::Worker;
@@ -160,12 +160,16 @@ impl SqliteStatement {
160160

161161
pub(super) fn reset(&mut self) {
162162
// https://sqlite.org/c3ref/reset.html
163+
// https://sqlite.org/c3ref/clear_bindings.html
163164

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

167168
#[allow(unsafe_code)]
168169
let _ = unsafe { sqlite3_reset(self.handle()) };
170+
171+
#[allow(unsafe_code)]
172+
let _ = unsafe { sqlite3_clear_bindings(self.handle()) };
169173
}
170174

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

0 commit comments

Comments
 (0)