Skip to content

Reject named collection DDL in readonly mode and with allow_ddl = 0 - #130952

Merged
alexey-milovidov merged 1 commit into
masterfrom
readonly-named-collection-ddl
Nov 12, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
readonly-named-collection-ddl

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

CREATE NAMED COLLECTION, ALTER NAMED COLLECTION and DROP NAMED COLLECTION were allowed with readonly = 1, readonly = 2 and allow_ddl = 0, unlike the DDL of tables, dictionaries, functions, workloads and resources. This adds the named collection DDL access types to the flags checked in ContextAccess.

This is one of the patches that chDB (https://github.com/chdb-io/chdb-core) carries on top of ClickHouse; upstreaming them brings chDB closer to building from ClickHouse master.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

CREATE NAMED COLLECTION, ALTER NAMED COLLECTION and DROP NAMED COLLECTION are now rejected in readonly mode and with allow_ddl = 0, like other DDL queries.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.2095-master (included in 26.11 and later)
  • Backported to: 26.3.65.6

`CREATE NAMED COLLECTION`, `ALTER NAMED COLLECTION` and `DROP NAMED COLLECTION`
were allowed with `readonly = 1`, `readonly = 2` and `allow_ddl = 0`, unlike the
DDL of tables, dictionaries, functions, workloads and resources. Add the named
collection DDL access types to the flags checked in `ContextAccess`.

The fix comes from chDB (https://github.com/chdb-io/chdb-core), which carries it as a patch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [75958db]

Summary: ✅


AI Review

Summary

The PR makes CREATE NAMED COLLECTION, ALTER NAMED COLLECTION, and DROP NAMED COLLECTION obey readonly and allow_ddl through the existing shared access checks. No actionable findings. The new regression test covers all three operations under readonly = 1, readonly = 2, and allow_ddl = 0, and passed in Fast test.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. labels Nov 12, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 75958db88 with master 895d4368f (stripped binary size, per-symbol sizes and ThinLTO time; 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.

Object file sizes

3 object files changed (+21.88 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Access/ContextAccess.cpp.o 990.23 KiB 1012.12 KiB +21.89 KiB (+2.21%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.62, programs/clickhouse-keeper ×0.65 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.8 s 12.3 s +8.7 s (+240%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.4 s 7.7 s +5.6 s (+266%)
Compile time of recompiled translation units

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

Job report

@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Nov 12, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Nov 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 12, 2026
Merged via the queue into master with commit 9d24449 Nov 12, 2026
203 checks passed
@alexey-milovidov
alexey-milovidov deleted the readonly-named-collection-ddl branch November 12, 2026 13:26
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 12, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 12, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 12, 2026
Backport #130952 to 26.8: Reject named collection DDL in readonly mode and with `allow_ddl = 0`
clickhouse-gh Bot added a commit that referenced this pull request Nov 12, 2026
Backport #130952 to 26.9: Reject named collection DDL in readonly mode and with `allow_ddl = 0`
clickhouse-gh Bot added a commit that referenced this pull request Nov 12, 2026
Backport #130952 to 26.10: Reject named collection DDL in readonly mode and with `allow_ddl = 0`
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Nov 14, 2026
Cherry pick #130952 to 26.3: Reject named collection DDL in readonly mode and with `allow_ddl = 0`
robot-clickhouse added a commit that referenced this pull request Nov 14, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 14, 2026
alexey-milovidov added a commit that referenced this pull request Nov 15, 2026
Backport #130952 to 26.3: Reject named collection DDL in readonly mode and with `allow_ddl = 0`
jkartseva pushed a commit to lazerg/ClickHouse that referenced this pull request Nov 19, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync 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.

4 participants