Skip to content

ADFA-7304: SQLite debugger execute returns RETURNING rows and binds named args - #2332

Draft
davidschachterADFA wants to merge 91 commits into
sqlite-debugger/ADFA-7299from
sqlite-debugger/ADFA-7304
Draft

davidschachterADFA wants to merge 91 commits into
sqlite-debugger/ADFA-7299from
sqlite-debugger/ADFA-7304

Conversation

@davidschachterADFA

@davidschachterADFA davidschachterADFA commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

ADFA-7304

Phase 2 follow-up of the SQLite debugger (ADFA-7131): execute binds named args as query does, and returns RETURNING rows within query's limits. Draft, stacked on #2313 (P2-4, which includes #2312). It also has #2319 (P2-2) merged in, for the named-args code it shares with query. So until #2319 lands, this PR's diff against #2313 also shows #2319's and #2311's commits. ADFA-7304's own commits are listed below.

What it adds (subprojects/sqlite-debugger):

  • Named args for execute (346cd6c): the same bind_named/bind_positional and the same rules and errors as query (prefixes, a misspelt key, a duplicate key, an anonymous ?). args is an array or an object, so named and positional can't be mixed.
  • RETURNING rows (6f5a8a4):
    • Rows come back as query returns them: columns, column_types, rows, storage_classes, has_more, truncated_cells and truncated_cell_indexes. That's at most max_rows (default as query's), about 4 MiB of cells, with the same per-cell cuts.
    • Every change is committed whatever is returned. has_more means RETURNING produced more rows than came back; they can't be paged, because that would write again.
    • A statement that fails returns no rows and SQLite rolls it back. The exception is FAIL conflict resolution, which keeps the rows changed before the failing one, and the error says how many were kept (c2fae14).
    • The 1.5 s write limit covers the whole write, since SQLite makes every change before the first row comes back.
  • A commit stopped at the cap (571cc3f): when a statement cut at a limit can't commit because an app connection holds a lock, it's reported like a stalled step: SQLITE_INTERRUPT, "Try it again", and nothing kept. Before, it was SQLITE_BUSY with no advice. Also, done: finalizes before restoring busy_timeout, so that commit is capped too.
  • execute's description, DebugEngine.execute's KDoc and the README say all this (0d5dbb9 adds the cut-cells note query has).

Merges:

Reviews:

  • Before it was published (ADFA-7304 comment 41628; fixed in a8bb4e3 and c2fae14).
  • A fresh review on 2026-11-30 after the merges: no IMPORTANT findings. 3 MINOR and 3 NITPICK, all fixed (571cc3f, f7e7b55, 0d5dbb9, 5ee892b) and re-checked.
  • The cloud session's review (2026-11-30, ADFA-7131 comment 41745): 1 IMPORTANT, fixed in b9ccfc7. The RETURNING time-limit test only shrank its table, so on a fast machine every row was copied within the limit and two checks failed; test-sqlite-debugger failed in CI at 5ee892b and 9cb70b8. The table now also doubles (up to 3.2 million rows) while the copy finishes in time.
  • CodeRabbit's review of b9ccfc7 (requested 2026-11-30): 13 findings (4 Major, 9 Minor), checked by a probe against SQLite 3.49.1. Fixed here: 9530161 (when building the result fails after the write ran, the error says whether it was committed; tested since acd87a1), 4d02e99 (KDoc and tool text: best-effort limits; omitted RETURNING rows can't be recovered, a follow-up query helps only if the data still exists), b1c4e54 (the time-limit test requires rows to have been copied, and bisects the table size), 67e3017 (test fix). Fixed in ADFA-7296: SQLite debugger records row and change events #2311, which owns the code, and merged in bad9f58: huge values left unread, changes -1 for an unfinished statement, the slot kept across SQLITE_BUSY, uncounted cut rows, two C-test NULL checks. Follow-up: ADFA-7379 (an execution id in row events). Accepted: column metadata read before the first step (a cross-connection schema change in that window), and no deadline check before a row-capped write's commit (limits are best effort; the write is documented as committed). Each thread has a reply.
  • A fresh review of the write-outcome reporting (2026-12-01, by a separate agent, then checked here), fixed in acd87a1:
    • A transaction left open on the server connection (a way past the authorizer, then a refused rollback) is rolled back before execute runs. Before, the write ran inside it, the call reported it written, and the backstop rolled it back afterwards.
    • The out-of-memory outcome error is always SQLITE_NOMEM. Before, it carried finalize's code, so an interrupt drew the tool's "retry it" onto an error that says the write may not have been committed.
    • A statement that failed before its result could be built reports its own error, not the allocation failure.
    • A failed commit at the row-limit reset says nothing was kept only for a lock, a constraint, a full disk or an interrupt. After an I/O error or corruption it says the change may not have been kept (not tested).
    • A seam in the JNI test build only (SQLITEDBG_TEST, never in the app) fails read_rows as a JNI allocation would. The new checks fail without their fixes: reverting the first three fixes fails 3, and dropping the outcome report fails 3 others.
  • The cloud session's review of acd87a1: no findings to fix; its three revert proofs each fail one check. Its two optional nits are fixed in 559fb19: after an out-of-memory error, a commit that SQLite rolled back (lock, constraint, full disk, interrupt) now says nothing was kept, as the row-limit reset does; the README says test.sh adds the SQLITEDBG_TEST seam.
  • CodeRabbit's follow-up (4748285282, answered): if building the outcome error fails as well, the caller gets the OutOfMemoryError from building it, without the outcome, and the comment above report_unfinished_write said the original exception was kept. 5dc2581 corrects the comment and records the gap in the README as an accepted limit (David, 2026-12-03) for every error the JNI layer builds: it takes a second allocation failure right after the first, and reserving the error would mean building it before every write. No test: the harness can't inject a failure inside throw_engine.

