Skip to content

Add ALTER USER/ROLE/SETTINGS PROFILE ... SET as an alias for MODIFY SETTING - #108722

Merged
alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:groeneai/alter-user-set-modify-setting-108717
Jul 2, 2026
Merged

alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:groeneai/alter-user-set-modify-setting-108717

Conversation

@groeneai

@groeneai groeneai commented Jun 28, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #108717

Changelog category (leave one):

  • New Feature

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

ALTER USER, ALTER ROLE and ALTER SETTINGS PROFILE now accept SET name = value as an alias for MODIFY SETTING name = value. It changes individual settings in place while keeping the rest, unlike the bare SETTINGS clause which replaces the whole settings list. This makes it less likely to accidentally wipe a user's other settings.

Description

Implements #108717 (requested by @alexey-milovidov).

SET <setting> = <value> is added as an alias for MODIFY SETTING <setting> = <value> on ALTER USER, ALTER ROLE and ALTER SETTINGS PROFILE. It modifies a single setting in place (keeping the other settings and parent profiles), in contrast to the bare SETTINGS clause which replaces the entire settings list. The motivation in the issue is the common footgun of typing SETTINGS (replace) when MODIFY SETTING (in-place edit) was intended.

Implementation: a single branch in the shared ParserAlterSettingsProfileElements maps the SET keyword to action = MODIFY, target = SETTINGS, so it produces the exact same modify_settings AST as MODIFY SETTING. All existing interpreter and formatter logic is reused unchanged; the formatter canonicalizes SET back to MODIFY SETTING. The change is purely additive (no setting defaults, on-disk or wire formats changed), so it is fully backward compatible. The SETTING/SETTINGS keywords are unaffected (word-boundary keyword matching), and SET composes with ADD/DROP in a single statement.

Examples:

ALTER USER u SET max_threads = 8;                 -- same as: ALTER USER u MODIFY SETTING max_threads = 8
ALTER USER u SET max_threads = 4 MIN 1 MAX 8 CONST;
ALTER ROLE r SET max_threads = 2, max_execution_time = 100;
ALTER SETTINGS PROFILE p SET max_memory_usage = 16106127360;

Added stateless test 04365_alter_user_set_as_modify_setting (covers USER/ROLE/PROFILE, multiple settings, MIN/MAX/constraints, equivalence with MODIFY SETTING, and parser round-trip) and updated the ALTER USER / ALTER ROLE / ALTER SETTINGS PROFILE docs.

Version info

  • Merged into: 26.7.1.416 (included in 26.7 and later)

…ETTING

SET <setting> = <value> now modifies a single profile setting in place,
exactly like MODIFY SETTING, instead of replacing the whole settings list
like the bare SETTINGS clause does. Implemented in the shared
ParserAlterSettingsProfileElements by mapping SET to action=MODIFY,
target=SETTINGS, so it produces the same modify_settings AST and reuses all
existing interpreter and formatter logic (the formatter canonicalizes SET
back to MODIFY SETTING). No AST or interpreter changes are needed, and the
new syntax is purely additive.

The motivation is the common footgun where users type SETTINGS (which
replaces the list) when they meant MODIFY SETTING (which edits one entry).

Closes: ClickHouse#108717

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On master, SELECT formatQuery('ALTER USER u SET max_threads = 4') fails with Code 62 SYNTAX_ERROR; with the fix it parses. Reproduced on demand against both the baseline binary (Build ID 0bac0101…) and the fixed binary (449dfee0…).
b Root cause / mechanism explained? Feature, not a bug. ParserAlterSettingsProfileElements (the shared alter-settings parser for USER/ROLE/SETTINGS PROFILE) had no SET branch, so SET was rejected. Adding a branch that maps SET to action=MODIFY, target=SETTINGS makes it produce the identical modify_settings AST as MODIFY SETTING.
c Fix matches the intent? Yes. Implements exactly the requested alias at the parser layer, reusing all existing MODIFY SETTING interpreter + formatter logic. No AST or interpreter change.
d Tests added? Yes. New stateless test 04365_alter_user_set_as_modify_setting covers USER/ROLE/SETTINGS PROFILE, single + multiple settings, MIN/MAX/CONST/READONLY constraints, byte-for-byte equivalence with MODIFY SETTING (via diff), and parser round-trip.
e Both directions demonstrated? Yes. Baseline binary rejects SET (SYNTAX_ERROR); fixed binary accepts it and behaves identically to MODIFY SETTING (verified end-to-end on a running server: SET edits one setting in place, keeps the rest). New test passed 50/50 runs, deterministic.
f Fix is general across code paths? Yes. The change is in the single shared parser, so ALTER USER, ALTER ROLE and ALTER SETTINGS PROFILE all gain SET uniformly; no sibling parser is left unpatched.
g Generalizes across inputs? Yes. Verified SET with a single setting, multiple comma-separated settings, MIN/MAX/CONST/READONLY constraints, and composed with ADD/DROP in one statement. The SETTING/SETTINGS keywords are not shadowed (word-boundary keyword matching); the bare replacing SETTINGS form still parses unchanged.
h Backward compatible? Yes. Purely additive new syntax. No setting default, on-disk, wire, replication or metadata format changed → no SettingsChangesHistory.cpp update needed. Old behavior fully preserved; the formatter canonicalizes SET → MODIFY SETTING, and the round-trip is idempotent.
i Invariants and contracts preserved? Yes. SET produces the exact same modify_settings AST that the interpreter already consumes; the action/target stickiness across comma-list elements is preserved; format(format(SET …)) == format(SET …) confirmed; no new code path in the interpreter.

