Skip to content

docs: Record what fails for backends installed against DBI without the .dbi slot - #802

Open
krlmlr wants to merge 3 commits into
claude/dbconnect-args-slotfrom
claude/dbi-slot-old-backend
Open

krlmlr wants to merge 3 commits into
claude/dbconnect-args-slotfrom
claude/dbi-slot-old-backend

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Stacked on #794. Kirill asked to understand the limitation behind "objects created by a backend that was installed against an older version of DBI … lack the slot", with an experiment that installs a backend, then the refreshed DBI, and shows what fails.

Result

Recorded in experiments/2026-11-29-dbi-slot-old-backend/, with scripts and output (R 4.5.3 on Linux; DBI main and #794; minimal backends written for the experiment and RSQLite 3.54.1, compiled from source against each DBI in a private library, each step in a fresh process). experiments/README.md lists the record, and .Rbuildignore excludes the folder from the package build.

  • Mechanism: S4 stores a class's complete definition, including the slots inherited from DBI's classes, in the package that defines it, when that package is installed. A backend installed against main keeps a connection class without .dbi until it is reinstalled.
  • Objects returned by DBI's generics still work with @: the generic sets the attribute, and @ and slot() read any attribute of that name.
  • @ and slot() fail where the attribute is missing, on objects made with new() and on objects saved with saveRDS() under main: no slot of name ".dbi" for this object of class "MiniConnection". Assigning with [email protected] <- fails: ‘.dbi’ is not a slot in class “MiniConnection”.
  • Reinstalling the backend makes @ work for new objects, but objects saved before then fail @ and now also validObject(): slots in class definition but not in object: ".dbi". Raised on feat: Keep the driver in each connection and the connection in each result #794 as a question.
  • With the old DBI and backends reinstalled against feat: Keep the driver in each connection and the connection in each result #794: no load warnings, [email protected] is an empty list, validObject() passes.
  • A backend that does not import DBI's classes gets its own copy of DBIConnection and DBIObject at install time (setIs() copies a superclass it cannot find through the imports). Loading it replaces DBI's definitions in the class table, so a class defined in the global environment afterwards inherits the stale copy.
  • attr(x, ".dbi", exact = TRUE) never errors; it returns NULL where the attribute is missing.

Status

  • Ready for review. Clean reviews: round 1 (two Medium on the mechanism's explanation, fixed) and round 2 (one Medium on branch history, a question; Low findings fixed in 4117d7b). Both reran the full experiment and reproduced the outputs.
  • Open question: rewrite branch history.
  • Accepted limitations: list.
  • Not part of the next release. Do not merge.

https://claude.ai/code/session_01Hr1rd6RgjpQxckjWTEReje

🤖 Generated with Claude Code

…e .dbi slot

An experiment record under experiments/, with a registry,
excluded from the built package by .Rbuildignore.
It installs a minimal backend and RSQLite against DBI from main,
then DBI from #794 over it, and records what works and what fails with the .dbi slot,
after reinstalling the backends, and in the reverse direction.

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

krlmlr commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Clean review, round 1 (789e679)

Reviewed by an agent without context from the work, by re-running run-all.sh (211 s, exit 0, no installation warnings). Every probe-*.txt, save-objects.txt and install-log.txt came out byte-identical; the versions-*.txt files differ only in timestamps and path padding. No High findings.

Medium, both being fixed:

  1. The README does not explain why the minicopy backend carries its own copy of DBIConnection, and states the trigger too narrowly. setIs() looks up the superclass from the package namespace through its imports; when DBI's class metadata is not visible there, methods silently writes a copy of the superclass definition into the subclass's namespace (DBIObject too). The trigger is "DBI's classes are not imported", not "imports no class from DBI".
  2. "Changes what the whole session sees" is wider than shown: on load, the copy, which carries @package == "DBI", overwrites the class table entry; the evidence covers getClass(), slotNames() and new() of subclasses.

Low, all being fixed: the evidence that [email protected] is the prototype relies on lapply(..., class), which cannot tell NULL from list(); "attr() works in every case" should say it returns NULL where the attribute is missing; the redaction runs after padding, so outputs depend on path lengths, and an empty R_LIBS_USER would break the sed expression; the user library is labelled <R library>.

Checked and correct: every finding matches the outputs line for line; @ and slot() read an attribute whatever the class definition says, and @<- refuses it (confirmed with a minimal class); the account of class definitions stored at install time; control: the private library comes first, and the recorded RemoteSha lines rule out the preinstalled DBI and RSQLite; each step runs in a fresh process; R CMD build leaves experiments/ out; no private paths, user names or emails.

Not checked: whether importClassesFrom(DBI, DBIConnection) alone prevents the copy; a full R CMD check; other R versions.


Generated by Claude Code

Describe the copy that methods writes when DBI's class metadata is not imported,
and test a subclass defined after loading such a package.
Show the value of the .dbi slot directly, note that attr() can return NULL,
and make the recorded output independent of path lengths.

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

krlmlr commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Clean review, round 2 (789e679..d6e22b3)

Scope: the fixes of round 1. No High findings; the one Medium is about the branch history, not the record, so the review stops here.

Medium

  1. An earlier commit on this branch linked an external repository that the record no longer names; removing it from the tree leaves it in the PR's commits. → Removing it needs a rewrite of this branch's history, which is left to Kirill.

Low, all being fixed: the LaterConnection result is also in probe-2, not only probe-3; the result was shown for one class defined in the global environment, which the conclusion should say; attr() also returns NULL for new() of classes that inherit the copy; a comment in minicopy keeps the old wording; run-all.sh puts paths into a sed pattern unescaped.

Checked and correct: the mechanism against methods 4.5.3 (setClass() → setIs() for every superclass, .findOrCopyClass(..., "subclass") → findClass(), copying silently into the subclass's namespace; loadNamespace() → cacheMetaData() → .cacheClass(), which overwrites the entry because the copy has @package == "DBI"); the new LaterConnection test, with probe-4 as control; identical([email protected], list()) as stated; the NULL cases of attr(); redaction and labels; no private paths, user names or emails. A rerun with a longer work path exited 0 and differs only in timestamps.

Not checked: other platforms and R versions.


Generated by Claude Code

krlmlr commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Question: Rewrite branch history to remove the name of an external repository?

The first commit of this PR, 789e679, and the experiment registry on the branch of the closed #795 (claude/s7-investigation, experiments/README.md) name and link a repository outside r-dbi as the source of the record format. The record here no longer names it (d6e22b3), but the commit keeps it. I cannot confirm from this session that the repository is public. Removing it needs a force-push, which the session's permission check refused, so nothing was rewritten.

  • Leave the history as is (recommended if that repository is public): nothing to hide, and no rewrite of pushed branches.
  • Squash this branch into one commit and force-push it, and remove the link from claude/s7-investigation with a new commit (recommended if it is private): the name disappears from this PR's commits; the branch of docs: Investigate a move of DBI's classes to S7 #795 keeps it in history unless it is also rewritten, and GitHub may still serve old commits by SHA.
  • Rewrite both branches.

Kirill decides; a force-push needs his go-ahead. If nobody decides, the history stays.


Generated by Claude Code

…ixed strings

Cite both runs that show the replaced definition,
say that one class defined in the global environment was tested,
and list the classes that inherit a stale copy among the cases where attr() returns NULL.
The driver now replaces paths as fixed strings.

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

krlmlr commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Accepted limitations

  • README.md, Not tested: only R 4.5.3 on Linux; DBIResultArrow, dbSendStatement() and dbSendQueryArrow() were not exercised; objects saved under feat: Keep the driver in each connection and the connection in each result #794 were not read back with main. Relevance low: the mechanism is the same for every class with the slot; reviewer confidence high.
  • README.md, Findings: the session-wide effect of a stale copy of DBIConnection was shown for one class defined in the global environment after loading, not for classes in other packages. Relevance low; reviewer confidence high.
  • The PR's first commit names an external repository that the record no longer names (question). Relevance depends on that repository's visibility; reviewer confidence high.

Generated by Claude Code

@krlmlr
krlmlr marked this pull request as ready for review November 29, 2026 18:57
@krlmlr krlmlr mentioned this pull request Nov 29, 2026
15 of 22 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants