Repository navigation
Conversation
A `dbBind()` whose first row failed to bind left a completed result: `dbHasCompleted()` returned `TRUE` and `dbGetRowsAffected()` returned `NA`. A `dbBind()` whose statement failed left a completed result too, whose fetch returned zero rows. Every failed `dbBind()` now leaves the result unbound, whichever row fails and whether it fails to bind or in the statement. `dbFetch()` asks for a new bind with "Query needs to be bound before fetching", and `dbHasCompleted()` returns `FALSE`. A flag records that a bind has started, separately from the readiness to fetch, so that `dbGetRowsAffected()` counts the rows changed since that bind: 0 when the first row fails to bind, 2 when the third of four inserts fails. It is still `NA` before the first bind. The tests from #868 and #935 that pinned the completed state now pin the unbound one. Ported from #830, as decided in #880 (comment) (option 1). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
After a failed bind, the statement is on no row, so peeking at the first row reads column values only for a bound result. Before the first bind, the column info is the same as before. NEWS states that input refused before binding keeps the previous binding, with a test that pins it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
… claude/rb-failed-bind-state Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
This was referenced Dec 1, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a
dbBind()whose parameters fail to bind or to run, the result is in one state: it is left unbound,dbFetch()refuses with "Query needs to be bound before fetching",dbHasCompleted()returnsFALSE, anddbGetRowsAffected()counts the rows changed since that bind. This holds whichever row fails, and whether it fails to bind or in the statement. Input thatdbBind()refuses before binding (the wrong number of parameters, columns of different lengths, placeholder or name errors, or a busy connection) keeps the previous binding usable, as on #935. For example, withCREATE TABLE u (x INTEGER UNIQUE)andres <- dbSendStatement(con, "INSERT INTO u VALUES (?)"),dbBind(res, list(c(1L, 2L, 1L, 3L)))fails on the third row and leavesFALSEand 2;dbBind(res, list(list(1)))fails to bind the first row and leavesFALSEand 0. RSQLite 3.54.1 returnedTRUEandNAwhen the first row failed to bind (from #868), andFALSEplus a count for an error from the statement. On #935, adbBind()whose first step fails left a completed result whose fetch returned zero rows; that is now the unbound state too.This follows the maintainer's decision in #880 (comment) (option 1). In
SqliteResultImpl::bind(), onecatcharound the bind and the first step drops the parameters and resetsready_andcomplete_tofalse, and a new flagbind_started_letsn_rows_affected()count from the latest bind also after it failed. It is stillNAbefore the first bind.peek_first_row()reads column values only for a bound result, sodbColumnInfo()after a failed bind reads no values from a statement that is on no row, and gives the same as before the first bind.Tests: the five #868 expectations in
tests/testthat/test-dbBind.Rchange (threedbHasCompleted()fromTRUEtoFALSE, twodbGetRowsAffected()fromNAto 0), and "an unsupported parameter type leaves a completed, unbound result" loses "completed". The #935 test "a fetch doesn't run a write again after its dbBind() failed" intests/testthat/test-fetch-error.Rnow expects the unbound state. Two new tests cover the reprex above (a failure on the third row and on the first row of the same statement) and a query whose first row fails in the statement. Two more pindbColumnInfo()after a failed bind and the kept binding after input refused before binding. Red on #935: the rewritten and new expectations fail in both files (dbHasCompleted()TRUE,dbGetRowsAffected()NA,dbFetch()not refusing). The last two tests pass on #935 too: they pin behavior that this change keeps. Green with this change: the full suite withNOT_CRAN=truegives FAIL 0, WARN 3, SKIP 63, PASS 10988.Layer B5 of the rebuilt chain, planned in #880; based on #935. Ported from #830 (now a draft), commits 527c277, d928047 and 1edd8f4, with its NEWS bullet.
Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Generated by Claude Code