Tests:

  • At 5dc2581 (comment and README only): test.sh 0 failures (ASan+UBSan 32,202 checks, TSan 32,201, JNI 701); :subprojects:sqlite-debugger:testDebugUnitTest (146) and spotlessCheck pass.
  • At b8e04e7: test.sh 0 failures (ASan+UBSan 32,203 checks, TSan 32,210, JNI 701); :subprojects:sqlite-debugger:testDebugUnitTest (146) and spotlessCheck pass.
  • At 6b745ce: test.sh 0 failures (ASan+UBSan 32,204 checks, TSan 32,207, JNI 691); :subprojects:sqlite-debugger:testDebugUnitTest (146) and spotlessCheck pass.
  • At 69dd43b: test.sh 0 failures (ASan+UBSan 31,659 checks, TSan 31,666, JNI 691); :subprojects:sqlite-debugger:testDebugUnitTest (144) and spotlessCheck pass.
  • At 559fb19: test.sh 0 failures (ASan+UBSan 23,037 checks, TSan 23,036, JNI 690). No Kotlin change since acd87a1.
  • At acd87a1: test.sh 0 failures (ASan+UBSan 23,052 checks, TSan 23,045, JNI 690); :subprojects:sqlite-debugger:testDebugUnitTest (140) and spotlessCheck pass. Not rechecked on a device: the changed paths need a transaction left open or a failed allocation, which only the test build can produce.
  • At bad9f58: test.sh 0 failures (ASan+UBSan 23,044 checks, TSan 23,042, JNI 659); :subprojects:sqlite-debugger:testDebugUnitTest (140) and spotlessCheck pass. A forced first-step interrupt now fails the time-limit test ("cut in its first step"), which the old test accepted.
  • test.sh at b9ccfc7: ASan+UBSan 21,006 checks, TSan 21,012, JNI 658, 0 failures. With the table started at 25,000 rows to stand in for a fast machine, the old test fails both checks CI showed, and the new one grows to 200,000 rows and passes. (The earlier claim of 0 failures at 5ee892b held on this machine only; CI failed there.)
  • :subprojects:sqlite-debugger:testDebugUnitTest (140), spotlessCheck and :app:assembleV8Debug pass at 0d5dbb9. 5ee892b and b9ccfc7 change only JniQueryTest.java, which Gradle doesn't build; spotlessApply changes nothing at b9ccfc7.
  • New JNI cases:
    • a commit stalled at the cap (SQLITE_INTERRUPT, "Try it again", 1.4-2.4 s);
    • OR ROLLBACK, OR IGNORE and OR REPLACE with RETURNING;
    • a time limit that strikes while rows come back. The table is halved while the first step is slow and doubled while the copy finishes in time; the case fails rather than passing if no size reaches that path.
  • Revert proofs: without 571cc3f, the stall case fails with code 5 instead of 9; without 0d5dbb9, the description test fails.
  • At 571cc3f alone, the JNI test fails (its old case still expects code 5). It passes from f7e7b55 on.

Device recheck at bad9f58 (Galaxy J7, 2026-12-01): every check below matches; execute's description now carries the best-effort and unrecoverable-rows text.

Device check (Galaxy J7, Android 9; ADFA-7304 comment, 2026-11-30): a RoomNotes test app with this branch's SQLite debugger at 5ee892b, called over adb forward. All 14 checks passed:

  • Room's acknowledgement: refused without acknowledge_room, then one RETURNING row with columns, column_types and storage_classes.
  • Named args with and without their prefix; a misspelt key names it; positional args still work.
  • UPDATE ... RETURNING with max_rows 2 gives 2 rows, has_more true and changes 3, and all three rows are updated.
  • A 5,000-character value comes back cut to 4,096, with truncated_cell_indexes [[0,0]].
  • With RETURNING: OR FAIL keeps its 1 row and says so; OR ROLLBACK keeps nothing; OR IGNORE returns the inserted row; OR REPLACE returns the new row.
  • SELECT 1 is refused ("run it with query").

The run also found that initialize's instructions still say "Every tool is read-only". That text dates from #2259, and #2312 added execute without changing it.

Merging:

Left as is (David, 2026-11-30): nitpicks from the last re-check, none affecting correctness.

  • The commit-stall case's 2.4 s upper bound can still flake on a very slow CI runner; if it happens, widen the bound or retry once. The time-limit case now fails only when no table size fits: a first step over 1 s at a size whose copy still finishes in time.
  • execute's description, like query's, explains truncated_cell_indexes but doesn't give the 4,096-byte and 1,024-byte cut sizes.

🤖 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 30 commits November 25, 2026 03:22
Phase 2, P2-1 (ADFA-7131 comments 41476, 41477, 41489).

- The record header grows from 56 to 72 bytes with rows and changes;
  every earlier field keeps its offset. SQLITEDBG_INTERFACE_VERSION 3.
