Skip to content

ADFA-7297 SQLite debugger P2-2: rows, change counts, named parameters and column types - #2319

Open
davidschachterADFA wants to merge 15 commits into
sqlite-debugger/ADFA-7296from
sqlite-debugger/ADFA-7297
Open

davidschachterADFA wants to merge 15 commits into
sqlite-debugger/ADFA-7296from
sqlite-debugger/ADFA-7297

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

ADFA-7297

Phase 2, P2-2 of the SQLite debugger (ADFA-7131): the MCP server turns on the row recording that #2311 (P2-1) added to the extension, and returns rows, change counts, named parameters and column types. Stacked on #2311.

What it does (subprojects/sqlite-debugger)

  • get_events: a profile event gains rows, changes (null for a read) and rows_cut. A new row event kind has row_number, column_count, values, storage_classes and cut_values. Calling get_events turns row recording on: 10 rows per statement, values cut at 256 bytes, rows at 4 KiB. include_rows: false turns it off and leaves row events out. Recording also goes off when the client goes idle and when the server stops.
  • query and explain_query_plan: args can be an object that binds by name (:name, @name, $name, ?NNN). A key is written as in the SQL; a key without a prefix, such as id, matches :id, @id and $id, and a ?NNN key keeps its ?. Names are matched in JNI. Every parameter needs a value, and every key must name a parameter.
  • query returns column_types (the declared types) and storage_classes (one letter per cell, irtbn).
  • BLOBs are now {hex, bytes, truncated}; they were base64. No client reads the old key.
  • The README's "Limits" and tool sections describe each of these.

