Skip to content

Document access rights of the Merge table engine and the merge table function - #129730

Merged
Blargian merged 2 commits into
ClickHouse:masterfrom
groeneai:docs-merge-engine-access-rights
Nov 10, 2026
Merged

Blargian merged 2 commits into
ClickHouse:masterfrom
groeneai:docs-merge-engine-access-rights

Conversation

@groeneai

@groeneai groeneai commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #129597

Changelog category (leave one):

  • Documentation (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Documented which privileges the Merge table engine and the merge table function need on the matched tables: data is read only from the matched tables that the user can see (has SHOW TABLES on), and SELECT is checked on those tables.

Description

Issue #129597 reports that a Merge table (or merge) whose regexp matches a table the user has no privilege on returns the rows of the other tables without an error, while the same read fails with ACCESS_DENIED once the user can see that table. This is intended: ReadFromMerge::getSelectedTables reads only the matched tables on which SHOW TABLES is granted and checks SELECT on those (moved into the engine by #78339, asserted by 03400_merge_storage_underlying_tables_access_validation). A maintainer chose to document it rather than change it: #129597 (comment)

This adds an Access rights section to the registration doc strings of the Merge engine and of merge: visible-only reads, SELECT on the columns read, SHOW COLUMNS when the structure is derived from the matched tables, and how to get every table read (or an error instead of a skip). 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.

Validation: the new sections appear in system.table_engines / system.table_functions, and autogenerate_docs.py run on both pages changes only these sections. Every sentence was checked on a server built from this branch with the setup from the issue (skip without error or warning, ACCESS_DENIED after GRANT SHOW TABLES, a full read after GRANT SELECT, SHOW COLUMNS for DESCRIBE and for CREATE without a column list); 03400 and 04514_table_functions_access_rights_rewrite pass. The row-policy NOT_FOUND_COLUMN_IN_BLOCK mentioned in the issue does not reproduce on current master.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/129730]

Version info

  • Merged into: 26.11.1.1875-master (included in 26.11 and later)

…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]>
@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (1 finding).

# Sev Finding Verdict Evidence / action
1 ❌ Another StorageMerge code path does not apply this access rule DISAGREE (out of scope: separate PR) It is a separate defect in different code that needs an engine change and its own test; this PR only documents the intended rule, as chosen on #129597. A fix for it is in progress separately.
2 💡 The sentence about a visible table without SELECT does not mention that a table excluded by a _table filter is not read, so it is not checked AGREE, not changed The first paragraph already limits the SELECT requirement to the tables that are read.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261106-131100

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, for the documented behaviour: the issue's setup (Merge(db1, '^t[12]$'), user with SELECT on db1.t1 and the Merge table only) returns t1's 3 rows with no error every run; after GRANT SHOW TABLES ON db1.t2 it fails with ACCESS_DENIED every run.
b Root cause explained? The behaviour is intended, the gap was documentation: ReadFromMerge::getSelectedTables reads a matched table only if SHOW TABLES is granted on it and checks SELECT on the read columns of those tables; structure inference applies the same filter and requires SHOW COLUMNS (#78339, test 03400). Neither reference page said so.
c Fix matches root cause? Yes: an Access rights section in the two registration doc strings that generate the reference pages. No behaviour change, per the maintainer's choice on #129597.
d Test intent preserved / new tests added? N/A (documentation only). The documented behaviour is already asserted by 03400_merge_storage_underlying_tables_access_validation and 04514_table_functions_access_rights_rewrite, both passing on this build.
e Both directions demonstrated? N/A for a docs change; every documented sentence was checked against the server: skip without error or warning, ACCESS_DENIED once the table is visible without SELECT, full read after GRANT SELECT, SHOW COLUMNS required for DESCRIBE and CREATE without columns.
f Fix is general across code paths? Both entry points are documented (Merge engine and merge); merge builds a StorageMerge, so it shares the read and inference paths.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (documentation only).
h Backward compatible? (maintainer-approved exception only) Yes, no behaviour change.
i Invariants and contracts preserved? No code changed; the text describes only which tables data is read from and which tables the structure is derived from.

Session id: cron:clickhouse-impl-slot-4:20261106-124200

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @vitlibar, could you review this and add the can be tested label so CI runs? It documents, in the Merge engine and merge doc strings, that only the matched tables with SHOW TABLES granted are read and SELECT is checked on those (the rule from #78339), as chosen on #129597.

@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [938163c]

Summary: ✅


AI Review

Summary

Documents the visibility filter and the SELECT and SHOW COLUMNS requirements for the Merge table engine and the merge table function in their source registrations. Reviewed the current diff, prior discussion, underlying implementation, and existing access-control regression coverage. No actionable findings in this documentation change.

Final Verdict

✅ Approve. No changes required. No new inline comments posted; no local tests run for this documentation-only change.

@clickhouse-gh clickhouse-gh Bot added pr-documentation Documentation PRs for the specific code PR can be tested Allows running workflows for external contributors comp-storage-merge Merge table engine (logical union over tables) and related mechanics. labels Nov 6, 2026
@PedroTadim PedroTadim self-assigned this Nov 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 938163c0d with master 8a8d2e477 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 4ce893869; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

8 translation units recompiled, 31 s compile time in total, 8 of them have a recent master baseline.

Job report

@groeneai

groeneai commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3e3617e

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Unknown job error, Check failed infra, not in this PR's diff (this PR only changes the documentation strings of Merge and merge()): the job stopped before the upgrade started, because get_previous_release_tag could not read api.github.com/repos/ClickHouse/ClickHouse/releases (one read timeout, then 504 Gateway Time-out three times); the same error hit 6 other unrelated PRs between 14:28Z and 15:26Z and none since #112974 (mine, open)
Mergeable Check / PR praktika rollups of the row above #112974 (mine, open)

The Config Workflow / Pre Hooks failure in CIDB comes from the run before the can be tested label was added. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261106-173005

@PedroTadim

Copy link
Copy Markdown
Member

@Blargian can you or someone from your team review this docs PR? Seems small

@Blargian
Blargian added this pull request to the merge queue Nov 10, 2026
Merged via the queue into ClickHouse:master with commit 5306908 Nov 10, 2026
187 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-storage-merge Merge table engine (logical union over tables) and related mechanics. pr-documentation Documentation PRs for the specific code PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A Merge table silently leaves out matched tables the user has no access to, instead of failing

4 participants