- PROFILE events carry the rows the statement returned and, for a
  statement that may write, its own change count (sqlite3_changes64,
  or 0 when sqlite3_total_changes64 did not move, so a CREATE TABLE
  does not report the previous write's count). -1 for a read.
- New SQLITEDBG_EVENT_ROW: the first N rows of each statement, while a
  client is connected and sqlitedbg_set_row_capture is on. Off by
  default; nothing turns it on yet (the server will, ADFA-7297).
- Each value is read with the accessor of its own type. Reading every
  column with sqlite3_column_text turns a BLOB into TEXT for the app.
- Up to 16 statements per connection are followed from start to
  PROFILE. Rows of a statement not seen start are dropped, which drops
  SQLite's own nested statements (a CREATE TABLE's schema read).
- EventDecoder.kt decodes the new header and row data; Event gains
  rows, changes, rowsCut and row, with defaults.
- Fixture regenerated; README documents the layout and the limits.

Tests: test.sh passes (ASan+UBSan, TSan, JNI 205). EventDecoderTest,
DatabaseToolsTest and McpProtocolTest pass (108), compiled with the
Kotlin compiler outside Gradle. Revert proofs: reading every column as
text fails test_rows (BLOB read back as TEXT); recording rows with no
slot fails test_internal_rows; plain sqlite3_changes64 fails
test_changes. Not run here: Gradle, spotlessCheck, the Robolectric
tests, and overhead on a phone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAZ8yszEP4MqbR9PLba
spotlessKotlinCheck failed on 67355bd (the hand-off expected ktlint to
reflow): braces around the multi-line `when` branches in EventDecoder.kt
and a chained `containsExactly` in EventDecoderTest.kt. Formatting only,
from `spotlessApply`; `git diff -w` changes no tokens.

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

record_row passed p to utf8_cut before its `if (!p)` guard. sqlite3_column_text
returns NULL when SQLite runs out of memory (for example when it cannot
add the NUL terminator), while sqlite3_column_bytes can still return the
value's length; for a TEXT value longer than the limit, utf8_cut then read
through the NULL pointer, inside the app's own sqlite3_step, and the app
crashed. Before ADFA-7296 the extension never read column values, so the
path was new. stored is now 0 whenever p is NULL, for TEXT and BLOB.

No test: it needs SQLite to fail an allocation at that exact point, which
the host tests cannot arrange. test.sh passes (with the next commit):
ASan+UBSan 20745 checks, TSan 20726, JNI 205, 0 failures (system JDK).

CodeRabbit thread 4691490650.

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

sqlitedbg_read_events stops at the first record that doesn't fit its
buffer, and the server reads 256 KiB at a time (DatabaseTools.
EVENT_BATCH_BYTES). sqlitedbg_set_row_capture accepted any max_row_bytes,
and a row record was bounded only by half the ring (2 MiB by default), so
a large setting could make one record no reader can receive, and every
event after it would wait until the ring evicted it. Nothing sets the
limit yet (default 4 KiB), so this guards a future setting.

SQLITEDBG_MAX_ROW_BYTES (64 KiB) in sqlitedbg.h caps it; a larger value is
lowered to it. The tests' ring is 8 KiB, which caps a row first, so a
test-only getter (SQLITEDBG_TEST, like sqlitedbg_test_fail_init) shows
the limit in force: UINT32_MAX becomes 64 KiB, 1000 stays, 0 is 4 KiB.

Revert proof: with the cap removed, test_row_limits fails with
"sqlitedbg_test_max_row_bytes() == SQLITEDBG_MAX_ROW_BYTES (4294967295 vs
65536)"; restored, test.sh passes: ASan+UBSan 20745 checks, TSan 20726,
JNI 205, 0 failures (system JDK).

CodeRabbit thread 4691490645.

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

The README said the per-row cost "has not been measured on a phone yet".
It now gives the Galaxy J7 numbers from the native benchmark in #2311's
description (no client: +1.1 us for a 20-row SELECT, +0.6 us for a one-row
SELECT over ade5cc2; about 2.9 us per recorded row), and the 64 KiB cap
on a row's data from the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The README still listed the ring buffer's trace events as statement,
profile and close, and said SQLITEDBG_INTERFACE_VERSION is 2. This
change added row events and raised the version to 3 (sqlitedbg.h).
Both lines now say so; the version line keeps why it became 2.

Checked against sqlitedbg.h (SQLITEDBG_INTERFACE_VERSION 3,
SQLITEDBG_EVENT_ROW). No code change.

CodeRabbit review 6053222300, outside-diff comment (README.md:20, 49)

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

The malformed-row test patched an integer's stored_bytes to 4 but left
full_bytes at 8, so decodeRow refused it at the cut check (stored <
full with cut 0) and never reached the 8-byte width check for numbers.
The test passed with the width check removed.

The case now sets both stored_bytes and full_bytes to 4 and asserts the
width check's message ("number 0 is 4 bytes"), so only that check can
refuse it. Revert proof: with the width check removed, "a malformed row
is refused" fails; restored, it passes. testDebugUnitTest and
spotlessCheck pass.

CodeRabbit review 6053222300, nitpick (EventDecoderTest.kt:162)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Stage gained five PRs since ade5cc2: #2291 (ADFA-4654), #2292
(ADFA-7134), #2283 (ADFA-6945), #2293 (ADFA-7247, ADFA-7243) and #2298
(ADFA-7201).

