Repository navigation
Cherry pick #129818 to 26.8: Merge tables report rows and sizes only of the tables the user can see - #132135
Merged
Conversation
A `Merge` table or `merge()` reads only the matched tables the user has `SHOW TABLES` on (#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]>
The metadata walks of a `Merge` table now ask for `SHOW TABLES` (and, for the trivial count, `SELECT`) on the whole database once per database, like `getSelectedTables` does, and check a single table only when the database-wide grant is missing. A fully granted user pays no per-table access check, and the query's `used_privileges` no longer lists every matched table. An `Alias` reports column sizes only when the user can see its target, as its `totalRows`/`totalBytes` already do, so an `Alias` child of a `Merge` no longer reports the sizes of a hidden target in `system.columns`. Drop the `StorageProxy::tryGetColumnSizes` forwarder: no `StorageProxy` wraps a `Merge` or an `Alias`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… see `system.columns` shows a table's per-column sizes only for the columns the user has `SHOW COLUMNS` on. Through a Merge table they needed only `SHOW TABLES` on the child, so a user with `SHOW TABLES ON db.t2` (or a column-level grant such as `SELECT(id)`) got the other columns' sizes of `t2` added into the Merge table's sizes. `StorageMerge::tryGetColumnSizes` now adds a child's column size only when the user has `SHOW COLUMNS` on that column of the child, the check `system.columns` applies to the child itself. An Alias child forwards its target's sizes, so `StorageAlias::tryGetColumnSizes` now keeps only the columns granted `SHOW COLUMNS` through the alias chain, as `system.columns` does for an Alias table read directly. This replaces its `SHOW TABLES` guard on the target (which `SHOW COLUMNS` implies), so a Merge over an Alias of a hidden table now reports the sizes of its other children instead of none. `total_rows`/`total_bytes` keep the `SHOW TABLES` rule: `system.tables` shows them for such a table directly. Rename the test to the next free number (`add-test`): 03400 -> 05616. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge tables report rows and sizes only of the tables the user can see
Collaborator
|
The conflicts come from master changes that are not on 26.8, and I resolved them without importing any of them:
The other files merge cleanly. On a 26.8 debug build, I cannot push to |
26.8 lacks the multi-hop alias grant checks and the row policy check in `supportsTrivialCountOptimization`, so the alias column sizes use the existing `isTargetTableGranted` and the trivial count check keeps only the new `SELECT` requirement. 26.8 also lacks #116774, so a table created from a table function reports no rows or column sizes at all; the `StorageTableFunction` override and the `m_func` size checks of the test are left out. 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.
Original pull-request #129818
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job