Skip to content

feat(history): record a multi-statement run one statement at a time - #602

Merged
EVWorth merged 1 commit into
mainfrom
feat/history-per-statement
Sep 10, 2026
Merged

EVWorth merged 1 commit into
mainfrom
feat/history-per-statement

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Closes #329.

Stacked on #601 (→ #600 → #599 → #598 → #597 → #593 → #584). The commit to read here is the last one.

A script executed as one batch recorded one history entry for the whole thing. A script whose third statement failed showed as one opaque failure, with no way to tell which line to look at.

The pairing is the backend's

QueryResult now carries the statement it came from, and QueryError carries the index of the statement that failed. The executor already splits the script to run it — splitting the text again in the frontend would be a second splitter to keep in step with the first, and they wouldn't stay in step.

CoreError gains an AtStatement wrapper rather than an index on every variant: only the multi-statement executor knows the index, and only a caller that has to point at a line cares. Its Display passes straight through, so nothing that merely reads the message has to know it exists.

Two honest limits

Verified on a live server

MySQL 8: SELECT 1; SELECT 2; SELECT * FROM definitely_not_a_table reports statement_index: 2 and code 1146; each result names its own statement. Both are permanent integration tests.

One test that was passing for the wrong reason

The makeQueryResult fixture had no sql, so the success-path assertions were exercising the fallback rather than the new path. Fixed, which surfaced a test whose fixture disagreed with the SQL it claimed to run.

Verification

2 live integration tests, 4 new store tests. Full suite 1911 passing, clippy clean, 0 lint errors.

A script executed as one batch recorded one history entry for the whole
thing. A script whose third statement failed showed as one opaque failure,
with no way to tell which line to look at (#329).

Each QueryResult now carries the statement it came from, and QueryError
carries the index of the statement that failed. The pairing is the
backend's: the executor already splits the script to run it, and splitting
the text again in the frontend would be a second splitter to keep in step
with the first, which they would not stay.

CoreError gains an AtStatement wrapper rather than an index on every
variant — only the multi-statement executor knows the index, and only a
caller that has to point at a line cares. Its Display passes straight
through, so nothing that only reads the message has to know it exists.

The frontend records one entry per result. Row counts are per statement.
Timing is not: the batch's elapsed time is repeated on each entry, because
per-statement timings are not measured separately and inventing a split
would be worse than repeating the one number that is true.

A result with no statement text falls back to the whole script, so a
backend that does not report it leaves the panel showing what ran rather
than an empty row. The SQLite executor is that case today.

Verified against live MySQL 8: a three-statement script whose last
statement hits a missing table reports statement_index 2 and code 1146,
and each result names its own statement.

Closes #329

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth force-pushed the feat/history-per-statement branch from df3c3a7 to 22a56a8 Compare September 10, 2026 01:04
@EVWorth
EVWorth merged commit 2efdbc1 into main Sep 10, 2026
12 checks passed
@EVWorth
EVWorth deleted the feat/history-per-statement branch September 10, 2026 01:06
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.

[P1/bug] Multi-statement execution records a single history entry; loses per-statement structure

1 participant