No conflicts, and no file changed on both sides. This PR's own diff is unchanged: the +/- lines of
`git diff ade5cc2 4f971a8` and `git diff origin/stage HEAD` are
identical, in the same 9 files.

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

* style: spotless reformat of CgtTemplateBuilder, no functional change

ktlint's output for the whole file, before the ADFA-7287 change to it:
tabs, and one parameter per line. It also re-indents the JSON inside the
raw strings with tabs. JSON ignores that whitespace, so the templates
read the same, but a built .cgt's template.json bytes differ.

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

* ADFA-7287: Stop rewriting unchanged plugin templates at every start

Plugins build and register their .cgt templates in activate(), which
runs at every start. CgtTemplateBuilder left each zip entry's time
unset, so ZipOutputStream stamped the current time, and both the build
and the registration wrote unconditionally. Each start therefore wrote
every template twice, with the same contents and a new checksum.

- CgtTemplateBuilder gives every entry a fixed time (1980-02-01 00:00
  local, Gradle's choice for reproducible archives), builds the zip in
  memory, and writes the file only when its bytes differ.
- IdeTemplateServiceImpl.registerTemplate() copies only when the
  registered copy is missing or differs, and then skips the template
  list reload too. It still returns true.

Tests: CgtTemplateBuilderTest (4) and IdeTemplateServiceImplRegisterTest
(3) pass, as do PluginTemplateCleanupTest and
PluginManagerTemplateWiringTest. With the fixed time and the two
content checks taken out, the four tests aimed at them fail for the
reasons they name, and the three guard tests still pass.
:plugin-api:apiCheck passes.

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

* style: spotless reformat of IdeTemplateService, no functional change

Tabs for spaces, and no blank line after the interface's opening brace,
before the next commit adds KDoc to it.

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

* ADFA-7287: Address the independent review

- registerTemplate() compares the two files in 8 KB chunks instead of
  reading both whole, since a plugin may register a template of any
  size. In both comparisons a failed read counts as a difference, so
  the write is tried, as it was before.
- CgtTemplateBuilderTest changes one byte of a template without
  changing its length, so it pins the byte comparison: with length-only
  comparisons the changed-template tests fail.
  IdeTemplateServiceImplRegisterTest adds a 20,000-byte template that
  differs only in its last byte.
- The time-zone test uses Tokyo and Los Angeles, 17 hours apart in
  1980, and its failure message no longer prints both byte arrays.
- KDoc on CgtTemplateBuilder.build() and
  IdeTemplateService.registerTemplate() says an identical file is left
  untouched and no change is reported.
- The new log line uses {} placeholders.

The template-list reload that registerTemplate() now skips for an
identical copy was a no-op already: nothing calls
PluginManager.setTemplateReloadListener(). The template list rescans
the folder by itself.

Tests: CgtTemplateBuilderTest 4, IdeTemplateServiceImplRegisterTest 4,
PluginTemplateCleanupTest 3, PluginManagerTemplateWiringTest 3, all
pass. :plugin-api:apiCheck passes.

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

* ADFA-7287: Address the re-review

- sameBytes() also checks that the plugin's .cgt has ended, in case it
  grew after its length was read. Before, a longer .cgt compared equal
  to a copy that matched its first part.
- A comparison that cannot read a file now logs that at debug level
  before it falls back to writing. Two tests cover that path: a built
  .cgt and a registered copy that are unreadable, the same length and
  different in content are written again. With either catch no longer
  catching IOException, those two tests fail. They skip when the test
  runs as root, which can read any file.
- KDoc: build() promises the same bytes on one device, not everywhere
  (deflate output depends on the runtime's zlib), and names its
  IllegalArgumentException. registerTemplate() costs reading both
  files, not one.

Tests: CgtTemplateBuilderTest 5, IdeTemplateServiceImplRegisterTest 5,
PluginTemplateCleanupTest 3 and PluginManagerTemplateWiringTest 3 pass,
none skipped. :plugin-api:apiCheck passes.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…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
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
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
…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
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
…y's limits

execute ran a statement's RETURNING rows to the end and dropped them.
Now they come back in query's format (P2-2's: column types, storage
classes, hex BLOBs) within the same limits: max_rows (default 100, at
most 1000), the 4 MiB budget with the first row whole, cut cells
listed, has_more. No offset: paging would run the write again.

From the experiments (41621): SQLite makes every change and buffers
every returned row in the first sqlite3_step, so
- a statement stopped at a limit is reset, which commits all of it, and
  changes counts every row written; a failed commit at the reset is the
  call's error ("could not be committed, and nothing it changed was
  kept"; the rollback backstop ends the open transaction);
- a statement that fails at any step, even while its rows come back, is
  rolled back whole, so execute returns the error and no rows.

- C: bridge_query's row loop moves into read_rows, which both use.
  bridge_execute takes query's limits and returns [columns, rows,
  counts, decltypes, {changes, last_insert_rowid}].
- Kotlin: ServerConnection.execute takes QueryLimits; ExecuteResult has
  rows. The tool gains max_rows and returns the rows only for a
  statement with RETURNING. Description and README updated.

Limit (README): if the JVM fails to allocate a row mid-read, the
unfinished statement is finalized, which commits it while the call
reports the error.

