Repository navigation
Enforce settings constraints installed by a profile in the same statement - #120376
Algunenano merged 9 commits into
Conversation
|
Workflow [PR], commit [e96c55d] Summary: ❌
AI ReviewSummaryThis PR fixes the ordered Findings❌ Blockers
Final Verdict
|
…b.com:Algunenano/ClickHouse into enforce-profile-constraints-in-same-statement
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes77 object files changed (+50.52 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units1275 translation units recompiled, 7831 s compile time in total, 1275 of them have a recent master baseline. |
Checking every change against the final profile let a later, looser `profile` lift the constraint of an earlier one in the same `SET`. Go back to segment by segment checking, and move `profile` first only in HTTP and gRPC, whose input has no order. Fix the gRPC tests, whose `display_text` has no error name. Related: ClickHouse#120376 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Moving `profile` first changed which assignment wins, e.g. `run_query_in_background=1&profile=p` let the explicit value override the profile (`04666_run_query_in_background_http`). Apply the list in its own order, and check each change against the constraints both before and after the profile, since these sources have no order. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The check against the constraints before the profile erased changes equal to the current value, so `?profile=p&max_result_rows=0` lost the explicit value and the profile won. Check that pass on a `const` view. Related: ClickHouse#120376 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ces put profile first gRPC now puts `profile` first when building the list from the protobuf map, so the other settings are bound by it and override its values deterministically. `checkSettingsConstraintsInAnyOrder` is removed and HTTP keeps master's handling: Poco groups a repeated URL parameter with its first occurrence before the handler runs, so there is no later position to restore. Tests are batched into few client calls. Related: ClickHouse#120376 (comment) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🕵 The It's a pre-existing bug: a lambda argument named the same as an Already tracked upstream in #121254 (same STID |
585f97e
Backport #120376 to 26.9: Enforce settings constraints installed by a profile in the same statement
… profile in the same statement
Backport #120376 to 26.8: Enforce settings constraints installed by a profile in the same statement
…LECT ... SETTINGS` does The core settings of a BACKUP/RESTORE clause went through the non-const `checkSettingsConstraints` overload, which drops every change equal to the value the setting already has. So for `SETTINGS max_execution_time = 0.000001, max_execution_time = 0` the trailing item was dropped and the first one applied, while `SELECT ... SETTINGS` keeps both and ends at 0. That is also the shape an ON CLUSTER BACKUP/RESTORE forwards to the other hosts for a core reset (the override, then the declared default), and each host applies it through this same branch. `execute` and `executeForCurrentContext` already use the const overload for this reason. The resets also skipped the profile-aware check from ClickHouse#120376, so `BACKUP ... SETTINGS profile = 'p', max_execution_time = DEFAULT` was accepted when `p` makes the setting constant, while `SET` and `SELECT ... SETTINGS` reject it. Pass the clause's changes to the three-argument overload, as the other two paths do. Both are measured over HTTP. The native client applies the clause on its side first (a `profile` item fails there with THERE_IS_NO_PROFILE), and the duplicate-item case does not reproduce through it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #120376 to 26.7: Enforce settings constraints installed by a profile in the same statement
… profile in the same statement
Cherry pick #120376 to 26.3: Enforce settings constraints installed by a profile in the same statement
… profile in the same statement
Backport #120376 to 26.7: Enforce settings constraints installed by a profile in the same statement
Backport #120376 to 26.3: Enforce settings constraints installed by a profile in the same statement
…alled by a profile in the same statement
A settings constraint installed by a settings profile was not enforced against the other setting assignments in the same statement.
Context::applySettingsChangeswalks the change list and replaces the constraint set when it reaches theprofileentry, but the whole list has already been checked against the constraints in force before the statement. SoSET profile = 'p', max_memory_usage = 1099511627776overrode theMAXthat profilepinstalls,SET profile = 'p', max_execution_time = 999overrode itsCONST, and areadonly = 1declared by the profile could be lifted in the sameSET, while the same settings applied as two separate statements were correctly rejected. Re-checking after the list is applied does not help: the constraint checker skips a change whose value already equals the current value.The check now follows the order in which the changes take effect.
Context::checkSettingsConstraintsandContext::clampToSettingsConstraintsenforce each run of changes up to the nextprofileentry against the constraints in force at that point, on a scratch copy of the context, so a rejected statement leaves the session untouched and the caller applies the changes exactly once.SET name = DEFAULTis checked with the statement'sprofileapplied. A list without aprofileentry keeps the previous path. Fixing the primitives covers all of their callers:SET(in every dialect, since they all reuseParserSetQuery), an outer or nestedSETTINGSclause, aWITHsubquery, HTTP URL parameters, gRPC, the Prometheus handler, TCP secondary queries, distributed DDL replay,SQL SECURITY DEFINERviews andEXECUTE AS.gRPC and Arrow Flight receive their settings in a map with no order, so they put
profilefirst: its constraints bind the other settings, and those settings override the values it sets. Arrow Flight'sSetSessionOptionsalso checked every option against a snapshot taken before the loop; it now checks against the session context it mutates.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed settings constraints from a settings profile not being enforced against the other setting assignments in the same statement.
SET profile = 'p', <setting> = <value>could override aCONST,MIN/MAXorreadonlyconstraint that profilepinstalls. The same escape existed through an in-querySETTINGSclause, HTTP URL parameters and Arrow Flight session options.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/120376]
Version info
26.10.1.678-master(included in26.10and later)26.9.3.35,26.8.11.55,26.7.16.4,26.3.36.5