Repository navigation
Conversation
`ASTCreateQuery::isParameterizedView` returns true whenever the SELECT
body has any query parameter, which made `executeQueryImpl` skip
`ReplaceQueryParameterVisitor` entirely. A `{db:Identifier}` placeholder
in the database name was therefore never substituted, leaving
`create.getDatabase()` empty and aborting the server in debug builds
(`assert(!database_name.empty())` in `DatabaseCatalog::tryGetDatabase`).
In release builds the empty database name silently produced an
`UNKNOWN_DATABASE` error late in the CREATE flow.
The visitor now handles parameterized views directly: it substitutes
parameters in the DDL parts of the create query (database name, table
name, columns list, storage, view targets) while keeping the SELECT
body's placeholders intact, so they remain available for substitution
at view-call time.
Discovered by the AST fuzzer (STID 3282-3691):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=ffc21883c7b374f0aed9c9bed5924341b680833e&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_debug%29
|
Pre-PR validation gate (per TASK.md): a) Deterministic repro? Yes. The reproducer above aborts on master 100% of the time and succeeds with this fix. b) Root cause explained? c) Fix matches root cause? The visitor now runs on every create query but for parameterized views it walks all immediate children except d) Test intent preserved? All 13 existing non-zookeeper parameterized view tests pass locally: e) Both directions demonstrated? Yes:
f) Fix is general, not a narrow patch? The branch in Session: cron:clickhouse-ci-task-worker:20260525-201500 |
|
cc @evillique @KochetovNicolai could you review this? It fixes an assertion (STID 3282-3691) where parameter substitution was skipped for the entire CREATE statement when the SELECT body of a parameterized view contained a query parameter. |
|
Workflow [PR], commit [1a463a4] Summary: ✅ AI ReviewSummaryThis PR fixes parameter substitution for Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: 96.30% (26/27) · Uncovered code |
ASTCreateQuery::isParameterizedViewreturns true whenever the SELECT body hasany query parameter, which made
executeQueryImplskipReplaceQueryParameterVisitorentirely. A{db:Identifier}placeholder in thedatabase name was therefore never substituted, leaving
create.getDatabase()empty and aborting the server in debug builds (
assert(!database_name.empty())in
DatabaseCatalog::tryGetDatabase). In release builds the empty databasename silently produced an
UNKNOWN_DATABASEerror late in the CREATE flow.The visitor now handles parameterized views directly: it substitutes parameters
in the DDL parts of the create query (database name, table name, columns list,
storage, view targets) while keeping the SELECT body's placeholders intact, so
they remain available for substitution at view-call time.
Reproducer (asserts on master, succeeds after the fix):
Discovered by the AST fuzzer (STID 3282-3691). Master CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=ffc21883c7b374f0aed9c9bed5924341b680833e&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_debug%29
Regression test:
04276_create_view_param_db_with_param_select.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed an assertion in
DatabaseCatalog::tryGetDatabase(and resultingUNKNOWN_DATABASEerror in release builds) when creating a parameterized view whose database name is supplied via a query parameter, for exampleCREATE VIEW {db:Identifier}.v AS SELECT {p:UInt64}. Parameters in the DDL parts of theCREATEstatement are now substituted at create time, while parameters in the SELECT body remain available for substitution at view-call time.Documentation entry for user-facing changes
Version info
26.6.1.149