Tests: JNI returningCaps:
- INSERT RETURNING id;
- UPDATE past a 3-row cap (3 rows, has_more, changes 50, all 50
  updated);
- the byte budget (first row only);
- a wide row cut;
- DELETE RETURNING cut short (all deleted);
- a failed commit at the reset (SQLITE_BUSY, nothing kept);
- the 1.5 s limit striking while 400,000 rows come back (first step
  about 0.5 s; SQLITE_INTERRUPT, nothing kept).
DatabaseToolsTest executeReturnsReturningRowsAsQueryDoes. test.sh 0
failures (JNI 564); JVM 133.

Revert proofs:
- returning rows on error fails "every row of a write past the time
  limit came back";
- ignoring the reset's rc fails "a write whose commit failed returned
  rows".

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
… change

ktlint wraps two long call chains in the new execute tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The case filled its 400,000-row table and ran its timing call through
execute, which stops any write after 1.5 s. With Gradle building
alongside, the setup UPDATE's first step passed 1.5 s and the JNI suite
aborted (review F02). The table is now filled on the app's connection,
which has no time limit. If the timing call is itself stopped, the case
prints a note and skips the stop-after-rows check instead of aborting.

Checked both ways: on a quiet machine the stop-after-rows check runs
(JNI 578 checks, no note); with the table made ten times bigger, the
first step passes 1.5 s and the case takes the note path and passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The tool text, DebugEngine, the README and a C comment said a statement
that fails "returns no rows and keeps nothing". Under FAIL conflict
resolution (OR FAIL, ON CONFLICT FAIL, RAISE(FAIL)) SQLite keeps, and in
autocommit commits, the rows changed before the failing one (review F01;
checked on 3.49.1: ABORT, ROLLBACK and their RAISE forms keep none and
leave sqlite3_total_changes64 where it was; FAIL moves it, and
sqlite3_changes64 is the number kept).

bridge_execute now adds "The N rows it changed before the failure were
kept: FAIL conflict resolution keeps them" to the error when the total
moved, and the texts say so. The README's accepted limit now covers any
allocation failure during or after the read, not only a row's (F03).