Limit: execute (#2312) still binds positional args only. Whichever of #2312 and this PR merges second wires named args into execute: pass argNames through bridge_execute and prepare_bound.

Commits

  • 99007a7: the change, from the cloud session.
  • e73b348: spotlessApply on DatabaseTools.kt only (one call chain wrapped, one blank line dropped).
  • e450122: the args description said every key could drop its prefix, but a bare 1 doesn't match ?1; it now says a ?NNN key keeps its ?, as the README already did (from the review below).
  • a8fca8c: merges the cloud session's ffb3f18, which drops a stale comment in sqlitedbg_jni.c; ADFA-7301 SQLite debugger P2-6: sqlite3 shell tools (suggest_indexes, lint_foreign_keys, dump, export, .dbinfo) #2323 carries the same commit.
  • e648501: test formatting only. ktlint joined kinds()'s expression body onto its signature line, at 142 columns, and that error (reported at L1) stopped its other changes. kinds() now has a block body, and the lines ktlint wanted wrapped are wrapped. Production code is unchanged.
  • f0c931f (ADFA-7323): on the J7, a misspelt key ({"idx": 1} for :id) failed with only "no value was given for parameter :id". bind_named stopped at the first parameter with no value, before it looked for keys that matched nothing. It now names the key as well: "the statement has no parameter named idx, and no value was given for parameter :id". A parameter left out with no stray key, and a stray key with every parameter bound, keep their messages. The README says so.
  • d354698: merges ADFA-7296: SQLite debugger records row and change events #2311's 0c9a19e, the 2026-11-26 review's fake-engine fix (ADFA-7131 comment 41632). One conflict: both branches added an addEvent overload to FakeDebugEngine, and both are kept.
  • b87338e: merges ADFA-7296: SQLite debugger records row and change events #2311's 2d674ec, its fix for CodeRabbit's third review (EventDecoder refuses a row count its bytes cannot hold), with no conflicts. Its diff is exactly 2d674ec's.
  • 2aa2c37 and 2523485: merge ADFA-7296: SQLite debugger records row and change events #2311's 5d8acf6 (its CodeRabbit fixes; one README conflict, both sides kept) and dd7ee19 (README only). Each merge's change equals the incoming commit's; the cloud session checked the first.
  • f0e8d51: merges ADFA-7296: SQLite debugger records row and change events #2311 at b9a3129 (ADFA-7379: 80-byte records with an execution id), with no conflicts; each file's changed lines equal ADFA-7296: SQLite debugger records row and change events #2311's.
  • 8760dc0 (ADFA-7379): get_events returns execution_id on every event, a statement event's own seq and the same number on that run's profile and row events, null when unknown (a trigger's statements, close, a statement whose start was not seen). Rows of two statements stepped in turn are now told apart. The tool text and README say a run can have more than one profile (a retry after a schema change) or none at its end.
  • 954de4a (ADFA-7379, from an independent review): get_events' description and the README now list every case where execution_id is null (close, a trigger's statements, a statement run inside a callback, an EXPLAIN's profile, a statement whose start was not seen, the later profile of a statement pushed out of its slot) and say that a busy step can fire a profile with rows 0 before the run's rows; the JNI test now requires a row's id to be the seq of the newest STATEMENT before it, with the query's SQL.
  • 6958e2f: merges ADFA-7296: SQLite debugger records row and change events #2311's ADFA-7379 review fixes (4ffc26d: a trigger step no longer clears its statement's slot; a non-DML statement's changes are not taken from another statement; stricter decoding of cut values; doc corrections, and the UTF-16 row-size cost as an accepted limit); one README conflict, resolved to both sides; each file's changed lines equal ADFA-7296: SQLite debugger records row and change events #2311's.

Tests

  • At 6958e2f: test.sh 0 failures (ASan+UBSan 31,934 checks, TSan 31,940, JNI 281); :subprojects:sqlite-debugger:testDebugUnitTest (131) and spotlessCheck pass. With the row's id made one less, or the previous statement's, the new JNI check fails (JniQueryTest.java:274).
  • At 8760dc0: test.sh 0 failures (ASan+UBSan 31,364 checks, TSan 31,362, JNI 281); :subprojects:sqlite-debugger:testDebugUnitTest (129) and spotlessCheck pass. Without the encoder's execution_id line, the fixture test fails ("execution_id is always present"). The JNI test checks a recorded row's execution_id is the seq of a statement record in the buffer.
  • At b87338e: :subprojects:sqlite-debugger:testDebugUnitTest (125 tests) and spotlessCheck pass.
  • At d354698: :subprojects:sqlite-debugger:testDebugUnitTest (124 tests) and spotlessCheck pass.
  • Local: test.sh at 99007a7 passes (ASan+UBSan 20750 checks, TSan 20732, JNI 279, 0 failures). The C and JNI code is unchanged after it. At e648501: :subprojects:sqlite-debugger:testDebugUnitTest (123 tests) and spotlessCheck pass. assembleV8Debug passed at 99007a7, and :subprojects:sqlite-debugger:assembleDebug at e450122.
  • At f0c931f: test.sh passes (ASan+UBSan 20748 checks, TSan 20750, JNI 280, 0 failures), and so do :subprojects:sqlite-debugger:testDebugUnitTest (123 tests), spotlessCheck and the module's debug and release AARs. Revert proof: with sqlitedbg_jni.c as at a8fca8c, exactly the two changed expectations fail, each showing the old message.
  • From the cloud session at 99007a7: test.sh 0 failures, 118 JVM tests, and four revert proofs that fail as named.

Review before this PR (a fresh read of 99007a7; no CRITICAL or IMPORTANT findings):

  • Fixed: the args description (e450122).
  • Not changed (MINOR): error messages cut a parameter name at 100 bytes (%.100s), which can split a UTF-8 character and show U+FFFD; a comment in DatabaseTools.kt says every tool that returns cells carries storage_classes, but only query and get_events do; the named-binding tests don't cover a key over 100 bytes or names and args of different lengths (the code paths were read and found correct).

Device check (Galaxy J7, Android 9, 2026-11-26; ADFA-7297 41611): get_events turned row recording on; after a note was added in the app, the INSERT's profile event had changes 1 and the list's SELECT rows 5, followed by 5 row events, and include_rows: false left them out. Named args bound as id, :id and ?1, and a misspelt key failed with "no value was given for parameter :id" (the key itself is now named too, f0c931f; not rerun on the device). The test app was RoomNotes built with the SQLite debugger from #2323's head (which carries this PR) and #2262's plugin, called over adb forward.

No screens added or changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn


Code Reviewer: Code Reviewer couldn't review this pull request
The pull request author does not have access to AI for the associated Atlassian organization.

claude and others added 5 commits November 26, 2026 05:02
…column types

Phase 2, P2-2 (ADFA-7131 comments 41476, 41477). On P2-1 (#2311, at
e16ea45).

- get_events: a profile event carries rows, changes (null for a read)
  and rows_cut; a row event carries row_number, column_count, values,
  storage_classes and cut_values. get_events turns row recording on
  (new DebugEngine.setRowCapture, JNI setRowCapture): 10 rows per
  statement, values cut at 256 bytes, a row at 4 KiB. include_rows
  false turns it off and leaves row events out; it also goes off with
  the idle client and when the server stops.
- query and explain_query_plan: args as an object binds by name
  (:name, @name, $name, ?NNN; a key with or without its prefix). Names
  go to JNI as UTF-8 and are matched against
  sqlite3_bind_parameter_name: every parameter needs a value and every
  key a parameter. The array form is unchanged.
- query returns column_types (sqlite3_column_decltype, null for an
  expression) and storage_classes, a letter per cell (i r t b n): JSON
  writes REAL 2.0 as 2, and big integers as strings.
- BLOBs are {hex, bytes, truncated}; they were base64. No client reads
  the old key (AI-Agent-MCP passes results through).
- Tool descriptions say what is capped; README updated.

Limit: execute (P2-3, #2312) still binds positional args only; the
second of the two PRs to merge wires its names.

Tests: test.sh passes (ASan+UBSan, TSan, JNI 279 checks: each name
form, the five refusals, declared types, the row-recording switch).
DatabaseToolsTest, McpProtocolTest and EventDecoderTest pass (118),
compiled with the Kotlin compiler outside Gradle, including an encoding
of every event in P2-1's fixture. Revert proofs: no unused-name check
fails "named: a misspelt name"; no decltype fails "declared types";
no idle switch-off fails rowRecordingStopsWithTheIdleClient; no row
filter fails getEventsTurnsRowRecordingOnUnlessToldNotTo. Not run here:
Gradle, spotlessCheck, a device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
spotlessKotlinCheck's two changes to DatabaseTools.kt: the named-args
key chain on one call per line, and one blank line dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The args description said every key could be written without its
prefix, but only :name, @name and $name match a bare name (key_matches):
{"1": 5} for ?1 fails with "no value was given for parameter ?1". The
text now says a ?NNN key keeps its ?, as the README already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
It described bind_args, which bind_positional and bind_value replaced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
spotlessKotlinCheck failed on DatabaseToolsTest.kt with one
max-line-length error, reported at L1. ktlint joins kinds()'s expression
body onto its signature line, and the joined line is 142 columns. Its
other changes were then not applied either, so the file also needed
ktlint's wrapping of the named-args call and of a four-call chain.

kinds() now has a block body. Two long assertions are wrapped, and the
row-values check reads values.get(c) once, before its when, so each
branch stays on one line. Production code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

The cloud session's ffb3f18 drops a stale comment above bind_value in
sqlitedbg_jni.c (one line). P2-6 (ADFA-7301) already merges it, so the
two branches keep the same ancestry. No conflicts; nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA pushed a commit that referenced this pull request Nov 26, 2026
…ite-debugger/ADFA-7301

P2-6 now stacks on #2319: it takes Remington's e450122 (a ?NNN args key
keeps its ?), e648501 and the merge of ffb3f18. No conflicts. At
the merge: DatabaseToolsTest, ShellToolsTest, McpProtocolTest and
EventDecoderTest pass (135); test.sh 0 failures (JNI 333).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
bind_named stopped at the first parameter with no value, before it
looked for keys that matched no parameter. So args {"idx": 1} against
"WHERE id = :id" failed with "no value was given for parameter :id",
and the misspelt key was never named (seen on the J7, ADFA-7297
comment 41611).

It now binds every parameter that has a value, then reports a key that
matched nothing first, together with the parameter left without a
value: "the statement has no parameter named idx, and no value was
given for parameter :id". A parameter left out with no stray key, and a
stray key with every parameter bound, keep their messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 26, 2026
…qlite-debugger/ADFA-7301

Brings in the misspelt named-args key message from #2319.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA pushed a commit that referenced this pull request Nov 26, 2026
…eff47b0)

The base for ADFA-7304, which needs P2-2 and P2-3/P2-4; neither has
landed (David, 2026-11-26).

Conflicts, each side kept:
- sqlitedbg.c: P2-2's sqlitedbg_set_row_capture beside P2-3's PRAGMA
  allowlist and writable authorizer.
- sqlitedbg_jni.c: P2-3's prepare_bound calls P2-2's bind_named or
  bind_positional (which checks the count itself, as prepare_bound did);
  bridge_query passes its names; execute stays positional for now.
- DebugEngine.kt: P2-2's setRowCapture beside P2-3's openServerConnection doc.
- DatabaseTools.kt: P2-3's withConnection with P2-2's Bind; execute
  refuses object args (its schema still says array), so an object's values
  are never bound by position; the Room check passes Bind.NONE.
- README: the JNI test list names both PRs' cases.

At the merge: test.sh 0 failures (JNI 480); DatabaseToolsTest,
McpProtocolTest and EventDecoderTest pass (131).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
davidschachterADFA pushed a commit that referenced this pull request Nov 26, 2026
The item left for whichever of #2312 and #2319 merged second (41592):
execute takes args as an array or an object, through the same
prepare_bound, bind_named and argsSchema as query.

- JNI execute gains names ([[B); bridge_execute passes them to
  prepare_bound. ServerConnection.execute gains argNames.
- The execute tool's args schema is argsSchema(), and the merge's
  refusal of an object is gone. README updated.

Tests: JNI binds INSERT ... VALUES(:id, @s) by name and refuses a
misspelt key with SQLITE_RANGE, writing nothing;
executeBindsAnObjectByName. test.sh 0 failures (JNI 488); JVM 132.
Revert proof: execute ignoring names fails "each value went to its own
parameter", "execute ran with a misspelt name" and "and the row is
still there".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba

@davidschachterADFA davidschachterADFA left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of #2319 at f0c931f63f. Stack: #2311 (P2-1) <- #2319 (this) <- #2323 (P2-6); claims checked at the stack tip 323d3d3. Read: the full diff; at the tip DatabaseTools.kt, EventDecoder.kt, the sqlitedbg.c row-capture setters, the JNI named-arg matching (misspelt, duplicate and unused keys) and decltype handling, and the README. Tests were not re-run for this review.

No findings survived verification.
Earlier review comments, re-checked against the code (not the replies)

  • claude[bot] - review-bot boilerplate (manual review instructions); no findings: fixed. Review body only says reviews are manual; no inline comments exist on the PR (gh api pulls/2319/comments is empty).

Verdict: COMMENT. This PR is authored by the account posting the review, and GitHub refuses APPROVE and REQUEST_CHANGES on your own PR. Severity rules: CodeOnTheGo REVIEW.md and CLAUDE.md (a ticket moves to QA with no outstanding critical, high or medium findings); addons has no written rule, so the default applied.


Generated by Claude Code

…gger/ADFA-7297

Brings in the #2311 review fix (the fake engine sizes records as the native ones).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 26, 2026
…gger/ADFA-7301

Brings in the #2311 review fix through #2319.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
@davidschachterADFA

Copy link
Copy Markdown
Collaborator Author

@hal-eisen-adfa A new commit since you were asked to review: d354698 merges #2311's test-only fix for the 2026-11-26 review. Both branches had added an addEvent overload to FakeDebugEngine, and both are kept. This PR had no findings of its own.

…gger/ADFA-7297

Brings in the #2311 review fix (EventDecoder refuses a row count its bytes cannot hold).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 27, 2026
…gger/ADFA-7301

Brings in the #2311 review fix through #2319.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Nov 27, 2026
…gger/ADFA-7302

Brings in the #2311 review fix through #2319 and #2323.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
@davidschachterADFA

Copy link
Copy Markdown
Collaborator Author

@hal-eisen-adfa A new commit since you were asked to review: b87338e merges #2311's 2d674ec (EventDecoder refuses a row count its bytes cannot hold), with no conflicts. Its diff is exactly 2d674ec's. This PR has no change of its own.

Brings #2311's fixes for CodeRabbit's findings on #2332 up the stack (CLAUDE.md: a fix lands in
the lowest PR, then merges up).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn

# Conflicts:
#	subprojects/sqlite-debugger/README.md
davidschachterADFA added a commit that referenced this pull request Dec 1, 2026
…DFA-7301

Brings #2311's row-event fixes up the stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Dec 1, 2026
…e) into ADFA-7301

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA and others added 2 commits December 1, 2026 11:38
…FA-7297

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
#2311 (b9a3129, merged in the previous commit) gives each event record
an execution_id: a STATEMENT event's own seq, and on that run's PROFILE
and ROW events the same number. get_events now returns it on every
event, null when unknown (a trigger's statements, close, a statement
whose start was not seen), so an agent can tell apart the rows of two
statements stepped in turn on one connection. The tool description and
the README say what it means, and that a run can have more than one
profile (a retry after a schema change) or none at its end.

Tests: DatabaseToolsTest's fixture test checks execution_id on every
decoded event (the fixture's ROW events carry ids); JniQueryTest checks
that a recorded row's execution_id is the seq of a STATEMENT record in
the buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
@davidschachterADFA

Copy link
Copy Markdown
Collaborator Author

Hal, two new commits: f0e8d51 merges #2311's ADFA-7379 (an execution id on events, with no conflicts), and 8760dc0 adds execution_id to every get_events event. It's the statement event's own seq, and the same number on that run's profile and row events, so rows of interleaved statements are told apart. It's null when unknown. test.sh 0 failures (JNI 281), unit tests 129, spotlessCheck. The fixture test fails without the encoder change.

davidschachterADFA added a commit that referenced this pull request Dec 1, 2026
…and execution_id in get_events) into ADFA-7301

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Dec 1, 2026
… and #2319) into ADFA-7302

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Dec 1, 2026
…and execution_id in get_events) into ADFA-7304

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn

