Skip to content

Cherry pick #115334 to 26.7: Do not let SET <name> = DEFAULT bypass the settings constraints - #115940

Merged
robot-ch-test-poll4 merged 7 commits into
backport/26.7/115334from
cherrypick/26.7/115334
Aug 25, 2026
Merged

robot-ch-test-poll4 merged 7 commits into
backport/26.7/115334from
cherrypick/26.7/115334

Conversation

@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

Original pull-request #115334

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

robot-clickhouse and others added 6 commits August 18, 2026 18:14
`SET <name> = DEFAULT` resets a setting rather than assigning to it, so it does not
produce a `SettingChange` and never reached `SettingsConstraints`. Any constraint
could therefore be escaped by resetting the setting instead of assigning to it:

    CREATE SETTINGS PROFILE p SETTINGS max_query_size = 1000 MAX 1000;
    SET max_query_size = 2000;      -- SETTING_CONSTRAINT_VIOLATION, as expected
    SET max_query_size = DEFAULT;   -- silently restored the default of 262144

A `CONST` constraint was just as escapable, and so was readonly mode, which is
enforced by the same check:

    SET readonly = 2;
    SET readonly = 0;               -- READONLY, as expected
    SET readonly = DEFAULT;         -- silently left readonly mode

Describe the reset as the change it effectively is - to the value declared in the
source code, which is what `Context::resetSettingsToDefaultValue` restores - and run
the usual check on it before anything is applied, so that a violation leaves the
whole statement without effect. The in-query `SETTINGS <name> = DEFAULT` form goes
through the same interpreter and is covered too.

A reset that does not change the value is still allowed, because the check drops
changes whose new value equals the current one. Resetting a setting that was never
touched therefore keeps working under a `CONST` constraint and in readonly mode,
which is what the CI profiles that pin a setting to its default rely on. Settings
without a declared default are unaffected: a custom setting is dropped rather than
reset and cannot carry a constraint, and an unknown name stays silently ignored.

Co-Authored-By: Claude Fable 5 <[email protected]>
Centralize reset validation so SQL and Arrow Flight enforce constraints consistently, including readonly checks for existing custom settings.

#115334
The `readonly = 1` case of `05023_set_default_bypasses_settings_constraints`
failed in CI: `readonly = 1` rejects every setting change, and the native
client sends `send_logs_level` (and the test runner its randomized settings and
`log_comment`) along with each statement, so one of those was rejected before
the reset under test and the expected message never appeared.

Do that check over HTTP with a session and a bare URL that carries nothing but
the session id, so the only setting change in the request is the reset itself.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115334&sha=5df0e26be9f9c6bacd206edbcd2b7f265303ecad&name_0=PR&name_1=Fast%20test
PR: #115334
…ngs-constraints

Do not let SET <name> = DEFAULT bypass the settings constraints
@robot-ch-test-poll3 robot-ch-test-poll3 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-critical-bugfix labels Aug 22, 2026
…ypick/26.7/115334

# Conflicts:
#	src/Interpreters/InterpreterSetQuery.cpp
@robot-ch-test-poll4
robot-ch-test-poll4 merged commit b39a752 into backport/26.7/115334 Aug 25, 2026
1 check passed
@robot-ch-test-poll4
robot-ch-test-poll4 deleted the cherrypick/26.7/115334 branch August 25, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants