Repository navigation
Allow EXISTS on a dictionary with the SHOW DICTIONARIES privilege - #108084
Conversation
A dictionary created by a DDL query is registered among tables, so the plain `EXISTS <name>` query (`ASTExistsTableQuery`) checked the `SHOW TABLES` privilege. As a result a user that was granted only `SHOW DICTIONARIES` on a dictionary could not run `EXISTS <dictionary>`, even though `SHOW DICTIONARIES`, `SHOW CREATE DICTIONARY` and `EXISTS DICTIONARY <dictionary>` all worked. This contradicted the documentation, which states that `SHOW DICTIONARIES` is enough for `EXISTS <dictionary>`. Now a plain `EXISTS <name>` referring to a dictionary is allowed when the user has `SHOW DICTIONARIES` on it. The change is guarded so it does not widen visibility for regular tables and does not leak whether an object is a dictionary: a user with neither `SHOW TABLES` nor `SHOW DICTIONARIES` still gets the same `SHOW TABLES` access error as for a regular or non-existing table. Closes: #64364 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [012a29b] Summary: ✅
AI ReviewSummaryThis PR fixes the Final VerdictStatus: ✅ Approve |
…observation A plain `EXISTS <name>` for a dictionary previously decided the `SHOW DICTIONARIES`-only access path from `isDictionaryExist`, but then reported existence from a second `isTableExist` lookup. If the dictionary were concurrently dropped and a regular table created under the same name between the two lookups, a user with only `SHOW DICTIONARIES` could get `1` for the regular table without a `SHOW TABLES` check, widening visibility for regular tables. Bind the privilege decision to the same observation: when the dictionary path is allowed, report existence directly from that observation (`result = true`), matching `EXISTS DICTIONARY <name>` (which returns `isDictionaryExist`); otherwise keep the `SHOW TABLES` check followed by `isTableExist`. This is behaviour-identical in the non-racy case because a registered DDL dictionary that satisfies `isDictionaryExist` also satisfies `isTableExist`. Reported by the AI review on the pull request. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Status (continue-pr review of
The only red jobs are Stress test (amd_tsan) and Stress test (arm_tsan) — both The branch tip is a fresh master merge (merge-base from earlier today), so no re-merge is needed — the flake fires on No code or test changes required. |
|
Status (continue-pr, round 5 on The change itself is unchanged and ready: AI Review ✅ Approve, 0 unresolved review threads, The only reds were A re-run of those two jobs on Ready to merge once the fresh CI run is green. |
`test_implicit_index_upgrade_alter_replay` creates a second replica `node2` and asserts `SELECT count() FROM test_alter_replay` equals `10001` immediately after `wait_for_active_replica`. But `wait_for_active_replica` only waits for `is_readonly = 0`, not for the freshly-joined replica to finish fetching parts. So `node2` can observe only the small `VALUES` part (1 row, `key = 99999`) before the 10000-row part is fetched, and the assertion fails with `assert '1' == '10001'`. This raced once each on several unrelated PRs over the last 30 days (e.g. ClickHouse#108084, ClickHouse#99280, ClickHouse#107566, ClickHouse#107442). Add `SYSTEM SYNC REPLICA test_alter_replay` after the replica becomes active, which blocks until all parts are fetched, before checking the row count. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108770&sha=bb760616d54e3d8e5d20968022085506c31b5f37&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%201%2F4%29 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 11/11 (100.00%) · Uncovered code |
`test_implicit_index_upgrade_alter_replay` creates a second replica `node2` and asserts `SELECT count() FROM test_alter_replay` equals `10001` immediately after `wait_for_active_replica`. But `wait_for_active_replica` only waits for `is_readonly = 0`, not for the freshly-joined replica to finish fetching parts. So `node2` can observe only the small `VALUES` part (1 row, `key = 99999`) before the 10000-row part is fetched, and the assertion fails with `assert '1' == '10001'`. This raced once each on several unrelated PRs over the last 30 days (e.g. ClickHouse#108084, ClickHouse#99280, ClickHouse#107566, ClickHouse#107442). Add `SYSTEM SYNC REPLICA test_alter_replay` after the replica becomes active, which blocks until all parts are fetched, before checking the row count. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108770&sha=bb760616d54e3d8e5d20968022085506c31b5f37&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%201%2F4%29 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…onary-show-priv Allow `EXISTS` on a dictionary with the `SHOW DICTIONARIES` privilege
A dictionary created by a DDL query is registered among tables, so a plain
EXISTS <name>query checks theSHOW TABLESprivilege. As a result, a user granted onlySHOW DICTIONARIESon a dictionary could not runEXISTS <dictionary>, even thoughSHOW DICTIONARIES,SHOW CREATE DICTIONARY, andEXISTS DICTIONARY <dictionary>all worked. This contradicted the documentation, which states thatSHOW DICTIONARIESis enough forEXISTS <dictionary>.This PR allows a plain
EXISTS <name>referring to a dictionary when the user hasSHOW DICTIONARIESon it. The change is guarded so it does not widen visibility for regular tables and does not leak whether an object is a dictionary: a user with neitherSHOW TABLESnorSHOW DICTIONARIESstill gets the sameSHOW TABLESaccess error as for a regular or non-existing table.The broader part of the linked issue — a database- or object-scoped
SHOW DICTIONARIESgrant not revealing dictionaries insystem.dictionaries/SHOW DICTIONARIES— was already fixed by #106105. This PR resolves the remainingEXISTS <dictionary>discrepancy.Closes: #64364
Related: #106105
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow
EXISTS <dictionary>for a user that has only theSHOW DICTIONARIESprivilege on the dictionary (previously it requiredSHOW TABLES).Documentation entry for user-facing changes