Merge pull request #60596 from Avogar/fix-bad-compatibility-setting-value

Fix logical error on bad compatibility setting value type
This commit is contained in:
Kruglov Pavel 2024-03-13 17:25:09 +01:00 committed by GitHub
commit 2f6981c613
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,7 @@ namespace ErrorCodes
extern const int THERE_IS_NO_PROFILE;
extern const int NO_ELEMENTS_IN_CONFIG;
extern const int UNKNOWN_ELEMENT_IN_CONFIG;
extern const int BAD_ARGUMENTS;
}
IMPLEMENT_SETTINGS_TRAITS(SettingsTraits, LIST_OF_SETTINGS)
@ -114,7 +115,11 @@ std::vector<String> Settings::getAllRegisteredNames() const
void Settings::set(std::string_view name, const Field & value)
{
if (name == "compatibility")
{
if (value.getType() != Field::Types::Which::String)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Unexpected type of value for setting 'compatibility'. Expected String, got {}", value.getTypeName());
applyCompatibilitySetting(value.get<String>());
}
/// If we change setting that was changed by compatibility setting before
/// we should remove it from settings_changed_by_compatibility_setting,
/// otherwise the next time we will change compatibility setting

View File

@ -0,0 +1,2 @@
select 42 settings compatibility=NULL; -- {clientError BAD_ARGUMENTS}