# Conflicts:
#	subprojects/sqlite-debugger/README.md
@davidschachterADFA

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

  • Row capture: get_events records statement rows by default. Limits are 10 rows per statement, 256 bytes per value, and 4 KiB per row.
  • include_rows: false turns off row events and disables capture.
  • Profile and row events include execution_id, which links them to their statement. The value is null when unknown.
  • query returns column_types and per-cell storage_classes.
  • query and explain_query_plan accept named-argument objects. Keys match :name, @name, and $name. ?NNN keys keep the ?.
  • DebugEngine adds setRowCapture(...). ServerConnection.query adds argNames. QueryResult adds declaredTypes.

Risks:

  • Breaking change: BLOB output changes from base64 to {hex, bytes, truncated}. Clients that read the old key fail. The author states no client reads it, but this is unverified.
  • Breaking change: the query signatures change in ServerConnection, NativeServerConnection, and NativeBridge. All callers must update.
  • Row capture is on by default and adds per-statement cost. Document this for users.
  • Long parameter names can be cut mid-UTF-8 character. The author reports this as unfixed.
  • A code comment overstates which tools carry storage_classes.
  • Some named-binding edge cases lack tests.
  • execute remains positional-only. Named-argument wiring depends on whether #2312 or this change merges second.

The SQLite debugger adds named SQL parameter binding and declared column types to query results. It also adds configurable row-event capture, row and profile event serialization, and include_rows control through get_events.

