Repository navigation
Conversation
…lt's `result_create()` tags the external pointer of a result with the symbol `RSQLite_result`. The conversions to `DbResult*` and `SqliteResult*`, `result_release()` and `result_valid()` fail with "Invalid result set" for a pointer without that tag, such as a connection's. Before, they read the connection's memory as a result's, and some crashed R. A result saved and restored keeps the tag and still fails with "Invalid result set". Closes #876. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
`dbIsValid()` returns `FALSE` again and `dbClearResult()` returns `TRUE` with the "Expired" warning for a result made with `new()` or saved by an RSQLite that didn't tag its results. Other untagged pointers still fail with "Invalid result set". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Closed
3 tasks
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
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 code that uses the DBI methods. The internal entry points that take a result, such as
result_fetch(),result_has_completed(),result_get_placeholder_names(),result_valid()andresult_release(), now fail with "Invalid result set" when given an external pointer that is not a result's, such as a connection's, instead of reading the connection's memory as a result's. Only code that calls them with:::can get there, so there is no NEWS bullet.How:
result_create()sets the tag of the result's external pointer to the symbolRSQLite_result. Theas_cpp()conversions toDbResult*andSqliteResult*insrc/RSQLite_types.h,result_release()andresult_valid()check that tag first; the conversions then keep failing for a NULL address as before. TheSqliteResult*conversion now goes through theDbResult*one with astatic_castinstead of casting the address directly. A result saved withsaveRDS()and restored keeps its tag and holds NULL, so it still fails with "Invalid result set" anddbIsValid()returnsFALSE.result_valid()andresult_release()first treat an external pointer that holds NULL as an expired result, tagged or not, sodbIsValid()still returnsFALSEanddbClearResult()still returnsTRUEwith the "Expired" warning for a result made withnew("SQLiteResult")or saved by an RSQLite that didn't tag its results. A non-pointer argument fails with "Invalid result set" in theDbResult*andSqliteResult*conversions;result_valid()andresult_release()reject it earlier, in cpp11's own conversion.Connections are not tagged here. Their entry points take
cpp11::external_pointer<DbConnectionPtr>directly rather than through one conversion, so a check would be a line in each of about ten functions insrc/connection.cpp,src/extensions.cppandresult_create(), and a new message would have to be chosen; a result's pointer passed to them still reads the result as a connection. That seems better as a separate change if wanted.Tests: a new block in
tests/testthat/test-dbClearResult.Rpasses a connection's pointer toresult_fetch(),result_has_completed(),result_get_placeholder_names(),result_valid()andresult_release(), and checks a saved and restored result; a second block checksdbIsValid()anddbClearResult()onnew("SQLiteResult")and on an untagged pointer that went throughserialize()andunserialize(), which errored before the follow-up fix. Red on the base (each call in its own callr subprocess, installed fromclaude/rb-failed-bind-state):result_has_completed(),result_rows_fetched()andresult_get_placeholder_names()crash R;result_fetch(),result_column_info()andresult_release()happen to read the busy flag as set and fail with the busy-guard message, andresult_valid()returnsTRUE. The issue's reproducer withresult_fetch()thus no longer crashes on this base, but by chance. Green with the fix: all of them fail with "Invalid result set", in process. Full suite withNOT_CRAN=true: FAIL 0, WARN 3 (locale warnings fromtest-encoding.R), SKIP 63, PASS 11000.Layer B6 of the rebuilt chain, planned in #880; based on #936. Not ported from an old PR: the issue was found by the review of #859.
Closes #876.
Coordinating session: https://claude.ai/code/session_01Hr1rd7QnTD4acgzTUihnF4
Generated by Claude Code