Repository navigation
Hide a Backup locator named like a COLUMNS matcher in EXPLAIN AST instead of throwing - #122870
Conversation
…T` instead of throwing
With secrets hidden, `EXPLAIN AST` replaces a secret argument with the
masked SQL the secret finder produces for the formatter, parsed back, and
sets the argument's alias on the result. The `Backup` database rule wrote
the locator function name unquoted, so `` `t.COLUMNS`('x') `` was masked as
`t.COLUMNS('[HIDDEN]')`, which parses back as a qualified `COLUMNS`
matcher. A matcher cannot carry an alias, so `EXPLAIN AST` threw
`Can't set alias ... (LOGICAL_ERROR)`.
Print the locator name with `backQuoteIfNeed`, as `ASTFunction` prints a
function name, so the masked text reads back as the same function and
keeps its structure in the dump. In `replaceWithMaskedText`, hide the
argument whole when the parsed text cannot carry an alias, as it already
did for text that does not parse: a bare `COLUMNS` name stays unquoted in
both the formatter and the finder, and the reconstructed `S3(...)` locator
writes a named-collection identifier as written, so its text can also end
in a matcher.
Closes ClickHouse#122810
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings), after my own cold review of the same head (3 nits, none blocking).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20260929-113800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260929-105300 |
|
Workflow [PR], commit [f49a2e4] Summary: ✅
AI ReviewSummaryThis PR fixes the Final Verdict✅ No findings. I did not post any inline review comments. LLVM Coverage ReportMeasured on commit f49a2e4.
Changed lines: Changed C/C++ lines covered: 11/11 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 14 s compile time in total, 8 of them have a recent master baseline. |
CI finish ledger - e585aa1Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
146 of 146 check runs completed (104 passed, 41 not selected, 1 red: the job above), Session id: cron:our-pr-ci-monitor:20260929-163137 |
|
@groeneai Make the PR merge ready |
|
Thanks. The only red job was |
Cherry pick #122870 to 26.7: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
…NS` matcher in `EXPLAIN AST` instead of throwing
Cherry pick #122870 to 26.8: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
…NS` matcher in `EXPLAIN AST` instead of throwing
Cherry pick #122870 to 26.9: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
…NS` matcher in `EXPLAIN AST` instead of throwing
Backport #122870 to 26.7: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
Backport #122870 to 26.8: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
Backport #122870 to 26.9: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
Cherry pick #122870 to 26.3: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
…NS` matcher in `EXPLAIN AST` instead of throwing
The prerequisite #120313 (`EXPLAIN AST` secret hiding) reached 26.3 through #123453 after this cherry-pick was created, so merge 26.3 first. The only remaining conflict is the include list: keep 26.3's includes and add `Parsers/ASTWithAlias.h`, which the fix needs. `ASTSubquery.h` and `ASTTablesInSelectQuery.h` are master-only context and are not needed here. Backport of #122870 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Backport #122870 to 26.3: Hide a `Backup` locator named like a `COLUMNS` matcher in `EXPLAIN AST` instead of throwing
Closes: #122810
Related: #120313
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
With secrets hidden (the default),
EXPLAIN AST CREATE DATABASE d ENGINE = Backup('db', `t.COLUMNS`('x'))throwsCan't set alias '' of t.COLUMNS('[HIDDEN]')(LOGICAL_ERROR), which aborts debug and sanitizer builds. Found by the automated review of #120313 (#122810).EXPLAIN ASTreplaces a secret argument with the masked SQL the secret finder builds for the formatter, parsed back, and sets the argument's alias on it. TheBackuprule wrote the locator name unquoted, so the masked text parses back as a qualifiedCOLUMNSmatcher, which cannot carry an alias.The change:
backQuoteIfNeed, asASTFunctionprints a function name, so the masked text reads back as the same function (the dump keeps the locator's structure, andquery_logkeeps the quotes);replaceWithMaskedTexthides the argument whole when the parsed text cannot carry an alias, as it already did for text that does not parse. This covers a bareCOLUMNSlocator, which stays unquoted, and theS3(...)reconstruction, which writes a named-collection identifier as is (Mask the S3 locator of aBackupdatabase with the same rule asBACKUP ... TO#122776 quotes it).Validation: the new test fails on master with the
LOGICAL_ERRORand passes with the fix (50/50 randomized runs); reverting either half alone reddens it. Using each of the 421 single-word keywords as the locator name, with two argument shapes, gives noCan't set aliaswith the fix. In debug builds,`COLUMNS`('x')still fails earlier in the AST formatting check; that is the formatter issue #121162 addresses.Not for changelog: #120313 is in no release yet. Its cherry-picks to 26.3, 26.7, 26.8 and 26.9 (#122800 to #122803) are open, so this needs
pr-must-backportas well.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122870]
Version info
26.10.1.1058-master(included in26.10and later)26.9.9.25,26.8.16.35,26.7.20.26,26.3.40.17