Session id: cron:clickhouse-worker-slot-2:20260627-233800

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @vitlibar @pufit — could you review this? It adds SET name = value as an alias for MODIFY SETTING name = value on ALTER USER/ROLE/SETTINGS PROFILE (issue #108717). The whole change is one branch in the shared ParserAlterSettingsProfileElements that maps SET to action=MODIFY, target=SETTINGS, so it produces the same modify_settings AST and reuses all existing interpreter/formatter logic.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a536ae3]

Summary: ✅


AI Review

Summary

This PR adds SET setting = value as an alias for the existing incremental alter-settings path used by ALTER USER, ALTER ROLE, and ALTER SETTINGS PROFILE, along with matching docs and a stateless regression test. After reviewing the current diff, the surrounding parser/formatter and access-control code, and the prior discussion, I did not find any remaining correctness, compatibility, or documentation issue beyond the already-fixed warning about bare SETTINGS also dropping inherited profiles.

Missing context / blind spots
  • ⚠️ I did not rerun the stateless test locally because this checkout does not include a ready build directory or binary; the review relies on the current code trace, the added regression test, and the PR discussion/CI artifacts.
Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jun 28, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

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 Jun 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 6ec4e24

Every failure below has an owner: a fixing PR (ours or external). Only CH Inc sync is exempt. This PR's diff is a 6-line parser alias (ALTER USER/ROLE/SETTINGS PROFILE ... SET -> MODIFY SETTING); none of the failures below are caused by it.

Check / test Reason Owner / fixing PR
Stress test (arm_tsan) / Hung check failed, possible deadlock found chronic trunk: an AST-fuzzer in-flight cancelled INSERT left hung in system.processes (is_cancelled=1, ASTFuzzerQueries=2, elapsed 1305s). 30d: 350 master hits + 24 distinct PRs. Not caused by this parser-only diff. #108212 (ours, open) + hung-check family #101680 / #105905 (ours, open)
CH Inc sync — CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260628-060000

…y_setting.sh

The test only exercises ordinary access-control DDL (CREATE/ALTER/DROP
USER/ROLE/SETTINGS PROFILE), SHOW CREATE and formatQuery, all core features
present in every build including Fast test. The sibling
02943_alter_user_modify_settings.sh covers the same path without the tag, so
there is no concrete fasttest-only dependency.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 3286c6c

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

This PR is a 6-line ParserSettingsProfileElement.cpp parser-alias change + docs + one stateless test. Both reds below are pre-existing trunk bugs the fuzzer/stress harness happened to hit on this run (each verified unrelated to the parser-alias diff), and each already has an open fixing PR.

Check / test Reason Owner / fixing PR
AST fuzzer (arm_asan_ubsan) / Bad cast ColumnSparse to ColumnString (STID 3336-3d40) trunk bug — groupConcat(Tuple(... String)) over a sparse-serialized subcolumn; SerializationString::serializeTextQuoted assert_casts a ColumnSparse. Aggregator only checks top-level sparsity, never materializes the sparse leaf of a Tuple. #108790 (ours, open)
Stress test (amd_tsan) / Too large size passed to allocator (STID 1367-330c) trunk bug — skip-index read after a pending ALTER MODIFY COLUMN type change: pending alter dropped from the read snapshot, incompatible set-index granule deserialized with the new type, garbage 2^63 size. Verified by local reproduction. #106988 (ours, open)
Mergeable Check / PR aggregators reflecting the two reds above n/a
CH Inc sync private fork mirror CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260629-060000

@alexey-milovidov

alexey-milovidov commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Merged the latest master (the branch was 491 commits behind and red). The merge is clean — no conflicts, and the net diff vs master is still exactly the original 6 files (the 6-line ParserSettingsProfileElement.cpp alias, the three docs pages, and the 04365_alter_user_set_as_modify_setting test). Re-triggered CI.

Both reds on the previous run are pre-existing trunk bugs unrelated to this parser-only change, and each had a fixing PR:

Status: approved by @alexey-milovidov (LGTM) and the AI review (✅ Approve), with no unresolved review threads. Waiting on a fresh CI run.

@alexey-milovidov

Copy link
Copy Markdown
Member

CI status — bf74db2308a0ddce388e3d91084d12babf7f6e7e

The PR itself is complete and unchanged: net diff vs master is still exactly the 6 original files (the 6-line ParserSettingsProfileElement.cpp alias, the three ALTER USER/ROLE/SETTINGS PROFILE docs pages, and the 04365_alter_user_set_as_modify_setting test). Approved by @alexey-milovidov (LGTM) and the AI review (✅ Approve), with no unresolved review threads. Only 6 commits behind master, MERGEABLE.

The current run (re-triggered after the master merge) is still in progress; the only red so far is a pre-existing trunk regression unrelated to this parser-only alias:

Check / test Reason Owner / fixing PR
Unit tests (msan, function_prop_fuzzer) / FunctionsStress.stress (+ AllTests) trunk bug — reinterpret(x, 'Decimal256(69)') over a same-physical-type Decimal(76, 22) source returns a column whose internal scale is the source scale, so the stress harness reports function returned column of unexpected type or scale: Decimal256 instead of Decimal(76, 69). Values are correct; the column object is structurally inconsistent with its declared type. A parser alias for ALTER USER ... SET cannot reach this code path. #108878 (ours, open)

Evidence this is master-wide and not caused by this PR: the function_prop_fuzzer "unexpected type or scale" failure first appeared on 2026-06-30 and hit 20 distinct PRs that day (all base_ref = master), including this one. The fix is already in progress in #108878 ("Fix reinterpret to Decimal/DateTime64 with a different scale").

Did not re-merge master: the branch is only 6 commits behind (the master merge above was this morning), and #108878 is not yet in master, so a re-merge would not clear this red — it would only churn the in-flight CI. Waiting on the fresh run to finish and on #108878 to land.

@alexey-milovidov

Copy link
Copy Markdown
Member

Re-merged origin/master (f54adf1f5bc) → new head 66fc80cde48. The net diff is unchanged — still only the SET→MODIFY SETTING alias branch in ParserSettingsProfileElement.cpp, the three ALTER docs pages, and 04365_alter_user_set_as_modify_setting.{sh,reference} (+95, no conflicts).

The only real CI red on the previous head was Unit tests (msan, function_prop_fuzzer) — the master-wide reinterpret → Decimal scale regression introduced by #108551, unrelated to this parser-only change. #108551 has since been reverted on master (#108981, 9bbbb45524f), and FunctionsStress.stress is green on master again (0 fails / 129 OK on 2026-07-01), so this re-merge should let the fresh CI run go green.

Still approved (LGTM) with an AI-review approve and 0 unresolved threads.

@vitlibar
vitlibar requested a review from pufit July 1, 2026 22:26
The `ALTER USER` / `ALTER ROLE` docs warned that the bare `SETTINGS`
clause "replaces the whole settings list", but in
`ParserAlterSettingsProfileElements::parseImpl` the old-style `SETTINGS`
path sets both `drop_all_settings` and `drop_all_profiles`, so it also
removes all inherited (parent) profiles, not just sibling settings.

Correct both warnings to mention parent-profile removal, mirroring the
already-accurate wording in `alter/settings-profile.md`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Addressed the AI review's Request changes minimum-required-action (a536ae39cae).

The finding was correct: the ALTER USER / ALTER ROLE warning said the bare SETTINGS clause "replaces the whole settings list", but ParserAlterSettingsProfileElements::parseImpl sets both drop_all_settings and drop_all_profiles on the old-style SETTINGS path, so it also removes all inherited (parent) profiles. Both warnings now say so, mirroring the already-accurate alter/settings-profile.md. Docs-only change; the parser alias and test are unchanged. All review threads resolved.

@clickhouse-gh

clickhouse-gh Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.50% 85.50% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.70% +0.10%

Changed lines: Changed C/C++ lines covered: 6/6 (100.00%) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 2, 2026
Merged via the queue into ClickHouse:master with commit 20e5f3d Jul 2, 2026
347 of 348 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 2, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…r-set-modify-setting-108717

Add ALTER USER/ROLE/SETTINGS PROFILE ... SET as an alias for MODIFY SETTING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-feature Pull request with new product feature 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.

ALTER USER ... SET as equivalent to ALTER USER ... MODIFY SETTING

3 participants