Skip to content

feat: Check text read into a character column with dbConnect(check_utf8 = TRUE) - #846

Merged
krlmlr merged 13 commits into
claude/utf8-infrafrom
claude/utf8-text-checks
Nov 13, 2026
Merged

krlmlr merged 13 commits into
claude/utf8-infrafrom
claude/utf8-text-checks

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

As asked on #799: checks of the text read into a character column, behind a dbConnect() argument that defaults to the current behavior, on top of the UTF-8 infrastructure of #845. Unlike #799, which checked only blobs that turn up in a text column, this also checks text values, the more common case.

The argument. dbConnect() gains check_utf8, which defaults to FALSE, must be TRUE or FALSE (anything else stops with an error), and is kept with the connection. There is no R option: the maintainer decided on #829 for an argument only.

check_utf8 = FALSE, the default. Every fetch runs the code of main: text with a NUL byte is cut silently, text that is not valid UTF-8 is returned marked as UTF-8, and a blob in a character column is read as text, so X'00ff' comes back as "". Three regression tests pin this, and they pass against main too.

check_utf8 = TRUE. A text or blob value read into a character column is read with its byte length (sqlite3_column_text() or sqlite3_column_blob(), then sqlite3_column_bytes()) and validated. A value that is not valid UTF-8, or holds a NUL byte, becomes NA, with one warning per column and fetch that counts the replaced values: "Column x: 2 values are not valid UTF-8 or contain NUL bytes, NA is returned". The fetch that returns a row raises the warning; a peek with dbFetch(n = 0) or dbColumnInfo() does not. A blob read with sqlite3_column_blob() is not transcoded in a UTF-16 database and keeps its storage class after a peek. Integer and real values in a character column, and blob columns, are read as before. The new warning passes its message as an argument, not as a printf format.

Not changed here. The mixed-type warning still passes the column name inside its format, its text is not marked as UTF-8, and fetch_blob() still hands a NULL pointer to memcpy() for an empty blob; all three belong to the open question on format strings. dbConnect() on an existing connection does not carry check_utf8 over here; #852, stacked on this pull request, makes a clone keep it, together with extended_types and bigint. The checks apply to every query on the connection, including RSQLite's own, so dbListTables() reports a table name that is not valid UTF-8 as NA. The new warning, like the mixed-type warning, is not marked as UTF-8.

Tests. tests/testthat/test-check-utf8.R covers invalid text, text with a NUL byte, invalid and valid blobs, empty text and blobs, a fetch in chunks where a later chunk holds the bad values, a peek between chunks, a UTF-16 database, and a column name containing %s%d; undoing each part of the change makes them fail. R CMD check --no-manual was rerun after dropping the option (only vignette and hidden-directory warnings of the local build tree), and the new and changed tests pass under AddressSanitizer and UBSan. Fetching 8 million strings takes as long as on main with the default, and 7% to 18% longer with check_utf8 = TRUE, depending on the data; many small fetches of wide results cost the same as on main.

A clean review found nothing above Low; four of its six findings are fixed, and what remains is under Accepted limitations. The tests' fixtures live in helper files, so every block runs on its own after load_all().

https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn


Generated by Claude Code

…tf8 = TRUE)`

The new `check_utf8` argument of `dbConnect()` defaults to `getOption("RSQLite.check_utf8", FALSE)` and is kept with the connection.
With `check_utf8 = FALSE`, the default, every fetch behaves as before:
text with a NUL byte is cut silently, text that is not valid UTF-8 is returned marked as UTF-8,
and a blob in a character column is read as text, so that `X'00ff'` comes back as `""`.

With `check_utf8 = TRUE`, a text or blob value that is read into a character column is read with its byte length and validated.
A value that is not valid UTF-8, or that holds a NUL byte, becomes `NA`,
with one warning per column and fetch that counts the replaced values:
"Column `x`: 2 values are not valid UTF-8 or contain NUL bytes, NA is returned".
The fetch that returns a row raises this warning, a peek with `dbFetch(n = 0)` or `dbColumnInfo()` does not.
A blob is read with `sqlite3_column_blob()`, so it is not transcoded in a UTF-16 database and keeps its storage class after a peek.
Integer and real values in a character column, and blob columns, are read as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Review of this pull request at 577784d, against its base fe9f927, by a Claude Code reviewer with clean context that read the description, the maintainer's request on #799, the two linked questions on #829, the diff fe9f9276..577784d0, the fetch code around it (DbDataFrame, DbColumn, DbColumnStorage, SqliteColumnDataSource, SqliteResultImpl, the R dbConnect() methods and sqliteRemote()) and the Arrow fetch code of #795 at 68a0575; built and installed main (3b7bea3), this pull request, a copy instrumented with AddressSanitizer and UBSan, and ten variants that each change one part; ran the same set of fetches against main and this pull request and compared the results; ran devtools::test() and R CMD check --no-manual, the new tests against main and under the sanitizers, and benchmarks; and posted nothing itself. "Confirmed" means reproduced by running code, "by reading" means not run. Line links point to 577784d unless they say otherwise.

What was run

  • Builds: main; this pull request; this pull request with -fsanitize=address,undefined, with the sanitizer runtimes preloaded into R; and 10 variants that each undo or change one part.
  • devtools::test() with NOT_CRAN=true on this pull request and on main, looking at every result of every test, and R CMD check --no-manual on a tarball built from a clean export.
  • A set of 443 fetch scenarios, described under "What holds", run four times: against main, and against this pull request with the option unset, with RSQLite.check_utf8 = FALSE and with TRUE, compared with identical() and on their serialized bytes.
  • Reproducers for check_utf8 = TRUE: UTF-16 text that is not valid and UTF-16 text with a NUL; mixed-type columns and chunked fetches with peeks between them; column names containing %n and non-ASCII characters; zeroblob() after peeks, and parameters with several rows; running out of memory under PRAGMA hard_heap_limit; options(warn = 2), and a warning handler that clears the result; cloned connections and invalid argument values.
  • R/cpp11.R and src/cpp11.cpp regenerated with cpp11::cpp_register(), the Rd files with roxygen2 8.1.1.9000, and the compiler's list of headers compared with src/SqliteColumnDataSource.dd.
  • Benchmarks, alternating the builds: 8 million strings fetched with dbGetQuery(), and 5000 calls of dbFetch(n = 1) on a table with 200 columns.
  • A trial merge of 577784d with feat: Implement the DBI Arrow interface natively #795 at 68a0575, using git merge-tree.

What holds (Confirmed unless marked otherwise)

  • The default is unchanged. With the option unset, and with RSQLite.check_utf8 = FALSE, every value, encoding mark and warning is identical to main across all 443 scenarios. They cover text, text that is not valid UTF-8, text with a NUL, blobs (including X'', zeroblob() and X'00ff'), numbers and NULL; columns without a type and of type TEXT, BLOB and DATE, in default, UTF-8, UTF-16le and UTF-16be databases; reads with dbGetQuery() (also with n and with several rows of parameters) and dbReadTable(); dbFetch() in chunks of 1, 2 and 3 rows, with no peek or with a dbFetch(n = 0) or dbColumnInfo() peek between chunks, and dbColumnInfo() after the last row; extended_types = TRUE; and a column of 5000 rows with mixed types.
  • Large fetches are as fast as on main by default: 8 million strings took 4.58–5.03 s on main and 4.31–4.80 s with this pull request, best of 7 in each of three rounds. L1 covers many small fetches.
  • With the checks on, only the expected values change: values that are not valid UTF-8 become NA; values that held a NUL become NA, both text that the default cuts at the NUL and blobs; blobs in UTF-16 databases are read as bytes; and after a peek, the fetch raises the mixed-type warning again, because the blob keeps its storage class, the doubled warning that fix: Validate blobs that are read into a text column #799 accepted as behaving as on main.
  • The SQLite calls come in the right order: sqlite3_column_type(), then sqlite3_column_text() or sqlite3_column_blob(), then sqlite3_column_bytes(), as SQLite asks (by reading). UTF-16 text with a lone surrogate, and UTF-16 text with a NUL, become NA.
  • NULL pointers from SQLite are handled: X'', zeroblob(0), '' and CAST(X'' AS TEXT) give "". Running out of memory gives the error "out of memory" rather than "", also after dbFetch(n = 1) and a peek, for zeroblob(100000000) under hard_heap_limit = 50000000 and for an 8-million-character text in a UTF-16 database under a limit of 30 or 45 MB. In that UTF-16 case, main and check_utf8 = FALSE still abort R in Rf_mkCharCE(NULL), as before.
  • The warnings behave as described: one per column and fetch, with the right count, also for parameters with several rows; none from dbFetch(n = 0) or dbColumnInfo(); column names such as x%n%s and ä€ are printed as they are; with options(warn = 2) the warning becomes an error after the chunk has been read, as the mixed-type warning does; a warning handler that calls dbClearResult() does not crash under ASan.
  • The plumbing is consistent: R/cpp11.R, src/cpp11.cpp, man/SQLite.Rd and NAMESPACE regenerate without a diff; src/SqliteColumnDataSource.dd matches the compiler's list of headers; sqliteRemote() passes check_utf8 on through ...; a result copies the setting from its connection when it is created; the member initializers follow the order of declaration (by reading).
  • The tests catch what they should: the three check_utf8 = FALSE tests pass against main; four others pass on both builds because they guard against regressions; the rest fail or error on main. Each variant that undoes one part of the change fails tests: blobs read with sqlite3_column_text() 8 (in the UTF-16 test), the n == 0 return removed 2, the warning text passed as a printf format 1, text not checked 15, blobs not checked 14, the option not used as the default 3, invalid values counted only once 9, NA for a NULL pointer 2. The one exception is L2.
  • The suite and R CMD check pass, apart from errors this environment causes: devtools::test() gives 10465 passed, 0 failed, 62 skipped, with the same four errors as main (10366 passed): three test-httpvfs.R tests that cannot open the local HTTP database here, and "interrupt in busy handler" in test-dbConnect.R, which needs RSQLite installed for a callr subprocess; testthat counts only one of them, because the HTTP VFS tests end with a warning (see test: Run the HTTP VFS tests for real, and make their errors fail the check #832 and testthat hides a test's error when the test records another result after it #837). R CMD check --no-manual: Status OK.
  • ASan and UBSan find nothing in the new code: test-check-utf8.R and eight related test files pass, and the reproducers and all scenarios, with the checks on and off, give no report in the new code. The only report is fetch_blob() passing NULL to memcpy(), which the description lists as not changed.
  • macOS and Windows need nothing new (by reading): the change uses only standard R API (Rf_mkCharLenCE(), R_BlankString, NA_STRING) and int64_t, which these files already use, and the new override is declared like its neighbours, so clang's -Winconsistent-missing-override does not apply.

High

None.

Medium

None.

Low

L1. The default path makes an R string from every column name on every fetch. src/DbDataFrame.cpp#L69-L73, src/DbColumn.cpp#L86. Confirmed. warn_invalid_strings() takes a const cpp11::r_string&, and boost::bind passes it the column name as a std::string, so each column of each fetch allocates a CHARSXP and a protected cpp11::sexp, before the early returns for n == 0 and for a count of zero, so also with check_utf8 = FALSE. The cost shows only with many small fetches of wide results: for 5000 calls of dbFetch(n = 1) on a table with 200 columns (four alternating rounds of 15, minimum of each round), main took 1.55–1.62 s, this pull request 1.68–1.72 s, and a variant whose parameter is const std::string& 1.51–1.65 s, which passes the new tests. Suggested fix: take const std::string&, since the names are already UTF-8 bytes from sqlite3_column_name(), or check the count before converting the name.

L2. No test checks that a value is read by its length. src/SqliteColumnDataSource.cpp#L125, tests at tests/testthat/test-check-utf8.R#L180. Confirmed. With Rf_mkCharLenCE(bytes, size, CE_UTF8) replaced by Rf_mkCharCE(bytes, CE_UTF8), all 17 tests still pass: values read from a table come out of OP_Column followed by NUL bytes, and every value with a NUL inside is already NA. A blob from a bound parameter has no NUL after it: with that variant, dbGetQuery(con, "SELECT CASE WHEN column1 = 1 THEN 'a' ELSE ? END AS x FROM (VALUES (1), (2))", params = list(blob::blob(charToRaw("abcdefgh")))) returns "abcdefgh" followed by six bytes of heap memory, where this pull request returns "abcdefgh". Suggested fix: add this query as a test; it fails on that variant, and ASan would also catch the overread.

L3. dbConnect() on an existing connection drops check_utf8, even when it is given. R/dbConnect_SQLiteConnection.R#L8-L11. Confirmed. The description says the clone does not carry the setting over. In addition, dbConnect(con, check_utf8 = TRUE) silently ignores the argument, because ... is not passed on, and the clone takes the value of the R option at that moment, so a connection opened with check_utf8 = TRUE clones to a connection without checks unless the option is set. extended_types and bigint behave the same way on main. Suggested fix: pass check_utf8 = drv@check_utf8 (and extended_types and bigint) when cloning, and let ... override them; otherwise state the behavior in the documentation (L6).

L4. Any setting other than exactly TRUE silently turns the checks off. R/dbConnect_SQLiteDriver.R#L111. Confirmed. isTRUE() turns "TRUE", "yes", 1, NA and c(TRUE, TRUE) into FALSE, also for the option: options(RSQLite.check_utf8 = "TRUE"), which is what a value read from an environment variable gives, produces con@check_utf8 == FALSE without any message. The option exists so that code that opens connections indirectly can turn the checks on, so a setting that silently does nothing is the least helpful result. extended_types behaves the same way. Suggested fix: accept only TRUE and FALSE, and stop with an error otherwise.

L5. After merging with #795, the data frame path and the Arrow path will check differently. src/SqliteResultImpl.cpp#L26; on #795 at 68a0575: src/SqliteArrowColumn.cpp#L355-L374, src/SqliteArrowColumn.cpp#L510-L521, src/SqliteResultImpl.cpp#L475-L480. By reading, except the trial merge. The textual conflicts are small: the includes of src/SqliteColumnDataSource.cpp, the initializer list of SqliteResultImpl, the table of entry points in src/cpp11.cpp (regenerated anyway), and src/utf8.h, added on both branches, which belongs to #845; fetch_rows() and peek_first_row() merge cleanly with check_utf8_. The difference in behavior is larger: the Arrow path of #795 always checks utf8 columns, with the same rules (invalid UTF-8 or a NUL byte; blobs read as bytes), turns those values into nulls, and warns once per column and execution, without a count, with the text "values of type blob that are not valid UTF-8, or hold a NUL byte, are NULL"; ensure_arrow_columns() never sees check_utf8. Once both are merged, dbGetQuery() returns invalid strings by default while dbGetQueryArrow() returns nulls, and with check_utf8 = TRUE both return missing values but with two differently worded warnings. Arrow cannot hold invalid UTF-8 in a utf8 column, so always checking on that path is defensible. Suggested fix: decide on #829 whether check_utf8 covers only the data frame path, and say so in its documentation; whichever pull request merges second aligns the two warnings, in wording and in counting per fetch.

L6. The documentation and the description leave out a few behaviors. R/dbConnect_SQLiteDriver.R#L42-L48, src/DbColumn.cpp#L98-L108. Confirmed except where marked. With check_utf8 = TRUE, valid blobs in a UTF-16 database also come back differently (X'6162' is "ab" with the checks and "扡" without); the description says this, the @param text does not. The check applies to every query on the connection, including the ones RSQLite runs itself: dbListTables() lists a table whose name is not valid UTF-8 as NA, with a warning about a column called name, and dbReadTable(row.names = TRUE) fails with "missing values in 'row.names' are not allowed" when a row name is not valid. The new warning passes its text as native bytes rather than marking it as UTF-8, just like the mixed-type warning (by reading); the description lists only the mixed-type warning as unmarked. The speed claim depends on the data: for 8 million strings with non-ASCII characters, check_utf8 = TRUE took 7–18% longer than the default on this noisy machine, depending on whether the minimum or the median is used; the description says about 7%. Suggested fix: add the UTF-16 sentence and the clone behavior to the @param text, list the new warning next to the mixed-type warning as not marked as UTF-8, and give the speed as a range or name the data it was measured on.


Generated by Claude Code

…about

`DbColumn::warn_invalid_strings()` took the column name as a `cpp11::r_string`, converted from the `std::string` that `DbDataFrame::get_data()` holds.
Each column of each fetch therefore allocated a CHARSXP and a protected `cpp11::sexp`, also with `check_utf8 = FALSE`.
It now takes a `const std::string&`, the UTF-8 bytes from `sqlite3_column_name()`, and builds nothing until it has something to warn about.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Values read from a table are followed by NUL bytes, so the existing tests also passed when a checked value was read up to its first NUL byte instead of by its length.
The new test reads a bound blob, which has no NUL byte after it, into a character column.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
`dbConnect()` turned any `check_utf8` other than `TRUE` into `FALSE` with `isTRUE()`, so `"TRUE"`, `1`, `NA` or `c(TRUE, TRUE)` silently turned the checks off.
This also applied to the `RSQLite.check_utf8` option, which is meant for code that opens connections indirectly and where a typo would go unnoticed.
It now accepts only a single non-NA logical and otherwise fails with an error that names both the argument and the option.
`extended_types` and `bigint` are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
In a UTF-16 database, a blob read into a character column is taken as UTF-8 bytes with the checks on, and transcoded from UTF-16 with them off.
The checks apply to every query on the connection, including the ones RSQLite runs itself, so `dbListTables()` reports a table name that is not valid UTF-8 as `NA`.
`dbConnect()` on an existing connection does not carry the setting over, nor `extended_types` or `bigint`, but reads the option again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
Every test_that() block now runs on its own after load_all().
The six fixtures moved to tests/testthat/helper-check-utf8.R, each with a comment.
with_warnings(), invalid_message(), local_check_con() and create_check_table() got a utf8 prefix,
because helper names are shared by all test files:
utf8_with_warnings(), utf8_invalid_message(), local_utf8_check_con() and create_utf8_check_table().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE

krlmlr commented Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by the current copy.

The clean review found nothing above Low. Its findings L1, L2, L4 and L6 are fixed: the column name is no longer converted to an R string on every fetch, so the default path is back to the cost of main (ae50fc7); a test with a bound blob checks that a value is read by its length (b805c2a); check_utf8 and the option RSQLite.check_utf8 accept only TRUE or FALSE and stop otherwise (448c8e1); and the documentation covers blobs in UTF-16 databases, RSQLite's own queries, and clones (a0e1409). The fixtures of the tests moved into helper files, so every block runs on its own after load_all() (8fc168c). These remain:

  • R/dbConnect_SQLiteConnection.R#L8-L11: dbConnect() on an existing connection does not carry check_utf8 over, and ignores it when given, reading the option again instead; extended_types and bigint behave the same way on main. Relevance: low; reviewer's confidence: high. (recorded)
  • src/SqliteResultImpl.cpp#L26: once feat: Implement the DBI Arrow interface natively #795 is merged too, the Arrow path checks utf8 columns always, since Arrow cannot hold invalid UTF-8, while the data frame path follows check_utf8; with the checks on, the two paths warn in different words and count differently. Whichever of the two pull requests merges second aligns the warnings, and when the Arrow stack uses the shared validator is an open question on #829. Relevance: medium; reviewer's confidence: high.

Generated by Claude Code

krlmlr and others added 4 commits November 11, 2026 17:25
The CI's auto-update regenerated `src/cpp11.dd` and `src/utf8.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 and keeps the auto-update's formatting of `src/utf8.cpp`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd3gjmufoKCWVDBPCgE
The `RSQLite.check_utf8` option is dropped:
`check_utf8` now defaults to `FALSE` and is set only by the argument.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd432Aef98ibnZSSsYn

