Constraints on Settings
The constraints on settings can be defined in the
profiles section of the
user.xml configuration file and prohibit users from changing some of the settings with the
The constraints are defined as the following:
If the user tries to violate the constraints an exception is thrown and the setting isn’t changed.
There are supported few types of constraints:
readonly (with alias
max constraints specify upper and lower boundaries for a numeric setting and can be used in combination. The
const constraint specifies that the user cannot change the corresponding setting at all. The
changeable_in_readonly constraint type allows user to change the setting within
max range even if
readonly setting is set to 1, otherwise settings are not allow to be changed in
readonly=1 mode. Note that
changeable_in_readonly is supported only if
settings_constraints_replace_previous is enabled:
If there are multiple profiles active for a user, then constraints are merged. Merge process depends on
- true (recommended): constraints for the same setting are replaced during merge, such that the last constraint is used and all previous are ignored including fields that are not set in new constraint.
- false (default): constraints for the same setting are merged in a way that every not set type of constraint is taken from previous profile and every set type of constraint is replaced by value from new profile.
Read-only mode is enabled by
readonly setting (not to confuse with
readonly constraint type):
readonly=0: No read-only restrictions.
readonly=1: Only read queries are allowed and settings cannot be changes unless
readonly=2: Only read queries are allowed, but settings can be changed, except for
users.xml includes lines:
The following queries all throw exceptions:
Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be greater than 20000000000.
Code: 452, e.displayText() = DB::Exception: Setting max_memory_usage should not be less than 5000000000.
Code: 452, e.displayText() = DB::Exception: Setting force_index_by_date should not be changed.
default profile has special handling: all the constraints defined for the
default profile become the default constraints, so they restrict all the users until they’re overridden explicitly for these users.
Constraints on Merge Tree Settings
It is possible to set constraints for merge tree settings. These constraints are applied when table with merge tree engine is created or its storage settings are altered. Name of merge tree setting must be prepended by
merge_tree_ prefix when referenced in
Example: Forbid to create new tables with explicitly specified