Repository navigation
Validate access to underlying tables for Merge engine - #78339
Merged
Merged
Conversation
Contributor
GrigoryPervakov
force-pushed
the
merge-access-validation
branch
6 times, most recently
from
March 31, 2025 17:44
a6a7c20 to
745d719
Compare
GrigoryPervakov
marked this pull request as ready for review
April 1, 2025 11:02
GrigoryPervakov
commented
Apr 3, 2025
| @@ -1,195 +1,195 @@ | |||
| CREATE TABLE t_merge as 01902_db.t ENGINE=Merge(REGEXP(^01902_db), ^t) | |||
Member
Author
There was a problem hiding this comment.
There is a neighbour test 01902_table_function_merge_db_params.sql that creates a db that matches that prefix, and in case of failure, it doesn't cleanup, so it affects this test run
divanik
reviewed
Apr 3, 2025
divanik
reviewed
Apr 7, 2025
divanik
reviewed
Apr 7, 2025
divanik
reviewed
Apr 7, 2025
divanik
reviewed
Apr 7, 2025
divanik
reviewed
Apr 7, 2025
divanik
reviewed
Apr 7, 2025
divanik
reviewed
Apr 7, 2025
divanik
left a comment
Contributor
There was a problem hiding this comment.
Some minor issues and an explanation request
GrigoryPervakov
force-pushed
the
merge-access-validation
branch
from
April 7, 2025 14:04
745d719 to
04c76a2
Compare
GrigoryPervakov
enabled auto-merge
April 7, 2025 16:50
divanik
approved these changes
Apr 8, 2025
This was referenced Apr 10, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Apr 10, 2025
This was referenced Apr 10, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Apr 10, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Apr 10, 2025
Backport #78339 to 25.2: Validate access to underlying tables for Merge engine
GrigoryPervakov
added a commit
that referenced
this pull request
Apr 14, 2025
Backport #78339 to 25.3: Validate access to underlying tables for Merge engine
robot-clickhouse
added a commit
that referenced
this pull request
Apr 14, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Apr 14, 2025
GrigoryPervakov
added a commit
that referenced
this pull request
Apr 15, 2025
Backport #78339 to 25.1: Validate access to underlying tables for Merge engine
GrigoryPervakov
pushed a commit
that referenced
this pull request
Apr 23, 2025
GrigoryPervakov
added a commit
that referenced
this pull request
Apr 29, 2025
Backport #78339 to 24.8: Validate access to underlying tables for Merge engine
This was referenced Nov 6, 2026
alexey-milovidov
pushed a commit
to zvonand/ClickHouse
that referenced
this pull request
Nov 10, 2026
A `Merge` table or `merge()` reads only the matched tables the user has `SHOW TABLES` on (ClickHouse#78339), but its metadata-only answers walked every matched table: the trivial count (`SELECT count()` with `apply_patch_parts = 0, apply_mutations_on_fly = 0`), `system.tables` `total_rows`/`total_bytes` and `system.columns` sizes included the rows and on-disk size of a table the user holds no privilege on, and the trivial count answered for a visible child the user cannot read. `totalRows`/`totalBytes`, `supportsTrivialCountOptimization` and `tryGetColumnSizes` now enumerate the children with the query context and skip those without `SHOW TABLES`, like `getSelectedTables` does. The trivial count is also declined for a visible child with no `SELECT` on any column, so the read path raises its `ACCESS_DENIED`. `tryGetColumnSizes` takes the query context (its only caller is `system.columns`), and the Merge sums each visible child's own context-aware sizes, so a nested `Merge` or an `Alias` over a `Merge` filters its own children too. `Alias`, `StorageProxy` and `StorageTableFunctionProxy` forward the context. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov
pushed a commit
to amosbird/ClickHouse
that referenced
this pull request
Nov 10, 2026
…ble function A `Merge` table and `merge` read only the matched tables that the current user can see (has `SHOW TABLES` on), and check `SELECT` only on those; a matched table the user cannot see is skipped without an error. Structure inference uses the same visibility filter and requires `SHOW COLUMNS`. The rule comes from ClickHouse#78339 and is asserted by `03400_merge_storage_underlying_tables_access_validation`. The owner chose to document it on ClickHouse#129597 instead of changing the behaviour. Add an `Access rights` section to both registration doc strings. The reference pages `docs/reference/engines/table-engines/special/merge.mdx` and `docs/reference/functions/table-functions/merge.mdx` are generated from these strings by the nightly docs autogeneration, so they are not edited here. Closes ClickHouse#129597 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the same validation as in the table function Merge before, but move logic inside StorageMerge to provide consistent behaviour
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Validate access to underlying tables for the Merge engine