Changes: Query bindings and results

Layer / File(s) Summary
Native query binding and result contract
subprojects/sqlite-debugger/src/main/cpp/sqlitedbg_jni.c, subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/engine/*, subprojects/sqlite-debugger/src/test/jni/JniQueryTest.java
The engine and JNI query interfaces accept optional parameter names. The native binder validates positional and named arguments. Query results include declared column types.
Tool binding inputs and query wiring
subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/mcp/DatabaseTools.kt, subprojects/sqlite-debugger/src/test/java/org/appdevforall/sqlitedebugger/engine/FakeDebugEngine.kt, subprojects/sqlite-debugger/src/test/java/org/appdevforall/sqlitedebugger/mcp/DatabaseToolsTest.kt, subprojects/sqlite-debugger/README.md
The query and explain-plan tools accept positional arrays or named objects and forward bindings to the server connection. Tests and documentation cover the binding forms and validation.
Query result value details
subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/mcp/DatabaseTools.kt, subprojects/sqlite-debugger/src/test/java/org/appdevforall/sqlitedebugger/mcp/DatabaseToolsTest.kt
Query responses include declared types and storage-class labels. BLOB values use lowercase hexadecimal representation.

Row-event capture

Layer / File(s) Summary
Capture configuration across the engine bridge
subprojects/sqlite-debugger/src/main/cpp/sqlitedbg_jni.c, subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/engine/*, subprojects/sqlite-debugger/src/test/jni/*
The engine exposes row-capture limits and forwards them through JNI. JNI tests cover capture toggling and row-event references.
Event tool lifecycle and serialization
subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/mcp/DatabaseTools.kt, subprojects/sqlite-debugger/src/test/java/org/appdevforall/sqlitedebugger/mcp/DatabaseToolsTest.kt, subprojects/sqlite-debugger/README.md
get_events controls row capture with include_rows, disables capture on shutdown or idle expiry, and serializes row and profile details. Tests cover event encoding and capture state changes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MCPClient
  participant DatabaseTools
  participant NativeServerConnection
  participant NativeBridge
  participant SQLite
  MCPClient->>DatabaseTools: Submit SQL and named arguments
  DatabaseTools->>NativeServerConnection: Pass values and parameter names
  NativeServerConnection->>NativeBridge: Pass UTF-8 parameter names
  NativeBridge->>SQLite: Bind arguments and execute query
  SQLite-->>NativeBridge: Return rows and declared column types
  NativeBridge-->>NativeServerConnection: Return query result array
  NativeServerConnection-->>DatabaseTools: Map result to QueryResult
  DatabaseTools-->>MCPClient: Return query data and storage classes
Loading
sequenceDiagram
  participant MCPClient
  participant DatabaseTools
  participant NativeDebugEngine
  participant NativeBridge
  MCPClient->>DatabaseTools: Call get_events with include_rows
  DatabaseTools->>NativeDebugEngine: Set row-capture limits or disable capture
  NativeDebugEngine->>NativeBridge: Forward row-capture limits
  NativeBridge-->>DatabaseTools: Provide buffered SQL events
  DatabaseTools-->>MCPClient: Return encoded events, filtering rows when disabled
Loading

Possibly related PRs

Merge Risk: Minimal · up to 8760d

This change adds named SQL parameters, declared column types, hex-encoded BLOBs and optional row capture to the SQLite debugger. No merge-blocking defect was found. The remaining edge cases are minor: declared types can briefly differ from the rows if the app changes the schema mid-query, and sparse numbered placeholders need positional binding.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the SQLite debugger P2-2 work and its main parts: row recording, change counts, named parameters, and column types. The changeset adds row capture to get_events, row and changes fields…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is related to the changeset. It covers the MCP server row recording for get_events (rows, changes, rows_cut, row events, include_rows), named-argument binding for query and explain_que…
Full details: Title check

Explanation

The title names the SQLite debugger P2-2 work and its main parts: row recording, change counts, named parameters, and column types. The changeset adds row capture to get_events, row and changes fields in profile events, named-argument binding in query and explain_query_plan, and column_types and storage_classes in query results. The title matches these changes. It is long, at 86 characters, and uses a ticket prefix, but it is still specific.

Full details: Description check

Explanation

The description is related to the changeset. It covers the MCP server row recording for get_events (rows, changes, rows_cut, row events, include_rows), named-argument binding for query and explain_query_plan, declared column types and storage classes, the BLOB encoding change to hex, and the execution_id addition. It also lists commits, test results, and device validation. The raw summary matches these claims in DatabaseTools.kt, DebugEngine.kt, NativeDebugEngine.kt, NativeBridge.kt, sqlitedbg_jni.c, and the README. The description is specific and not generic, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit taps a query key,
Named bindings hop in neatly.
Rows leave tracks in event streams,
Types and hex appear in beams.
Then capture rests when clients flee.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 8a025778-561c-40fa-9d05-9177445a5d5f
Commits

Reviewing files that changed from the base of the PR and between b9a3129 and 8760dc0.

Files selected for processing: 10

  • subprojects/sqlite-debugger/README.md
  • subprojects/sqlite-debugger/src/main/cpp/sqlitedbg_jni.c
  • subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/engine/DebugEngine.kt
  • subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/engine/NativeBridge.kt
  • subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/engine/NativeDebugEngine.kt
  • subprojects/sqlite-debugger/src/main/java/org/appdevforall/sqlitedebugger/mcp/DatabaseTools.kt
  • subprojects/sqlite-debugger/src/test/java/org/appdevforall/sqlitedebugger/engine/FakeDebugEngine.kt
  • subprojects/sqlite-debugger/src/test/java/org/appdevforall/sqlitedebugger/mcp/DatabaseToolsTest.kt
  • subprojects/sqlite-debugger/src/test/jni/JniQueryTest.java
  • subprojects/sqlite-debugger/src/test/jni/org/appdevforall/sqlitedebugger/engine/NativeBridge.java

Included review availability: This review used your included allowance. Your plan provides up to 5 included reviews per hour; 2 remain after this review.

davidschachterADFA and others added 2 commits December 1, 2026 18:16
…statement

Review findings on #2319 (an independent review of the ADFA-7379 code):

- F07: get_events' description listed only some of the cases where
  execution_id is null. It now names them all, as #2311's README does:
  close, a trigger's statements, a statement an app function runs inside
  a callback, an EXPLAIN's profile, a statement whose start was not seen,
  and the later profile of a statement pushed out of its slot. It also
  says that a step that met a busy lock fires a profile with rows 0
  before the run's rows. The README's get_events paragraph says the same.
- F06: JniQueryTest only checked that a row's execution_id was the seq of
  some STATEMENT in the buffer, so an id off by one or naming an older
  statement still passed. It now requires the id to be the seq of the
  newest STATEMENT before the row, and that statement's SQL to be the
  query's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…DFA-7297

# Conflicts:
#	subprojects/sqlite-debugger/README.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Dec 2, 2026
… and #2319's F06/F07) into ADFA-7301

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Dec 2, 2026
 and #2319) into ADFA-7302

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
davidschachterADFA added a commit that referenced this pull request Dec 2, 2026
… and #2319's F06/F07) into ADFA-7304

# Conflicts:
#	subprojects/sqlite-debugger/README.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
@davidschachterADFA

Copy link
Copy Markdown
Collaborator Author

Hal, two new commits on #2319 (8760dc0..6958e2f):

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