Skip to content

Fix remaining Web UI review feedback from #110210 - #115103

Merged
alexey-milovidov merged 10 commits into
masterfrom
fix-110210-review-feedback
Aug 21, 2026
Merged

alexey-milovidov merged 10 commits into
masterfrom
fix-110210-review-feedback

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

Related: #110210

Fixes three review findings discovered shortly before #110210 merged: recognize inline input following WITH/EXPLAIN-wrapped INSERT, restore plain each-row JSON HTTP errors exactly as displayed live, and clear stale Download/Copy state when a result pane is reset.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...


Workflow [PR]
Sync PR [sync-upstream/pr/115103]

Version info

  • Merged into: 26.8.1.1823 (included in 26.8 and later)

@clickhouse-gh

clickhouse-gh Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5f11232]

Summary: ✅


AI Review

Summary

This PR tightens Web UI handling for inline-INSERT detection, failed each-row HTTP snapshot replay, and stale Download/Copy state. The snapshot and stale-action fixes look sound, but the new WITH / EXPLAIN prefix walk still misclassifies valid leading-WITH inserts whose CTE expression starts with an ordinary bare word, so the page can still treat inline payload as SQL.

Findings

⚠️ Majors

  • [programs/server/play.html:13717] The new CTE handling only skips keyword-shaped aliases, but a leading WITH list can contain arbitrary top-level scalar expressions before the real statement keyword. WITH toInt32(1) AS x INSERT INTO FUNCTION null('line String') FORMAT LineAsString\nFORMAT JSONCompactColumns still returns on toInt32, so the page treats the second FORMAT as a real output clause again; the same shape with post-format SETTINGS framing_output_format = 'None' makes detectFramingSetting read inline payload as query SQL.
  • Suggested fix: keep walking the leading WITH expression list until it resolves to the actual statement keyword, mirroring statementIsReadOnly, instead of returning on the first non-alias bare word.
Tests
  • ⚠️ Add a regression for a scalar CTE expression such as WITH toInt32(1) AS x INSERT INTO FUNCTION null('line String') FORMAT LineAsString\nFORMAT JSONCompactColumns and the analogous post-format SETTINGS case, ideally in both the fallback harness and the lexer-backed framing/format mirrors.
Final Verdict

Changes requested.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.90% 86.90% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 79.20% 79.20% +0.00%

Changed lines: Changed C/C++ lines covered: 66/67 (98.51%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 17, 2026
Comment thread programs/server/play.html Resolved
Only treat a plain each-row exception object as an HTTP error carrier when it matches the persisted displayed error, preserving partial rows on transport failure replay.

#115103
Comment thread programs/server/play.html Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 5f11232a4 with master 90a20ccf8 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 703.89 MiB 700.85 MiB -3.04 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

6 translation units recompiled, 3 s compile time in total, 6 of them have a recent master baseline.

Job report

Comment thread programs/server/play.html Resolved
Comment thread programs/server/play.html Resolved
…refix

`ParserExplainQuery` hands `EXPLAIN AST ...` to the full `ParserQuery`, so the
statement wrapped by a leading `EXPLAIN` can be of any kind. Enumerating the
non-`INSERT` statement starters therefore cannot be complete: `EXPLAIN AST
DETACH TABLE insert FORMAT TabSeparated` kept scanning past `DETACH`, let the
table name `insert` set `saw_insert`, and made `detectExplicitFormatClause` drop
the real trailing `FORMAT` clause as if it were inline `INSERT` input. The same
gap existed for `ATTACH`, `UNDROP`, `COPY` and every other missing starter.

Invert the condition instead: keep walking only while the prefix itself is still
unresolved. For a `WITH` prefix nothing is left after the alias skip, so any
other bare word resolves the statement; for an `EXPLAIN` prefix only the
`EXPLAIN` kind words of `ParserExplainQuery` and its optional settings list can
still precede the wrapped statement. An unlisted word now only stops the walk
earlier, which is the safe direction.

Also fix the new `renderFailedSnapshot` regression in
`image_preview_harness.js`: it still used the old five-argument signature, so
`plain_http_each_row_error` was `undefined` and the positive case exercised the
raw-plus-error replay path rather than the new provenance-based restore. Pass
the persisted provenance bit explicitly for both cases, and add fallback
tokenizer regressions for the `EXPLAIN` / `WITH`-wrapped non-`INSERT`
statements and for `EXPLAIN PLAN header = 1 INSERT ...`.
Comment thread programs/server/play.html
}
/// `ParserInsertQuery` accepts a leading `WITH`; `ParserExplainQuery` can wrap that
/// insert. Keep scanning those prefixes until their top-level `INSERT`, while returning
/// as soon as they resolve to a non-insert statement such as `WITH ... SELECT`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Scalar WITH expressions can still hit the fallback return tokens path before the real statement keyword appears. ParserInsertQuery accepts leading CTE elements like toInt32(1) AS x, so a query such as:

WITH toInt32(1) AS x
INSERT INTO FUNCTION null('line String') FORMAT LineAsString
FORMAT JSONCompactColumns

is still a valid inline-INSERT. Here the top-level bare word toInt32 is neither an alias nor insert, so this walk bails out before it ever sees the real INSERT, and detectExplicitFormatClause starts treating the second FORMAT JSONCompactColumns as a real output clause again. The same shape with SETTINGS framing_output_format = 'None' after LineAsString makes detectFramingSetting scan post-format payload as query SQL.

This needs the same kind of leading-WITH walk as statementIsReadOnly: keep skipping ordinary CTE expression tokens until the list resolves to the actual statement keyword, not only the alias positions.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Aug 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 21, 2026
Merged via the queue into master with commit 822ae90 Aug 21, 2026
177 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-110210-review-feedback branch August 21, 2026 03:10
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants