Repository navigation
Conversation
StorageBuffer::totalRows added destination->totalRows(context) with no access check. system.tables lists a Buffer on SHOW TABLES of the Buffer alone and reads totalRows with the user's context, so a user granted SELECT on the Buffer and nothing on its destination got the destination's exact row count, while every read of the Buffer requires SELECT on the destination. DROP TABLE IF EMPTY used the same number. Count the destination only when SHOW TABLES is granted on the declared destination, checked before the table is resolved so that a hidden and a missing destination give the same answer. Otherwise only the buffer's own rows are returned, which is what the function already returns when the destination is missing (value_or(0), ClickHouse#40643). SHOW TABLES is the privilege under which system.tables shows the destination's own total_rows, and every grant on the destination implies it, so users with any privilege on it see no change. StorageAlias::totalRows uses the same gate (ClickHouse#114596). NULL (as Alias returns) was rejected: a Buffer has rows of its own, and Buffer -> Alias -> hidden table already yields the buffer's rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A user with DROP TABLE on two Buffers and no privilege on their destination: the Buffer holding rows is still refused with TABLE_NOT_EMPTY, the empty one is now dropped (before the fix it was refused because the destination's rows were counted). Both DROPs pin ignore_drop_queries_probability = 0 so the stress job cannot skip them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings; 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-review-self-slot-58:20261106-174900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20261106-174000 |
|
cc @azat @vitlibar, could you review this and add the |
|
Workflow [PR], commit [40d8294] Summary: ✅
AI ReviewSummary
Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline. |
324b7a5
Related: #114596
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A
Buffertable no longer counts its destination's rows insystem.tables.total_rowsfor a user who has no privilege on the destination, so that table's row count is no longer disclosed. Such a user sees only the rows held in the buffer, andDROP TABLE IF EMPTYjudges the buffer by those rows.Description
On 26.3.33.24 and 26.10.2.103, a user granted
SELECTon aBuffertable and nothing on its destination gets the destination's exact row count fromSELECT total_rows FROM system.tables, although the destination is not listed for that user and every read of the Buffer fails withACCESS_DENIED(it needsSELECTon the destination).StorageBuffer::totalRowsaddeddestination->totalRows(context)without an access check. It now counts the destination only when the user hasSHOW TABLESon the declared destination, the privilege under whichsystem.tablesalready shows the destination's owntotal_rowsand which every grant on it implies. Otherwise the destination contributes nothing, as it already does when it is missing. This is the gateAliasuses for the same metadata (#114596).Users with any privilege on the destination see no change. For the others,
DROP TABLE IF EMPTYof an empty buffer over a non-empty hidden destination now succeeds; a buffer with rows is still refused, and dropping aBufferflushes its rows, so nothing is lost.Validation: the new test fails on master (
1007instead of7, and the empty buffer is refused) and passes 50/50 with randomized settings. Gating onSELECTinstead ofSHOW TABLES, or returningNULLfor a hidden destination, also fails it.Workflow [PR]
Sync PR [sync-upstream/pr/129801]
Version info
26.11.1.1667-master(included in26.11and later)