Repository navigation
Conversation
These tests pin what binding a list of parameters does, before its implementation moves into a parameter source. They cover the messages for parameters that don't match the placeholders, including an unnamed list bound to a query without placeholders, values that can't be bound, parameter sets that return any number of rows or are empty, a later set that fails to bind after earlier sets changed the database, a new bind that replaces the sets left, bound vectors that only the result refers to across fetches, and a handler that tries to bind while a fetch runs. A later set that fails to bind in a fetch is pinned in `test-read-ahead.R`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The result bound list parameters itself, with `bind_row()`, `bind_parameter_pos()` and the `group_` bookkeeping. `SqliteListParamSource` now holds the list and binds its sets one at a time, behind `SqliteParamSource`, whose one method `bind_next_row()` resets the statement and binds the next set. A later pull request adds an Arrow parameter source next to it. The source owns the list, which protects the vectors across the fetches that bind the later sets, and a new bind or a failed first set releases it, as before. A value that can't be bound throws a `std::runtime_error`, which `bind_row()` turns into a `step_error` with `SQLITE_ERROR`, so that `read_ahead()` still keeps the error of a later set for the next fetch. `db_bind()` gets `is_unnamed_placeholders()` and `match_placeholders()`, for the Arrow bind to share. `match_placeholders()` takes the parameters, not their names, and counts the unmatched ones with `seq_along(params)`, so that an unnamed list bound to a query without placeholders still fails with "Named parameters not used in query: ". No message changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
|
Review of this pull request at 7387832, by a Claude Code reviewer with clean context that read the description, the plan, the diff against #830's head aa07034, the code around it ( What was run
What holds
HighNone. MediumNone. Low
Generated by Claude Code |
…laceholders()` takes The comment of `SqliteParamSource` now says that a source must not leave by the longjmp of an R error, what happens to the result if it does, and how a source avoids it: through cpp11's safe wrappers, or with R API calls made before binding starts. `SqliteListParamSource` reads its vectors with R's API directly, as the result did before, which fails only for an ALTREP vector whose data pointer can't be taken. The comment of `match_placeholders()` now says that it takes an object whose names are matched, such as a list of parameters or the named `children` of an Arrow schema, not a vector of the names themselves. No code changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Superseded: Accepted limitationsSuperseded by the current copy. The clean review found nothing above Low: in 1461 cases compared with #830's head, values, conditions, row counts and completion were identical, also under AddressSanitizer and
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
Accepted limitationsThe clean review found nothing above Low: in 1461 cases compared with #830's head, values, conditions, row counts and completion were identical, also under AddressSanitizer and
Generated by Claude Code |
…urce Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
…urce Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
…urce Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
…urce The checks of the bind return codes from #868 move into the parameter source: SqliteListParamSource checks each code through SqliteParamSource::check_bind(), which names the parameter and the row and throws a SqliteBindError with SQLite's code. The result's bind_row() turns it into a step_error with that code and marks the result complete, as raise_bind_exception() did, which goes away with the result's own row counter. The tests of both branches are kept in test-dbBind.R. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd8MVXyvU7qoMeruD1R
This is the first pull request of the reworked Arrow stack, as planned in #829 (comment). It moves the binding of list parameters out of the result into a parameter source, so that a later pull request can add an Arrow parameter source next to it. No behavior and no message changes.
What changes
SqliteResultImplbound list parameters itself:bind_row()reset the statement and bound one parameter set throughbind_parameter_pos(), whilegroup_andgroups_counted the sets. That code moves, unchanged apart from names and the type of exception it throws, intoSqliteListParamSource, behind a small abstractSqliteParamSourcewhose one method,bind_next_row(), resets the statement, binds the next set, and returns whether there was one. The result keeps the source of its latest bind in aboost::scoped_ptrand calls it frombind_row(), which is all that is left of the binding inSqliteResultImpl. The comment of the interface says that a source must not leave by the longjmp of an R error, which would leave the result ready on a statement that was reset and only partly bound; the list source reads its vectors with R's API directly, as the result did before, which fails only for an ALTREP vector whose data pointer can't be taken.On the R side,
db_bind()getsis_unnamed_placeholders()andmatch_placeholders()from #795, for the Arrow bind to share later. Unlike #795's version,match_placeholders()takes the parameters rather than their names, and counts the unused ones withseq_along(params)asdb_bind()did. #795 counted them withseq_along(param_names), which turned "Named parameters not used in query: " into "Query does not require parameters." for an unnamed list bound to a query without placeholders. Somatch_placeholders()takes any object whose names are matched, and the Arrow bind of pull request 11 will pass, for example, the schema's namedchildrenrather than a vector of column names.What a reviewer may want to check
cpp11::list, which protects the vectors across the fetches that bind the later sets, as theparams_member of the result did. A new bind, or a first set that fails, destroys the source and releases the list, as before. Values are bound withSQLITE_TRANSIENT, so the statement never points into R memory. A new test binds vectors that only the result refers to and callsgc()between fetches; the same bind also passed undergctorture().std::runtime_errorfor a value it can't bind, andbind_row()turns it into astep_errorwithSQLITE_ERROR, which is what fix: A fetch returns its rows when the step past its last row fails #850'sbind_parameter_pos()threw. Soread_ahead()still keeps the error of a later set for the next fetch, and the fetch returns its rows. feat: Implement the DBI Arrow interface natively #795's list source calledcpp11::stop()there, which bypassedread_ahead().step_errorstays private toSqliteResultImpl.cpp, and the interface does not depend on it.bind()replaces the source, and onlybind()and the fetches use it, all under fix: Never restart a statement after an error indbFetch()ordbBind()#830's guard, so a handler can't replace the source while a fetch or a bind uses it. A new test pins that adbBind()from a warning handler of a fetch is refused.INSERT(40 ms), anUPDATEthat changes no row (30 ms) and aSELECTper set that returns the rows (70 ms); 1M rows through theUPDATEtake 0.29 to 0.30 s at best on both builds.Left out
The Arrow parameter source and its R entry point (pull request 11 of the plan),
executions(), theholds_r_objects()method that #795's interface has for reading streams on other threads (pull request 15), and everything else Arrow.Tests
The first commit adds
test-dbBind.R, which pins the messages for named, unnamed and missing parameters, including an unnamed list bound to a query without placeholders, the messages for values that can't be bound, parameter sets that return several rows, none, or that are empty, a later set that fails to bind after earlier sets wrote to the database, rebinding, bound vectors across fetches, and the refused bind from a handler. A later set that fails to bind in a fetch, which returns the earlier rows and raises from the next fetch, was already pinned intest-read-ahead.Randtest-dbSendQuery.R. The new tests pass on #830's head (aa07034) as well as on this branch, and eachtest_that()block passes on its own afterpkgload::load_all().devtools::test()passes except for the three errors intest-httpvfs.Rthatmainhas as well (#832, #837).R CMD check --no-manualpasses its tests, with one NOTE for the.gitfile that a git worktree puts in the built tarball.Stack
Based on #830 (
claude/fix-error-mid-result), which is based on #850. Next in the new stack: owning results through a shared pointer, and vendoring nanoarrow.Review
The clean review found nothing above Low; its two points are answered by comments in c352631. See the accepted limitations.
https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Generated by Claude Code