Repository navigation
Conversation
…row parameters `bind_arrow_stream()` binds a dictionary, such as a factor, by the values its indices point to, with indices of any integer type, for every value type that binds on its own. A null index or a null value binds NULL, an index out of range fails with its parameter and row. The offsets of each string or binary value are checked, since validation checks only the first and the last one, so that negative, decreasing or out-of-range offsets fail rather than read out of bounds. A value beyond SQLite's length limit fails with its size, parameter and row before its data is read. `connection_limit_length()` lowers the limit for the tests. A stream of RSQLite that reads the result it would be bound to, directly or through the parameters of other results, fails up front, before its schema reads any rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
The CI's auto-update regenerated `src/SqliteParamSource.dd` and `src/cpp11.dd` with GCC, whose dependency output indents continuation lines by one space, which the filter in `src/Makevars.deps` does not drop, so the files gained hundreds of absolute and vendored paths (#836). This restores them as they were at 944a0be and keeps the auto-update's formatting of `src/SqliteParamSource.cpp`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
|
Review of this pull request at 944a0be, by a Claude Code reviewer with clean context that read the descriptions of #867 and #866, the diff What was run
What holds
HighNone. MediumNone. Low
Generated by Claude Code |
…ded chain A dictionary whose values are of the null type skipped the check of its indices, so an index out of range bound NULL without an error; the index is now checked before a null-type value binds NULL. A test binds the first result of a chain to the stream at its end once the first stream has ended, which is allowed and reads the right rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn
Superseded: Accepted limitationsSuperseded by this newer copy. The clean review of 944a0be found nothing above Low: dictionaries of every index and value type, invalid offsets and lengths, and cycles of up to 200 results behave as described; AddressSanitizer and valgrind are clean on the tests and on reproducers for each; binding a large utf8 stream shows no slowdown beyond noise;
Generated by Claude Code |
Question: guard against an Arrow producer whose last offset points past its data buffer?The offsets of each text or binary value are checked against the array's last offset (
If nobody decides, nothing changes, and the code comment stays the record. Generated by Claude Code |
Question: detect a self-binding cycle through a stream implemented in R as well?The check for self-binding follows RSQLite's own streams (
If nobody decides, such a cycle keeps failing at the first row. Generated by Claude Code |
Question: read SQLite's length limit once per bind instead of once per text or blob value?Each text or blob value reads the connection's length limit with
If nobody decides, the limit is read per value. Generated by Claude Code |
Superseded: Accepted limitationsSuperseded by the copy of 2026-11-29. The clean review of 944a0be found nothing above Low: dictionaries of every index and value type, invalid offsets and lengths, and cycles of up to 200 results behave as described; AddressSanitizer and valgrind are clean on the tests and on reproducers for each; binding a large utf8 stream shows no slowdown beyond noise;
Found here, but also on
Generated by Claude Code |
…ind check A string or binary value beyond SQLite's length limit is no longer checked up front: sqlite3_bind_text64() and sqlite3_bind_blob64() refuse it before they read its data, also for a 64-bit length, and the refusal fails through check_bind() with a SqliteBindError, with the message and the state of dbBind(). The checks of dictionary indices and offsets name the row from the parameter sets counted over all arrays of the stream, as check_bind() does, and a test pins that row for an index out of range in a later array. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd8MVXyvU7qoMeruD1R
Question: should a value beyond SQLite's length limit name its size and the limit, for Arrow and list parameters alike?Merging #866 up into this pull request (5516cc3) broke #866's test "a value SQLite refuses fails with the message and state of dbBind()": this pull request checked the length of an Arrow string or binary value up front and threw its own plain error, "Can't bind the value of N bytes … beyond SQLite's length limit of L bytes.", while #866, after Adding the size and the limit to
Kirill decides. If nobody decides, the message stays as it is now, the same for both paths. Generated by Claude Code |
|
The smoke test on 8e6fe0de fails with FAIL 5 | PASS 12076, all five in Generated by Claude Code |
Accepted limitationsThe clean review of 944a0be found nothing above Low: dictionaries of every index and value type, invalid offsets and lengths, and cycles of up to 200 results behave as described; AddressSanitizer and valgrind are clean on the tests and on reproducers for each; binding a large utf8 stream shows no slowdown beyond noise; The clean review of 2026-11-29, after
Generated by Claude Code |
…nt outside the data The full validation of each array refuses offsets of a utf8 or binary value that are negative, decreasing or beyond the data, with a message that names neither the parameter nor the row and counts within the array from 0. When it fails, the rows of the array are now checked for such offsets, also of the value that a dictionary index points to, and the first one fails like a value that can't be bound, with the parameter, its name and the row counted across the stream. The check runs only after the validation has failed, so a valid array costs nothing more. Text is now bound before it is checked for NUL bytes and UTF-8, so that a value beyond SQLite's length limit fails with SQLITE_TOOBIG before its data is read, as blobs already did. Ported from #867. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Pull request 12 of the Arrow rework plan. It stacks on #866 (bind the rows of an Arrow stream to a statement), which stacks on #865, #864, #863, #862, #861, #860, #859, #857, #856, #855, #830 and #850. It picks up what #866 left to it: dictionaries, 64-bit lengths and self-binding.
What changes
All of it is behind the internal
bind_arrow_stream()of #866; no DBI method calls it yet, and the defaultdbBind()path is unchanged.Dictionaries. A dictionary-encoded column, such as a factor of a data frame converted by nanoarrow, binds the value its index points to, for every value type that #866 binds on its own (text, blobs, integers, reals, times and so on, also their large variants), with indices of any integer type from int8 to uint64. A null index and a null value of the dictionary bind NULL; unused levels don't matter. The index is checked also for a dictionary of the null type, whose values all bind NULL. Validation of an array doesn't look at the indices, so each index is checked at its row: one that is negative or beyond the dictionary fails with "Can't bind the dictionary index 2 of parameter 1 in row 2, out of range for 2 values." (a uint64 index shows its unsigned value) before anything is read. A dictionary of values that can't be bound fails before any row runs with the type error of #866, now naming the whole dictionary type. The slicing of #866 carries over: the index array and the dictionary each add their own offset.
Offsets and lengths. nanoarrow's default validation, which
ArrowArrayViewSetArray()runs on each array, checks only the first and the last offset of a string or binary array. Each value of utf8, large utf8, binary and large binary (also as dictionary values) now has its own two offsets checked before it is read: offsets that are negative, decreasing or beyond the data fail with "Invalid Arrow parameters: the offsets of parameter 1 in row 2 point outside its data." A value longer than the connection'sSQLITE_LIMIT_LENGTH(by defaultSQLITE_MAX_LENGTH, whichsrc/Makevarssets to 2147483647 bytes) is refused bysqlite3_bind_text64()orsqlite3_bind_blob64()before its data is read, and fails through the sharedcheck_bind()ofdbBind(), with its message and state: "Can't bind parameter 2 in row 1: string or blob too big." Sizes are 64-bit throughout, so a large value isn't truncated into a small one. At the default limit only large utf8 and large binary values can exceed it, since 32-bit offsets can't; a limit lowered withsqlite3_limit()applies to all four types. Whether that message should also name the size and the limit is an open question. The check of the offsets costs two loads and a few comparisons per value, full validation throughArrowArrayViewValidate()would also have covered dictionary indices, but it walks every chunk's dictionary again and reports neither the parameter nor the row. Rows are counted across the arrays of the stream, from 1, null struct rows included.Self-binding. Binding a result to an Arrow stream of RSQLite that reads the same result, from this execution or an earlier one, fails up front with "Can't bind a result to an Arrow stream of its own rows." A chain of results whose parameters read each other's streams, which would recurse into the busy guard or leave the results holding each other, fails with "Can't bind a result to an Arrow stream of a result whose parameters read the rows of this one."
DbResult::check_arrow_params()follows the chain: from the stream to the result it reads (a newarrow_stream_result()recognizes RSQLite's streams by theirreleasecallback), then to the Arrow stream that result is bound to, and so on, with a set of visited results.bind_arrow_stream()calls it through a newresult_check_arrow_params()before reading the schema, since the schema of a stream of RSQLite fetches the first chunk;DbResult::bind_arrow()calls it again. A refused stream is neither read nor taken over, and the result keeps its previous bind. Before, a result bound to its own stream failed only at the first row, through #864's check of the execution, after the schema had fetched a chunk. A stream that has ended no longer reads its result, so it doesn't count as a link: binding the first result of a chain to the stream at its end is allowed and runs once the first stream has ended, because the rows that result would read are already in the chunks the next result holds, and nothing reads the first result again. Reading the schemas along a chain fetches ahead, so a chain of five results over three rows in chunks of one row is already in that state, and the first result then reads the chain's rows without recursion.Test hook. A new internal
connection_limit_length(con, n)setsSQLITE_LIMIT_LENGTHand returns the previous limit, so that the tests use 31-byte values instead of gigabytes. SQLite doesn't go below 30 bytes.Deliberately left out
dbBindArrow()and the other DBI methods: pull request 17.Tests
tests/testthat/test-arrow-bind-checks.R, through nanoarrow, with helpers inhelper-arrow.Rthat build dictionaries and string arrays by hand, without validation:INSERTafter the first rowtest-arrow-bind.Rkeeps its test of types that can't be bound, with a date64 column in place of the factor. Everytest_that()block of both files passes on its own afterload_all().devtools::test()withNOT_CRAN=truepasses except five expectations intest-dbBind.Rfrom #868, which wait on the question on the state after a faileddbBind(). valgrind (--leak-check=full) reports no errors and nothing lost fortest-arrow-bind-checks.Randtest-arrow-bind.R; an AddressSanitizer and UBSan build reports nothing from the new code (only the knownmemcpy(…, NULL, 0)infetch_blob()noted on #866).https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn (merge of 3.54.1: https://claude.ai/code/session_01Hr1rd8MVXyvU7qoMeruD1R)
Generated by Claude Code