krlmlr commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Review of 6041aae in this pull request, by a Claude Code reviewer with clean context that read the one-commit diff, the pull request description, the clone method and the tests, built the commit in a detached worktree, ran the tests and an R CMD check, and wrote its own reproducers; it posted nothing on GitHub.

What was run

  • test-check-utf8.R via pkgload::load_all() and test_file(): all pass. test-dbConnect.R: all pass except "interrupt in busy handler", whose callr subprocess needs RSQLite installed (an artifact of load_all(), not of the change); it passes in the installed-package run of R CMD check.
  • Reproducer: clone with dbConnect(con) from a connection made with check_utf8 = TRUE, bigint = "character"; validation with NA, "a", c(TRUE, FALSE), NULL, logical().
  • R CMD check --no-manual --ignore-vignettes on the built tarball: tests OK, one NOTE (hidden .git in the worktree). No vignette WARNINGs appeared because vignettes were skipped.

What holds

  • No reference to the RSQLite.check_utf8 option remains in R/, man/, tests/, vignettes/, NEWS.md or DESCRIPTION; the only hit for "check_utf8" outside these files is a comment in tests/testthat/helper-check-utf8.R, unrelated to the option.
  • The default is FALSE in both the R signature and man/SQLite.Rd; the two agree. The roxygen text and the Rd text match.
  • Validation rejects NA, a string, a number, a vector of length 2, NULL and a zero-length logical, each with "check_utf8 must be TRUE or FALSE." (Confirmed.) The old option text is gone from the message and the test.
  • Cloning: dbConnect(con) on a connection with check_utf8 = TRUE gives check_utf8 = FALSE (and bigint = "integer64"), so an unset argument resets it. This matches how bigint and extended_types behave on this branch, and the documentation says so. (Confirmed.)
  • Removed tests: the two option tests tested only the option and the option-versus-argument override; both behaviors no longer exist. The argument validation and the FALSE default are still tested; check_utf8 = TRUE set through the argument is covered by the remaining blocks.

