Repository navigation
Check the UNDROP TABLE grant on the undropped table instead of *.* - #131892
Conversation
|
Workflow [PR], commit [07f6601] Summary: ✅
AI Review
|
|
@lazerg please address the blocker threads |
… other dropped tables
…t database is still added
|
Fast test failed on |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units9 translation units recompiled, 39 s compile time in total, 9 of them have a recent master baseline. |
… the temporary database
… to the shard default databases
…eadonly mode `readonly` and `allow_ddl` are enforced in `ContextAccess::checkAccessImplHelper` by a deny-list of requested access types. Three statements that change persistent state were missing from it: - `ALTER DATABASE ... MODIFY COMMENT` / `MODIFY SETTING` request the children of `ALTER_DATABASE`, which `table_ddl` did not contain, so they ran at `readonly = 1`, `readonly = 2`, over HTTP GET and with `allow_ddl = 0`. `ALTER_DATABASE` is now part of `table_ddl`, like `ALTER_TABLE` and `ALTER_VIEW`. - `KILL TRANSACTION` requests `KILL_TRANSACTION`, which was not in `not_readonly_flags` (`KILL_QUERY` is), so a read-only session could roll back another user's transaction. - `INSERT INTO FUNCTION` never requests `INSERT`; its only gated flag is `CREATE_TEMPORARY_TABLE` (forced for inserts by ClickHouse#44290), which `readonly = 2` allows on purpose for session temporary tables. So at `readonly = 2`, which is what HTTP GET runs with, `file()` wrote and overwrote files and `url()` sent the POST. The source `WRITE` flag is not added to the deny-list because it is also requested by `BACKUP` destinations (documented as not restricted by `readonly`), by `SELECT` from a `DatabaseS3` table and by `file()` reads with `rename_files_after_processing`, and a filtered `WRITE` grant does not reach the gate at all. Instead `InterpreterInsertQuery::getTable` refuses a table function insert under any `readonly`, with the gate's error text, before anything is resolved or written. Every table function insert (synchronous, asynchronous, parallel replicas) goes through it. The English documentation of these settings is updated, including two stale sentences (named collection management and `UNDROP TABLE` have been gated since ClickHouse#130952 and ClickHouse#131892). Related: ClickHouse#132330 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #131853
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
UNDROP TABLEnow works with anUNDROP TABLEgrant on the database or the table. Before, it always required the grantON *.*.Description
InterpreterUndropQuery::executecalledcheckAccess(AccessType::UNDROP_TABLE)without a database or table, so a grant likeGRANT UNDROP TABLE ON db.*was never enough. The check now runs inexecuteToTableagainst the target table, after an unqualified name is resolved to the current database, the same asDROP TABLE.ON CLUSTERqueries already check the scoped grant throughgetRequiredAccessForDDLOnCluster. Since a grant on one table is now enough,UNDROP TABLE t2 UUID '...'with theUUIDof another dropped tablet1is now rejected: it used to bring backt1, which would let a grant ont2restoret1. The error for such a mismatch no longer names the other table or database.UNDROP TABLEis also now rejected underreadonlyandallow_ddl = 0, likeDROP TABLE, and theUUIDform withON CLUSTERstill needs the grant on*.*, because older replicas do not check the name. WithON CLUSTERthe grant is checked before the database is looked at, and_temporary_and_external_tablesis rejected like inDatabaseCatalog. The new test fails on master.Workflow [PR]
Sync PR [sync-upstream/pr/131892]
Version info
26.11.1.2557-master(included in26.11and later)