Repository navigation
Conversation
|
Workflow [PR], commit [f7ba0f6] Summary: ❌
AI ReviewSummaryThe PR adds ordinary views to Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Correct both resolution paths and add the focused regressions before merging. |
78e24af to
4275fc0
Compare
This comment was marked as outdated.
This comment was marked as outdated.
53afe59 to
b8f0c0d
Compare
|
@bharatnc updated as per your review |
|
|
@bharatnc ping |
bharatnc
left a comment
There was a problem hiding this comment.
Looks mostly good to me, other than a few recommended changes.
65a72d4 to
108d859
Compare
|
No unexpected fails here. @bharatnc I think it is ready to be looked at again. |
I'll take a look again. |
|
@bharatnc I guess it won't be merged automatically due to |
|
the only fail is because the test is flaky |
…el, 1/2) 05450_plain_view_dependencies_in_expression_alias moved a view out of the Replicated test database, which is not supported. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=92472&sha=1b1fb83a7ac22fb86c5d367761efbe7716dce968&name_0=PR ClickHouse#92472
…sion's `enable_global_with_statement` A view does not store the settings of the session which creates it: it runs with the settings of the session which reads it. `DDLDependencyVisitor` took `enable_global_with_statement` from the global context, so with `SET enable_global_with_statement = 0` the bare name in the recursive member of a recursive CTE was treated as the CTE, although that session reads the physical table there. The source was then missing from `system.tables.dependencies_table`, and `DROP TABLE` with `check_referential_table_dependencies` broke the view. Now, unless a `SETTINGS` clause of the stored definition fixes the setting, a name is excluded from the dependencies only if it refers to a CTE with either value. The self-reference checks (`RENAME` of a view into a name it reads, and a materialized view selecting from itself) still use the precise value, so a recursive CTE named like the view stays allowed; the self-edge it produces after `RENAME` is erased from the recomputed dependencies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Pushed
All 30 tests of this PR and |
|
🕵 Status of The only red is What happens: with the database disk on object storage and several concurrent copies, @groeneai, please investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=92472&sha=latest&name_0=PR&name_1=Stateless%20tests%20(amd_asan_ubsan%2C%20db%20disk%2C%20distributed%20plan%2C%20targeted) and fix it in a separate PR (for example, wait until The |
|
Acknowledged. No fix for this shape is in progress. I'm investigating |
|
The fix is in #128859: |
… the database disk on object storage `interrupt_running_refresh` checks `status = 'Running' and read_rows between 1 and 8` one client start-up after `SYSTEM REFRESH VIEW`. The refresh is already `Running` while it creates its target table, and with the database disk on object storage that takes seconds, so the check saw `read_rows = 0` and printed 0. Re-creating the view repeated the same timing, so all 10 attempts missed: `<3a: refresh running before stop: 0>` in `Stateless tests (amd_asan_ubsan, db disk, distributed plan, targeted)` (reported on ClickHouse#92472; there the check ran 0.4-0.6 s after the refresh started and the refresh INSERT 0.6-2.6 s after it). Wait until the refresh has read its first row, or failed, before the one-call check. A new view's `read_rows` keeps its value after the refresh, so the wait cannot miss it (no hang like the one ClickHouse#125034 fixed), and `clickhouse_test_time_left` bounds it. The `read_rows <= 8` check, the one-call statements and the retry from ClickHouse#127917 are unchanged, so a STOP that lands after the refresh is still retried and an all-miss is still a labelled mismatch. Validated on master 4944813 CI builds: with the database disk on MinIO and 10 ms injected latency each way, before 14/14 FAIL (release and asan_ubsan), after 56/56 and 42/42 OK, one attempt per helper call; a failpoint that holds the refresh before it reads fails before and passes after; 50/50 OK per test with random settings on a local disk and on the database disk. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflict in `StorageAlias::getTargetTable`: master moved the column-level access check into `StorageAlias::read`, which now checks the table returned by `getTargetTable`. The new `StorageAlias::getTargetChain` and the `checkAlterIsPossible` message use `getTargetStorageID`, so a target written without a database follows the alias as elsewhere in this PR.
|
🕵 Pushed
On a local build of the merged tree, the 30 tests of this PR, the 21 The |
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]>
|
I merged Since 2026-11-19, stateless tests randomize the MergeTree setting 🤖 Generated with Claude Code |
…gainst the execution database The name of a `joinGet` table, an expression-valued `dictGet` name and a bare parameterized view call in the query of a view are not qualified in the stored definition, so they are resolved against the current database of the query which reads the view. The referential and plain-view dependencies now resolve them against `execution_database` (the current database of the session on `CREATE`, `ALTER` and `RENAME`, the default database of the server on startup) instead of the database owning the view, so the actual sources stay protected from `DROP`, also after the view is moved to another database. Addresses review: ClickHouse#92472
| addQualifiedNameFromArgument(function, 0); | ||
| /// The name is evaluated and an unqualified one is resolved when the function is executed, in the context | ||
| /// of the query which runs it: `AddDefaultDatabaseVisitor` qualifies only literal names of dictionaries. | ||
| addQualifiedNameFromArgumentWithExecutionDatabase(function, 0); |
There was a problem hiding this comment.
[Blocker] Resolve the dictionary table function against the execution database too
The dictionary branch below still calls addQualifiedNameFromArgument with the view's owning database. Unlike a qualified FROM identifier, dictionary('d') remains unqualified in the stored query and resolves against the reading session. This records both the referential and plain-view dependency on the wrong dictionary.
Reproduced with the Fast-test binary for f7ba0f65ce71:
CREATE DATABASE reader_db;
CREATE DATABASE view_db;
CREATE DICTIONARY reader_db.d (id UInt64, val String)
PRIMARY KEY id SOURCE(NULL()) LAYOUT(FLAT()) LIFETIME(0);
CREATE DICTIONARY view_db.d (id UInt64, val String)
PRIMARY KEY id SOURCE(NULL()) LAYOUT(FLAT()) LIFETIME(0);
USE reader_db;
CREATE VIEW view_db.v AS SELECT * FROM dictionary('d');
SELECT count() FROM view_db.v; -- succeeds
DROP DICTIONARY reader_db.d SETTINGS check_referential_table_dependencies = 1;
SELECT count() FROM view_db.v; -- Dictionary (`d`) not foundThe guarded drop incorrectly succeeds: view_db.d lists v, while reader_db.d lists no dependent. A metadata-only ALTER preserves the error, and cross-database renames move the edge again without changing what the view reads. Please apply execution-database resolution to this table-function carrier and add coverage for creation and recomputation.
| /// Like addQualifiedNameFromArgument, but evaluates the argument and resolves an unqualified name against `execution_database`. | ||
| void addQualifiedNameFromArgumentWithExecutionDatabase(const ASTFunction & function, size_t arg_idx) | ||
| { | ||
| String saved_current_database = std::exchange(current_database, execution_database); |
There was a problem hiding this comment.
[Blocker] Preserve the dictionary source query's execution context
visitDictionaryDef deliberately switches current_database to the server default before visiting a local CLICKHOUSE source query. This override replaces that with the outer DDL session's execution_database for joinGet/dictGet, so the dependency no longer matches the source query's execution context. The loading visitor uses a separate visitor with the default database and still records the correct edge.
Reproduced with the Fast-test binary for f7ba0f65ce71: create default.j and reader_db.j, both Join(ANY, LEFT, id) tables with columns (id UInt64, val String), and insert (1, 'global') into default.j. Then:
CREATE DATABASE owner_db;
USE reader_db;
CREATE DICTIONARY owner_db.d (id UInt64, val String)
PRIMARY KEY id
SOURCE(CLICKHOUSE(QUERY 'SELECT toUInt64(1) AS id, joinGet(\'j\', \'val\', toUInt64(1)) AS val'))
LAYOUT(FLAT()) LIFETIME(0);
SELECT dictGetString('owner_db.d', 'val', toUInt64(1)); -- global
DROP TABLE default.j SETTINGS check_referential_table_dependencies = 1;
SYSTEM RELOAD DICTIONARY owner_db.d; -- UNKNOWN_TABLE: default.jThe guarded drop incorrectly succeeds, while dropping the unused reader_db.j is blocked by owner_db.d. Please scope execution_database to the dictionary source query's default database as well, and add a regression proving the actual source remains protected.
Closes #67601
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
dependencies_databaseanddependencies_tablecolumns ofsystem.tablesnow list the plain (non-materialized) views that read from the table, in addition to the materialized views. Previously they listed exactly the materialized views which anINSERTinto the table triggers, so tools which read them as "what an insert triggers" now also get the plain views and should filter them out, e.g. byengineof the dependent table.Note
Medium Risk
Touches core catalog dependency bookkeeping and rename/drop flows; bugs could leave stale or missing dependencies in
system.tables(and potentially affect operations that rely on dependency graphs).Overview
system.tables.dependencies_tablenow reports both materialized views and regular (plain) views that depend on a table, including multi-source JOIN views and cross-database cases.This adds a new plain-view dependency graph tracked from CREATE/ALTER/ATTACH metadata (
DDLDependencyVisitor,TablesLoader,InterpreterCreateQuery) and keeps it consistent throughDROP/DETACH,RENAME TABLE, andRENAME DATABASEby extendingDatabaseCatalogdependency add/remove/update paths. A new stateless test (03760_view_in_system_tables) validates dependency output and edge cleanup/migration behavior.Written by Cursor Bugbot for commit 2c3b3f0. This will update automatically on new commits. Configure here.
Workflow [PR]
Sync PR [sync-upstream/pr/92472]