Tests: a JNI case with INSERT OR FAIL ... RETURNING (code 19, 2 rows
kept and counted) and a default ABORT one (nothing kept, nothing
claimed); DatabaseToolsTest checks the new tool text. Revert proofs:
with the old C, the JNI case fails on the kept-rows message; with the
old tool text, DatabaseToolsTest fails on the missing sentence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
FakeDebugEngine.readEvents still counted a 56-byte header, but this PR
grew the record header to 72 bytes (EventDecoder.HEADER_BYTES), and it
counted a ROW event's SQL, which is empty, instead of its values (#2311
review, 2026-11-26). No test failed, as none sized a batch to the byte.
The fake now uses EventDecoder's header and row sizes, made internal for
it, and a new test checks that its batches end where the C layer's
records in events.bin do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…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
A ROW record with columns = kept = Int.MAX_VALUE passed the kept <= columns
check, and ArrayList(kept) then threw OutOfMemoryError before the first
value's check could refuse the row, instead of the documented
IllegalArgumentException (CodeRabbit, #2311, 2026-11-26). Each kept value
takes at least ROW_VALUE_BYTES, so kept is now checked against the row's
length before the list is sized. Rows the C layer writes always pass.

Without the check, the new test's row throws "OutOfMemoryError: Requested
array size exceeds VM limit", and the build's -XX:+ExitOnOutOfMemoryError
ends the test JVM (exit 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…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
Mark the v8 ABI flavor isDefault in the shared build-logic, so a fresh
Android Studio sync selects v8Debug instead of v7Debug for every flavored
module. Build types are untouched: AGP already prefers debug.

CLI and CI builds name their variant explicitly and are unaffected. A
plain `./gradlew lint` now uses v8Debug, AGP's default variant. Existing
checkouts may keep their saved variant until .idea is reset.
CI builds of branches other than stage no longer run advzip on the APK; stage and release builds still do (debug.yml passes -Padvzip on stage). Branch builds save 200 to 300 s; their APK is about 3.7% larger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
davidschachterADFA and others added 8 commits December 1, 2026 17:29
…w-cut docs

Eviction: a statement evicted from its slot keeps its id on its STATEMENT and on the ROW
events recorded before the eviction. Its later rows are not recorded at all, and only its
PROFILE has 0. The header, the README and the test comment said the later ROW events had 0.
The eviction test now asserts that statement 0's ROW has exec_id equal to its STATEMENT's seq.

README: each ROW trace now makes one extra sqlite3_sql call, and that cost was not re-measured
(it said the per-row path was unchanged). The stale claim that the interface version is 3 is
gone; sqlitedbg.h has the current value. The limits note that in a UTF-16 database
sqlite3_column_bytes converts a whole TEXT value before the 1 MiB guard, and the code comment
no longer says it never copies. Behaviour is unchanged.

ROWS_CUT and Event.rowsCut also cover a row the producer could not record (a byte budget below
a row header, or an allocation failure), not only the per-statement row limit.

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

* ADFA-6958: Run the CI checks in their own job, alongside the APK build

Step 3 of the ADFA-6953 plan. The Universal APK job ran four checks
(apiCheck, the plugin-api and sqlite-debugger unit tests, and
spotlessCheck with the :common compile) one after another before the
assemble, about 123 s on a normal stage build. They now run in a new
job, "Run checks (API, unit tests, Spotless)", on a second runner at the
same time as the build, so they are off the critical path.

The build job still publishes nothing unless the checks pass: a new step
before the Google Cloud login waits for the checks job (GitHub API,
filter=latest so "Re-run failed jobs" sees the newest attempt) and fails
if it did not succeed. "Build Universal APK", the only status check that
stage's branch protection requires, therefore still fails on a failed
check, and branch protection needs no change.

The steps moved unchanged, with the same comments and error hint. The
checks job sets up the workspace the same way (checkout, flox,
google-services.json and its cleanup, INCLUDE_LLAMA_ASSETS=false).

Runner use over 2026-11-19..26: jobs waited a median 2 s for a runner,
5 of 885 waited over a minute, and all six runners were busy 0.1% of the
busy time, so the second runner per push should not cause queueing.

The sqlite-debugger README names the job its tests now run in.

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

* ADFA-6958: Cap the checks job at two workers; harden the wait step

From the independent review of the first commit:

- The six runners are three per machine (01/03/05 on one, 02/04/06 on
  the other, from the job logs), so the checks job often shares a
  machine with a build job. Over 2026-11-19..26, "Build Universal APK"
  jobs that shared their machine with another Gradle-heavy job for at
  least half their run took a median 1047 s, against 638 s with no
  neighbour (83 and 119 jobs). The machines have 30 cores (Gradle uses
  30 worker leases), and a full build uses all of them. --max-workers=2
  keeps the checks to two cores; they are off the critical path.
- curl gets --max-time 30, so a hung API call cannot stall the wait.
- The wait's limit is 40 minutes instead of 30. It counts from the wait
  step, so it must also cover the checks job waiting for a runner.
- The failure message says to use "Re-run failed jobs": re-running only
  the checks job leaves "Build Universal APK" failed.

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

* ADFA-6958: Give up waiting for the checks before the job times out

From the re-review: on 87 recent green builds the wait step would start
after a median 705 s, p90 1236 s and max 1554 s. A fixed 40-minute wait
on top of that could run into the build job's 60-minute timeout, which
shows a generic cancellation instead of the error. If the checks passed
at the last moment, the timeout could also stop the job after the App
Tester upload but before the Jira and Slack steps.

The job now records its start time in its first step, and the wait gives
up 5 minutes before the 60-minute timeout, leaving time for the publish
steps. The timeout itself is unchanged.

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

* ADFA-6958: Check the wait deadline before accepting success

From CodeRabbit: if the assemble itself ran past the 55-minute mark and
the checks had already passed, the wait step accepted success at once,
so publishing could start without the 5-minute reserve the step exists
to keep, and the job's timeout could fall between the App Tester upload
and the Jira and Slack steps.

The step now checks the deadline after each poll and before accepting
success. A failed check still reports as a failed check at any time.
Tested locally against real runs: success in time, success too late,
failure in time and too late, not found in time and too late.

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

* ADFA-6958: Cap the checks job's heap

gradle.properties lets Gradle and the Kotlin daemon each grow to 8 GB
of heap, and three runners share a machine with 30 GB and no swap.
From 2026-10-31 to 2026-11-26, four jobs lost a Gradle or Kotlin
process partway through, each while other Gradle builds ran on the same
machine, with no OutOfMemoryError logged (ADFA-7325). The checks job
adds a second Gradle job per push, so give its four Gradle calls 3 GB
for Gradle and 2 GB for the Kotlin daemon. The value replaces the
gradle.properties line, so it repeats that line's other flags.

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

* ADFA-6958: Say where to raise the checks job's heap, and point at the jvmargs copies

Independent review of 62fb3d5: only runner 02's machine was measured,
so say so; Gradle's and Kotlin's out-of-memory messages point at
gradle.properties, which CHECKS_JVMARGS overrides, so say to raise the
limit there; and gradle.properties now names the workflows that replace
its org.gradle.jvmargs line, so a new flag reaches them too.

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

* ADFA-6958: Say which out-of-memory hint overrides CHECKS_JVMARGS

Re-review of 18f735d: Kotlin's message points at kotlin.daemon.jvmargs,
which KGP applies after kotlin.daemon.jvm.options, so setting it in
gradle.properties would override this job's 2 GB, and the build's 8 GB.

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

* ADFA-6958: Stop the APK build when a check fails

Hal's review: a failed check must signal the assemble to abort, so the self-hosted
runners are not held for the rest of a ten-minute build that cannot be published.

The "Assemble Universal APK" step now runs Gradle in the background and polls the checks
job every 30 s while it runs (the same jobs API call, filter=latest, as "Wait for the
checks to pass"). If that job ends with anything but success, the step stops Gradle and its
whole process tree, fails with a message that says what happened and how to retry, and
nothing is published. If the checks succeed first it stops polling; if the build ends first
its exit status is passed through, then the D8 check runs as before. A trap stops the build
if the step itself is cancelled or times out, so the build cannot outlive its job.

The tree is stopped by parent pid, not by process group: Gradle's single-use daemon sits in
its own group but is a child of its client. "Install jq" moves above this step, which now
uses it. "Wait for the checks to pass" is unchanged and still decides whether to publish
when the build finishes first.

Tested locally with the step's real script: stubbed curl and flox for exit codes (abort on
failure and on cancelled, pass-through of a build failure, D8, API errors, SIGTERM to the
step), and a real Gradle build with a forked daemon that was stopped mid-task with no
process left behind. Not yet run on a runner.

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

* ADFA-6958: Wait for the build's processes to exit before ending the step

kill_tree sent SIGTERM and returned, and wait "$build" waits only for the
subshell, so the step could end while Gradle was still shutting down. The
runner's orphan cleanup caught it (Terminate orphan process: java), but the
step should not rely on that.

kill_tree now collects the process tree, sends SIGTERM, and returns only when
every process has exited (zombies count as gone), with SIGKILL after 30 s.

Tested with a stub whose child takes 4 s to exit after SIGTERM: the old
function returned after 0 s with the child still running; the new one waits
for it. The earlier scenarios (abort on failure or cancel, success, failing
build, D8 message, jobs API errors) and a real Gradle build give the same
results, and no Gradle process is left behind.

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

* ADFA-6958: Name the checks job once in the build job, and stop the tree once

Three findings from the independent review of the abort step:
- CHECKS_JOB moves from the two steps' env to build_apk's env. The checks
  job's name now has one copy, with comments at both ends. A rename that
  updated only one step's copy would have disabled the abort without a
  message.
- The abort branch clears the EXIT/INT/TERM trap before `exit 1`, so the
  trap no longer runs kill_tree a second time on the reaped build pid.
- kill_tree's unused loop counter becomes `_` (shellcheck SC2034).

kill_tree's comment now says that it does not wait after sending KILL.

Checked by running the extracted step under bash -e with stubbed flox and
curl. A failed or cancelled checks job gives exit 1 with kill_tree called
once; at bf390bf the same case calls it twice. A daemon that ignores
TERM is killed after the 30 s grace. A passing or running checks job gives
exit 0 without a kill. SIGTERM to the step gives exit 143. In every case
no stub process was left. actionlint is clean; with shellcheck, the two
changed steps report nothing.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
In a UTF-16 database, recording rows converts each TEXT value to UTF-8 in full before the 1 MiB
guard applies, so a large value costs its full size in memory and time. Android's own databases
and Room use UTF-8. The decision is to document this and not change the behaviour, so the README
now states it as an accepted limit instead of "not fixed yet".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The SQL of a PROFILE is cut at the test's 64-byte limit and keeps a leading comment, so the
earlier WITH ... INSERT case never found its event. It now uses a shorter statement that fits.

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

EventDecoder now requires full_bytes to equal stored_bytes for INTEGER and FLOAT, and zero for
NULL. The producer never cuts these, so a record that says otherwise is malformed. A new test
feeds INTEGER 8/9, FLOAT 8/9 and NULL 0/1, each flagged cut, and expects
IllegalArgumentException.

FakeDebugEngine.addEvent(Event) renumbers the event. A STATEMENT whose execution id equals its
seq now gets the new seq as its id too, as a native STATEMENT has. Null ids and the parent ids
of ROW and PROFILE events are left alone. A new FakeDebugEngineTest case covers it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…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
… 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, 6b745ce merges #2319 at 6958e2f: #2311's ADFA-7379 review fixes (see #2311) and #2319's fuller execution_id description. Two README conflicts, resolved to the incoming lines plus this branch's own execute lines; every other file matches the incoming change. test.sh 0 failures (32,204 / 32,207 / JNI 691), unit tests 146, spotlessCheck.

davidschachterADFA and others added 3 commits December 1, 2026 21:11
Clean merge. Brings in stage's checks job (ADFA-6958), which now runs the
sqlite-debugger unit tests outside build_apk, and the other stage changes since
the last merge.

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

CodeRabbit's re-review summary of #2319 (review 7331550099) raised five
points that hold up:

- DatabaseTools.kt: the VALUES_NOTE KDoc said every tool that returns
  cells uses it; only query and get_events do.
- sqlitedbg_jni.c: the named-binding error messages cut a parameter name
  or key at 100 bytes with %.100s, which could split a UTF-8 character
  and show U+FFFD. utf8_prefix moves above bind_named and cuts on a
  whole character at the four places a name is shown.
- JniQueryTest.java: new cases for a gap in the middle of ?NNN (?1, ?3
  with an object), one bare key binding both :id and @id, and an
  unknown key over 100 bytes (CJK and Latin-1 text) shown as a
  whole-character prefix.
- README.md: the stale-after-schema-change limit now names declared
  types (column_types) as well as column names.

Each new test fails without its fix: the old %.100s code fails the
long-key case (2 failures), skipping the gap check fails the ?1, ?3
case, and stopping a bare key from filling a second parameter throws
at the :id/@id case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…s) into ADFA-7304

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, b8e04e7 merges #2319 at 4eccd33: the fixes for CodeRabbit's review summary of #2319 (KDoc wording, whole-character cuts of long parameter names in error messages, three new JNI binding tests, a README limit that now names declared types). One README conflict: this branch had reworded the time-limits line next to the changed one, and both lines are kept. Each file's changed lines equal 4eccd33's, so this PR's own diff is unchanged and there's nothing new to review here. Tests: test.sh 0 failures (ASan+UBSan 32,203 checks, TSan 32,210, JNI 701), :subprojects:sqlite-debugger:testDebugUnitTest (146), spotlessCheck.

…built

CodeRabbit (4748285282): if building the error that says what became of
an unfinished write fails too, the caller gets the OutOfMemoryError from
building it, without the outcome. The comment above
report_unfinished_write said the original exception is kept then, which
was wrong; it now says what happens. The README records the gap as an
accepted limit for every error the JNI layer builds: it takes a second
allocation failure right after the first, and reserving the error would
mean building it before every write. No code change.

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, 5dc2581 answers CodeRabbit's follow-up on sqlitedbg_jni.c (thread): if building the error that says what became of an unfinished write fails as well, the caller gets the OutOfMemoryError from building it, without the outcome. The comment above report_unfinished_write said the original exception was kept, which was wrong; it's corrected. The README now records the gap as an accepted limit for any error the JNI layer builds: it takes a second allocation failure right after the first, and reserving the error would mean building it before every write. Comment and README only. Tests: test.sh 0 failures (ASan+UBSan 32,202 checks, TSan 32,201, JNI 701), :subprojects:sqlite-debugger:testDebugUnitTest (146), spotlessCheck.

Daniel-ADFA and others added 14 commits December 3, 2026 09:12
ADFA-6572: Wrap the banner's action buttons when they don't fit on one row
* style: spotless reformat, no functional change

* ADFA-7365: Match system bar icon color to the bar color on BaseIDEActivity screens
record_row read every BLOB and TEXT value up to 1 MiB to keep its prefix.
sqlite3_column_blob materializes a zeroblob, which stays virtual until read, on
the app's own statement: an allocation of the zeroblob's full size. If that
allocation failed, the app's next step failed and its finalize returned
SQLITE_NOMEM (CodeRabbit, review 6143153271).

SQLite's API can't tell a zeroblob from a stored BLOB, so a BLOB is now read
only when it fits the limits; a larger one keeps only its size, with the value
marked cut. Its prefix is lost: an accepted limit. A TEXT has no virtual form,
so it is still read up to 1 MiB for its prefix.

Tests: test_blob_over_limit binds a 200 KiB zeroblob with row capture on and
checks, through a counting allocator, that no allocation reaches 128 KiB, that
the app's step and finalize succeed, and that the row keeps the size and no
bytes. The row-limit tests and the 1 MiB case now expect a cut BLOB to keep no
bytes; the 1 MiB case reads a TEXT instead. events.bin and events.tsv are
regenerated (test.sh --update-fixture): the fixture's cut BLOB keeps no bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…the value limit) into ADFA-7297

Brings #2311's zeroblob fix (CodeRabbit review 6143153271) and the stage merge 949037f.
One conflict, in the sqlite-debugger README's rows section: the ROW line keeps #2319's
text (only #2319 changed it), the value-reading line takes #2311's (only #2311 changed it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Since #2311 reads a BLOB only when it fits the value limit, a cut BLOB in a row
event keeps no bytes (hex empty, bytes 0), and only a TEXT keeps its first 256
bytes (none past 1 MiB). The get_events description and the README said both were
cut at 256 bytes.

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

Follows a82ea5c (a BLOB is read only when it fits the value limit). The
sqlitedbg_set_row_capture and sqlitedbg_row_value comments said TEXT and BLOB values
over the limit are cut, and that only a value over 1 MiB keeps no bytes;
RowValues.cutIndexes now says a cut BLOB is an empty ByteArray. Comments only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
The KDoc said TEXT and BLOB values are cut at maxValueBytes; since #2311 a longer
BLOB keeps no bytes. Comment only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… cut BLOB keeps no bytes) into ADFA-7297

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
… docs) into ADFA-7304

