From d56932c4e6babde6f8833d6dd55eb5dbabd9b454 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 28 Oct 2025 15:16:49 +0100 Subject: [PATCH] Fix exception with multiple batch operations in SQLite3 backend Don't leave current_row_ with an invalid value after finishing a batch operation, it could be reused, resulting in an exception due to the index being invalid, when the statement is executed again. Note that this was already done for the other backends using current_row_ in their overridden get_row_to_dump() in a similar way (Firebird and PostgreSQL), so they were not affected by this bug. Closes #1308. --- src/backends/sqlite3/statement.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backends/sqlite3/statement.cpp b/src/backends/sqlite3/statement.cpp index d2e95135..68458207 100644 --- a/src/backends/sqlite3/statement.cpp +++ b/src/backends/sqlite3/statement.cpp @@ -334,6 +334,10 @@ sqlite3_statement_backend::bind_and_execute(int number) rowsAffectedBulk_ += sqlite3_changes(session_.conn_); } + // Don't leave invalid (out of range) value in current_row_, this can't be + // useful and can cause problems when using multiple batch inserts. + current_row_ = -1; + return retVal; }