High

None.

Medium

None.

Low

  1. Clone still resets check_utf8, and fix: dbConnect() on a connection keeps bigint, extended_types and check_utf8 #852 will not carry it either unless it is extended. R/dbConnect_SQLiteConnection.R passes only vfs, flags and loadable.extensions. dbConnect(con) therefore returns a connection with check_utf8 = FALSE, the same as for bigint and extended_types. Branch claude/clone-keeps-options (fix: dbConnect() on a connection keeps bigint, extended_types and check_utf8 #852) changes the clone to carry bigint and extended_types from the original (diff read, not run); its defaults list has no check_utf8, so whichever of the two pull requests merges second leaves check_utf8 as the one setting a clone silently drops, with the documented sentence here ("does not carry this setting over") then wrong for the other two but right for this one. This is consistent and documented on this commit, so it is a note about the merge order, not a defect. Suggested fix: when fix: dbConnect() on a connection keeps bigint, extended_types and check_utf8 #852 lands, add check_utf8 = drv@check_utf8 to its defaults and drop the sentence from ?dbConnect; or say in fix: dbConnect() on a connection keeps bigint, extended_types and check_utf8 #852 that it is left out on purpose.

  2. No test pins that a clone does not carry check_utf8. tests/testthat/test-check-utf8.R tests the default, but nothing tests the documented clone behavior, which the removed option tests did not test either (they only covered the option). The documented sentence can therefore change without a test failing. (by reading) Suggested fix: one block that clones a file-backed check_utf8 = TRUE connection and expects FALSE, or, if fix: dbConnect() on a connection keeps bigint, extended_types and check_utf8 #852 is extended as in finding 1, one that expects TRUE.

  3. The error message does not name the received value or dbConnect(). R/dbConnect_SQLiteDriver.R says only "check_utf8 must be TRUE or FALSE." This is the same style as the nearby checks, so it is fine; noting only that stopc() is called with the dbConnect_SQLiteDriver frame hidden, as for the other arguments. (by reading) Suggested fix: none needed.


