Repository navigation
Conversation
…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
krlmlr
force-pushed
the
claude/rb-arrow-param-checks
branch
from
December 1, 2026 10:39
bab0da7 to
fb7666d
Compare
… claude/rb-arrow-param-checks
As `arrow_int_array()` does since #970, so that the tests also hold on big-endian machines. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…efore binding it Binding first copied invalid text into SQLite before refusing it, and a huge invalid value could fail for lack of memory. Text beyond the connection's length limit now fails as SQLITE_TOOBIG unread, then text with a NUL byte or invalid UTF-8 fails, and only valid text is bound. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
…8, and restore the limit in its test with `withr::defer()` 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.
No change of behavior for users: this improves the errors of the internal
bind_arrow_stream(), which no DBI method calls yet.What changes
Offsets outside the data name their parameter and row. #967 validates every array of the stream at nanoarrow's full level, which checks every offset of utf8 and binary values. Its message names neither the parameter nor the row, and counts within the array from 0: "Invalid Arrow parameters: [3] Expected element size >= 0". When the full validation of an array fails,
SqliteArrowParamSource::check_offsets()now looks for the first row with a utf8, large utf8, binary or large binary value, also as the value of a dictionary, whose offsets are negative, decreasing or beyond the data. It fails like a value that can't be bound, with the parameter, its name and the row counted across the stream: "Can't bind parameter 1 ($x) in row 2: the offsets of its value point outside the data." This is the counterpart of #970'scheck_dictionary_indexes()for offsets, but it runs only after the validation has failed, so a valid array costs nothing more. An array that is invalid only where no row reads it, such as under a null struct row, still fails with nanoarrow's message, and so does a negative first offset, whichArrowArrayViewSetArray()refuses before the full validation runs. Since the last offset gives the size of the data, only an offset before the last one can lie beyond the data. As before, the error comes when the array is read, before any of its rows runs.Text is checked before it is bound. #967 scanned text for NUL bytes and UTF-8 before binding it, also text beyond SQLite's length limit. Text whose length exceeds the connection's current limit (
sqlite3_limit(conn, SQLITE_LIMIT_LENGTH, -1)) now fails with "string or blob too big" (RSQLite_error_toobig) without its data being read, as blobs already did throughsqlite3_bind_blob64(). Then text with a NUL byte or invalid UTF-8 fails as before, and only valid text is bound, so invalid text is never copied into SQLite. A large utf8 value that claims more bytes than its buffer holds was scanned out of bounds; it now fails unread, but only if the claimed length exceeds the limit. The Arrow C data interface carries no buffer sizes, so a claimed length within the limit over a shorter buffer can't be detected.What of #867 was already covered
check_bind(): feat: Bind parameters from an Arrow array stream #967, but untested there; tested here with the existingconnection_limit_length()hook.dbBind()in feat: Bind parameters from an Arrow array stream #967, since they need only the schema.Tests
The new
tests/testthat/test-arrow-bind-checks.R, with helpers inhelper-arrow.Rthat build struct arrays, offsets and dictionaries without validation: offsets beyond the data and decreasing at the second row for all four string and binary types and for the value a dictionary index points to; nanoarrow's message for bad offsets under a null struct row; with the length limit lowered to 30 bytes (SQLite raises any lower limit to 30), 31-byte values of utf8, large utf8, binary, large binary, a factor, and text with a NUL byte or invalid UTF-8 fail at their row withRSQLite_error_toobigafter the first row ran, while 30-byte text with a NUL byte or invalid UTF-8 fails with its own message; at the default limit, whichsrc/Makevarssets throughSQLITE_MAX_LENGTHto 2147483647 bytes, large utf8 and large binary values that claim 3e9 bytes over a one-byte buffer fail withRSQLite_error_toobig. One expectation intest-arrow-bind.Rnow expects the new offsets message. On the base, the new tests fail with nanoarrow's message for the offsets and with "the text contains a NUL byte" for text beyond the limit (red); they pass with this change (green). Everytest_that()block passes on its own afterload_all(). valgrind (--leak-check=full) reports no errors and nothing lost fortest-arrow-bind-checks.R. The full suite withNOT_CRAN=true: FAIL 0, WARN 3 (the knowntest-encoding.Rwarnings), SKIP 64, PASS 13451.Layer F9 of the rebuilt chain, planned in #880; based on #970. Ported from #867, minus what #967 and #970 already cover.
Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Generated by Claude Code