Repository navigation
Conversation
A view, materialized view, column DEFAULT/MATERIALIZED/ALIAS expression or mutation command stored `assignCentroid(v, 'dict')` with the bare name, because AddDefaultDatabaseVisitor qualified only the first argument of dictGet. The name was then resolved in the current database of whoever used the definition: reading the view or inserting from another database failed with `Dictionary not found` or used a same-named dictionary there, and a mutation, which runs in the server context, always failed. getDictionaryNameArgumentPosition gives the position of the name for both functions. The visitor qualifies the String literal of assignCentroid only in a new definition: a CREATE that is not a replay of stored metadata (isReplayedTableDefinition), and every ALTER, which is never replayed from metadata. A replayed definition (short ATTACH, startup, RESTORE, Replicated replay and recovery) keeps the stored name: without a loading dependency the dictionary may not be registered yet, so qualifying there would depend on the attach order, and RESTORE refuses a created definition that differs from the one in the backup. RESTORE ... AS renames a qualified name, for a literal only, because an identifier in that position is an expression. Deliberately unchanged: the dependency visitors, since a loading edge like the one of dictGet would refuse a dictionary <-> table cycle that is accepted today, at CREATE and at startup; and the legacy metadata repair, which would need that edge to be deterministic. Definitions stored by older versions keep resolving in the reader's database. During a rolling upgrade of a Replicated database, an ALTER applied by an old replica stores the bare name there. Addresses ClickHouse#123711 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the self-describing helper comment and the ALTER flag narration; condense the setIsNewDefinition comment to one line. 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; 1 finding) plus my own cold review (3 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261009-192200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261009-180500 |
|
Workflow [PR], commit [fe8c6db] Summary: ✅
AI ReviewSummaryThe PR qualifies literal dictionary names in new stored Final Verdict✅ Approve |
…tabase An ALTER issued from another current database qualified the name against the session database. assignCentroid is not validated against that database at ALTER time, so a name that exists only in the table's database was stored bare: the ALIAS, DEFAULT or mutation then failed with Code 36 when used from any other database, and a same-named dictionary in the session database was bound instead of the table's one. Bind it to the altered table's database, like the table names of the same ALTER, and like a Replicated database already does, whose replicas run the ALTER with that database as the current one. dictGet keeps the session database, because its ALTER validation resolves the name there. CREATE is unchanged: the visitor database is the session database there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units41 translation units recompiled, 383 s compile time in total, 41 of them have a recent master baseline. |
…lify-new-stored-definitions Conflicts in AddDefaultDatabaseVisitor.h and InterpreterCreateQuery.cpp: master removed the post-UDF qualification pass (ClickHouse#130531, the revert of ClickHouse#114923), and this branch had added its assignCentroid literal branch and a setIsNewDefinition call there. Resolved by taking master's removal: like dictGet, a dictionary name brought in by a SQL UDF body is no longer qualified at CREATE. The full traversal and the ALTER path keep this branch's qualification unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #123711
Related: #123711 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
Dictionary not found, or silently reading a same-named dictionary of another database, when a view, a materialized view or a columnDEFAULT/MATERIALIZED/ALIASexpression that callsassignCentroid(vec, 'dict')is used from another current database, and fixALTER TABLE ... UPDATE ... = assignCentroid(vec, 'dict')mutations failing withDictionary not found. The dictionary name is now qualified with the database when the definition is created, like the one ofdictGet.Description
On 26.9.9.28,
CREATE VIEW a.v AS SELECT id, assignCentroid(v, 'centroids_dict') AS c FROM a.vectorsread while the current database isbfails withCode: 36 ... Dictionary (centroids_dict) not found, and returns the centroids ofb.centroids_dictifbhas one.ALTER TABLE a.t UPDATE c = assignCentroid(v, 'centroids_dict') WHERE 1fails its mutation even when issued froma, because a mutation runs in the server context.AddDefaultDatabaseVisitorqualified the dictionary name of stored definitions only fordictGet(argument 0).assignCentroidtakes it in argument 1, so the bare name was stored and later resolved in the current database of whoever used the definition. #123711 fixed the same problem at query time.The visitor qualifies the
assignCentroidliteral only in a new definition: aCREATEthat is not a replay of stored metadata (isReplayedTableDefinition), and everyALTER, which binds it to the altered table's database also when issued from another current database, as a Replicated database already does (dictGetkeeps the session database, where itsALTERvalidation resolves it). A shortATTACH, server startup,RESTOREand Replicated replay keep the stored name: without a loading dependency the dictionary may not be loaded yet, so qualifying there would depend on the attach order.RESTORE ... ASrenames a qualified name.The dependency graphs are not changed: a loading dependency like the one of
dictGetwould refuse a dictionary/table cycle that is accepted today. Definitions stored by older versions keep resolving in the reader's database. I can make it identical todictGet(dependency plus legacy repair) if refusing that cycle is acceptable.Validation: the new test fails on master and passes with the fix, 50/50 with randomized settings and 20/20 with a Replicated database. Old metadata loads unchanged across 3 restarts.
Workflow [PR]
Sync PR [sync-upstream/pr/124989]