Generated by Claude Code

krlmlr commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by the current copy.

The first clean review found nothing above Low; its findings L1, L2, L4 and L6 are fixed (ae50fc7, b805c2a, 448c8e1, a0e1409, 8fc168c). As decided, 6041aae makes check_utf8 a plain dbConnect() argument defaulting to FALSE, without the RSQLite.check_utf8 option; its clean review found nothing above Low, no reference to the option remains, and R CMD check passes. These remain:


Generated by Claude Code

krlmlr commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Resolved: carry check_utf8 over when dbConnect() clones a connection?

Fixed by #852, stacked on this pull request: a clone now keeps check_utf8 along with bigint and extended_types.

dbConnect() on an existing connection passes on only vfs, flags and loadable.extensions (clone code at 6041aae6), so a clone of a connection opened with check_utf8 = TRUE has the checks off, as it falls back to integer64 and untyped dates for bigint and extended_types. The documentation of check_utf8 says so, and no test pins it. #852 makes a clone keep bigint and extended_types, so whichever of the two merges second would leave check_utf8 as the one setting a clone drops, unless it is added there.

con <- dbConnect(RSQLite::SQLite(), tempfile(), check_utf8 = TRUE)
clone <- dbConnect(con)
clone@check_utf8
# FALSE, as the second review confirmed; carried over, it would be TRUE

