8000 fix: block OPTIMIZE DEDUPLICATE and MODIFY/MATERIALIZE TTL without CLICKHOUSE_ALLOW_DROP by bishalde · Pull Request #260 · ClickHouse/mcp-clickhouse · GitHub
[go: up one dir, main page]

Skip to content

fix: block OPTIMIZE DEDUPLICATE and MODIFY/MATERIALIZE TTL without CLICKHOUSE_ALLOW_DROP - #260

Merged
joe-clickhouse merged 3 commits into
ClickHouse:mainfrom
bishalde:fix/guard-deduplicate-ttl
Nov 16, 2026
Merged

joe-clickhouse merged 3 commits into
ClickHouse:mainfrom
bishalde:fix/guard-deduplicate-ttl

Conversation

@bishalde
Copy link
Copy Markdown
Contributor

Fixes #259

OPTIMIZE ... DEDUPLICATE and ALTER TABLE ... MODIFY TTL / MATERIALIZE TTL delete rows. Before this change they ran with only CLICKHOUSE_ALLOW_WRITE_ACCESS=true set. This adds them to _DESTRUCTIVE_KEYWORDS, next to the cases from #220.

  • \bDEDUPLICATE\b covers OPTIMIZE ... [FINAL] DEDUPLICATE [BY ...]. Plain OPTIMIZE is still allowed.
  • \b(?:MODIFY|MATERIALIZE)\s+TTL\b covers table TTL changes. A TTL clause in CREATE TABLE and REMOVE TTL are still allowed.
  • I updated the error message, the README lists and the CHANGELOG.

Checked against ClickHouse 26.3 through run_query:

before/after

Tests: I added both cases to DESTRUCTIVE_QUERIES and the allowed forms to ALLOWED_QUERIES. uv run pytest tests gives 875 passed, 1 xfailed, and ruff check . is clean.

…ICKHOUSE_ALLOW_DROP

Both delete rows but passed the destructive-operation guard with only
write access enabled. TTL in CREATE TABLE stays allowed.

Fixes ClickHouse#259
@bishalde
bishalde 8000 commented Nov 12, 2026
Copy link
Copy Markdown
Contributor Author

@joe-clickhouse @chernser @alex-clickhouse could one of you take a look when you have a moment? Small follow-up to #220. cc @mosya415 since you wrote that one.

@joe-clickhouse
Copy link
Copy Markdown
Collaborator

Approved, thanks for the fix! I added column TTL coverage, including the ALTER COLUMN alias, plus regression tests and updates to the tool description and docs.

@joe-clickhouse
joe-clickhouse merged commit ebc3e7a into ClickHouse:main Nov 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Destructive-operation guard misses OPTIMIZE ... DEDUPLICATE and MODIFY TTL

2 participants

0