Repository navigation
Revert "Make a table read by a scalar subquery in a CONSTRAINT a loading dependency" - #130531
Conversation
…nt-subquery-loading-dependency" This reverts commit 659cc1c, reversing changes made to f75df10. Conflicts resolved by removing only what ClickHouse#114923 added: the narrow qualification pass in AddDefaultDatabaseVisitor.h is removed together with the parts ClickHouse#114908 later added inside it; InterpreterCreateQuery.cpp keeps the expansion bound of ClickHouse#122362 on the neighbouring call; the string overload of qualifyDictionaryNameWithDatabase in ExternalDictionariesLoader is kept, because the dictionary usage record of ClickHouse#121567 is built on it. 04908_constraint_subquery_loading_dependency.sh (edited by ClickHouse#124408) is deleted with the rest of the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the revert, the only caller of `addWithAliases` passes `only_recursive_with_hides_table = true`, so `collectWithExpressionAliases` is never called and `with_expression_aliases` is never written: `isExpressionAlias(name)` equals `expression_aliases.contains(name)` on every remaining path. Remove the parameter, the member and both helpers (added by ClickHouse#114908 for the removed pass); the full traversal behaves as before. The second sentence of the comment on the string overload of `qualifyDictionaryNameWithDatabase` named the removed metadata-load caller. 05233_udf_expansion_with_alias_scope (ClickHouse#114908) and 05317_udf_dictget_alias_column_lightweight_delete (ClickHouse#123563, issue ClickHouse#123489) test the qualification of the names a SQL UDF brings into a CREATE, which the revert removes; both fail on the revert commit and are deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
cc @tavplubix @PedroTadim: this is the revert of #114923 you asked for on #129485; @alexey-milovidov as its author. Could one of you add the |
…itly The case relied on `CREATE` adding the current database to the `joinGet` table name, which this revert removes. The unqualified name was then resolved against the test database at `ATTACH`, so the case no longer covered a dropped database and the server logged `Replacing outdated dependencies` to stderr. Related: ClickHouse/clickhouse-private#86905 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The revert drops `#include <Databases/DatabaseOnDisk.h>` from TablesLoader.cpp, but `removeUnresolvableDependencies` now does a `dynamic_cast` to `DatabaseWithOwnTablesBase` (12cee6e, merged on 2026-11-09), which got its declaration only through that include. The merge queue build of this PR failed with `unknown type name 'DatabaseWithOwnTablesBase'`. Include the header that declares it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The merge queue could not build this PR ( |
|
The CI failure is unrelated |
…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]>
Backport of the revert of #114923 (CONSTRAINT scalar-subquery loading dependency) to 26.10. Conflict: 05397_implicit_minmax_index_alias_unresolvable_attach.sql does not exist on 26.10 (it is a master-only test the revert only re-qualified), so it is kept absent rather than introduced here.
…uery in a CONSTRAINT a loading dependency"
Backport #130531 to 26.10: Revert "Make a table read by a scalar subquery in a CONSTRAINT a loading dependency"
Master reverted ClickHouse#114923 (ClickHouse#130531), which removed the `current_database` parameter of `getLoadingDependenciesFromCreateQuery` and the narrow qualification pass (`visitTableExpressionsImpl`) of `AddDefaultDatabaseVisitor`. Resolution: - `AddDefaultDatabaseVisitor.h`: take master, dropping the narrow pass and the members only it used; keep the static alias helpers of this PR which `DDLDependencyVisitor` uses. - `DDLLoadingDependencyVisitor`: keep the `current_database` and `engine_arguments_database` parameters of this PR (the constraint subquery part of ClickHouse#114923 stays removed). At startup, `TablesLoader` passes the default database of the server, which keeps the behaviour of master there. - Call sites in `DatabaseMemory`, `DatabaseOrdinary`, `InterpreterCreateQuery`: keep this PR's version. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st the session database Review threads: ClickHouse#92472 (comment) ClickHouse#92472 (comment) The column expressions (`DEFAULT`, constraints, ...) and the table engine with all of its arguments are evaluated in the context of a query, so an unqualified name in them is resolved against the current database of the session, not against the database owning the table. Only the query of a view is bound to the owning database. Rename `engine_arguments_database` to `execution_database` and apply it to these subtrees: - `DDLDependencyVisitor` visits the columns, the storage and the view targets with a nested visitor while `current_database` is overridden, and skips them in the outer traversal. Before, the `SCOPE_EXIT` in `visitTableEngine` restored the database before the depth-first traversal reached the arguments, so `dictGet` in the sharding key of `Distributed` was resolved against the owning database. - `DDLLoadingDependencyVisitor` looks only at such expressions, so it resolves everything against `execution_database`. After merging master, which reverted the load-time qualification of ClickHouse#114923 (ClickHouse#130531), `TablesLoader` resolves the query of a view against the database owning it, as the `ALTER` path and the graph of plain views do, and everything else against the default database of the server, as master does. Remove `05444_plain_view_dependencies_rename_after_metadata_reload`: it asserted that loading the view qualifies its unqualified source, which master reverted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rewrite The revert of ClickHouse#114923 (ClickHouse#130531) removed `qualifyNamesFromLegacyMetadata`: metadata load no longer qualifies the bare names that metadata written before SQL UDF table names were qualified at CREATE time can contain. The rewrite reads the definitions the same way load does, so it no longer qualifies them either, and a rewritten view keeps the state a restart gives it. The dependencies of a rewritten definition are still resolved against the database of the view rather than the current database of the RENAME query. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reverts #114923
Closes: #129449
Related: #129485
Related: #114918
Related: #123489
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
After a restart, a view reading a session temporary table by a bare name fails with
UNKNOWN_TABLE(#129449): #114923 qualifies such names with the view's database at metadata load. As asked on #129485, this reverts it; #114918 and #123489 come back.Hand-resolved: commit 1 is
git revert -m 1 659cc1c2f3c, keeping the bound of #122362, theWITHscoping of #114908, and the string overload ofqualifyDictionaryNameWithDatabasethat #121567 now uses. Commit 2 removes the #114908 helpers only the reverted pass used, and tests 05233 and 05317, which fail after commit 1.Validation (debug build): the #129449 reproducer fails on master and passes here; 458 of 470 related stateless tests pass, 1 is skipped, 11 also fail on master (local setup).
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130531]
Version info
26.11.1.2237-master(included in26.11and later)26.10.5.27