Brings #2311's a82ea5c (a BLOB is read only when it fits the value limit) and
24e09d4, the stage merge 949037f, and #2319's doc commits 460ea42 and ab81763.
One conflict, three lines of the sqlite-debugger README: each line comes from the one
side that changed it (Bound parameters and Limits from #2332, the get_events row line
from #2319).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
Since a82ea5c a cut BLOB keeps no bytes, so its size is all that is known of it.
The extension records it (full_bytes), but EventDecoder dropped it. RowValues.cutSizes
now holds the size of each value in cutIndexes; it defaults to empty for sources that
don't record sizes. EventDecoderTest checks the fixture row's two cut values (6 and 5
bytes); without the decoder change it fails there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
…'s whole size) into ADFA-7297

One README conflict, two adjacent lines: the ROW line keeps #2319's text (only #2319
changed it), the value-reading line takes #2311's (only #2311 changed it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh2DAYT7GPoC2cDzo8LErn
A cut BLOB keeps no bytes (ADFA-7296), so get_events showed only an empty
hex and bytes 0 for it. Each row event now carries cut_sizes: the whole size
in bytes of each cut value, in the order of cut_values, from
RowValues.cutSizes (null when the source records no size).

Tests: getEventsReturnsRowsAndChangeCounts checks a cut BLOB's hex is empty,
its bytes 0 and its cut_sizes entry 300, and that an uncut row has an empty
cut_sizes; the fixture test checks cut_sizes against the decoded sizes.
Without the cut_sizes line both fail reading cut_sizes.

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

Brings #2311's fa77bd4 (RowValues.cutSizes, filled by EventDecoder) and #2319's
417b785 (get_events gives cut_sizes), with #2319's merge caae57d. One conflict,
three lines of the sqlite-debugger README: each line comes from the one side that
changed it (Bound parameters and Limits from #2332, the get_events row line from #2319).

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

4 participants