If nobody decides, the recommended option holds.


Generated by Claude Code

krlmlr commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Question: make the UTF-8 checks of the data-frame path and the Arrow path agree?

The data-frame path checks text only when the connection was opened with check_utf8 = TRUE (src/SqliteResultImpl.cpp#L26), while the reworked Arrow stack (#860) checks utf8 columns always, since an Arrow utf8 column can't hold invalid UTF-8. Once both are merged, dbGetQuery() returns invalid strings by default while dbGetQueryArrow() returns nulls; with the checks on, both return missing values, but the two paths warn in different words and count the values differently.

If nobody decides, the recommended option holds.


Generated by Claude Code

krlmlr commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Superseded: Accepted limitations

Superseded by the new copy.

The first clean review found nothing above Low; its findings L1, L2, L4 and L6 are fixed (ae50fc7, b805c2a, 448c8e1, a0e1409, 8fc168c). As decided, 6041aae makes check_utf8 a plain dbConnect() argument defaulting to FALSE, without the RSQLite.check_utf8 option; its clean review found nothing above Low, no reference to the option remains, and R CMD check passes. These remain:


Generated by Claude Code

krlmlr commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

The first clean review found nothing above Low; its findings L1, L2, L4 and L6 are fixed (ae50fc7, b805c2a, 448c8e1, a0e1409, 8fc168c). As decided, 6041aae makes check_utf8 a plain dbConnect() argument defaulting to FALSE, without the RSQLite.check_utf8 option; its clean review found nothing above Low, no reference to the option remains, and R CMD check passes. Since then, main has been merged into this pull request (e3c2551), and #852, stacked on it, makes a clone keep check_utf8. These remain:


Generated by Claude Code

@krlmlr
krlmlr merged commit e64138c into main Nov 13, 2026
8 checks passed
@krlmlr
krlmlr deleted the claude/utf8-text-checks branch November 13, 2026 19:45
@krlmlr krlmlr mentioned this pull request Nov 14, 2026
16 of 22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants