From 62541ab7647fb3384e9ce30dfe65960fa92b763e Mon Sep 17 00:00:00 2001 From: Sergei Trifonov Date: Thu, 8 Sep 2022 17:43:09 +0200 Subject: [PATCH] fix more tests and clang tidy build --- src/Access/SettingsProfileElement.cpp | 8 ++++---- src/Common/SettingConstraintType.h | 2 -- tests/integration/test_settings_profile/test.py | 12 +++++++----- .../queries/0_stateless/01292_create_user.reference | 12 ++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Access/SettingsProfileElement.cpp b/src/Access/SettingsProfileElement.cpp index 6851169db5e..64bb4d3769a 100644 --- a/src/Access/SettingsProfileElement.cpp +++ b/src/Access/SettingsProfileElement.cpp @@ -50,11 +50,14 @@ void SettingsProfileElement::init(const ASTSettingsProfileElement & ast, const A { setting_name = ast.setting_name; - /// Optionally check if a setting with that name is allowed. if (access_control) { + /// Check if a setting with that name is allowed. if (setting_name != ALLOW_BACKUP_SETTING_NAME) access_control->checkSettingNameIsAllowed(setting_name); + /// Check if a CHANGEABLE_IN_READONLY is allowed. + if (ast.type == SettingConstraintType::CHANGEABLE_IN_READONLY && !access_control->doesSettingsConstraintsReplacePrevious()) + throw Exception("CHANGEABLE_IN_READONLY for " + setting_name + " is not allowed unless settings_constraints_replace_previous is enabled", ErrorCodes::NOT_IMPLEMENTED); } value = ast.value; @@ -62,9 +65,6 @@ void SettingsProfileElement::init(const ASTSettingsProfileElement & ast, const A max_value = ast.max_value; type = ast.type; - if (type == SettingConstraintType::CHANGEABLE_IN_READONLY && !access_control->doesSettingsConstraintsReplacePrevious()) - throw Exception("CHANGEABLE_IN_READONLY for " + setting_name + " is not allowed unless settings_constraints_replace_previous is enabled", ErrorCodes::NOT_IMPLEMENTED); - if (!value.isNull()) value = Settings::castValueUtil(setting_name, value); if (!min_value.isNull()) diff --git a/src/Common/SettingConstraintType.h b/src/Common/SettingConstraintType.h index 9302a598fbf..eee5e630b9a 100644 --- a/src/Common/SettingConstraintType.h +++ b/src/Common/SettingConstraintType.h @@ -1,7 +1,5 @@ #pragma once -#include - namespace DB { diff --git a/tests/integration/test_settings_profile/test.py b/tests/integration/test_settings_profile/test.py index a90273e7a7a..83c504f6d0c 100644 --- a/tests/integration/test_settings_profile/test.py +++ b/tests/integration/test_settings_profile/test.py @@ -102,6 +102,7 @@ def test_smoke(): 110000000, "\\N", "\\N", + "\\N", ] ] @@ -148,7 +149,7 @@ def test_smoke(): ) ) assert system_settings_profile_elements(user_name="robin") == [ - ["\\N", "robin", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"] + ["\\N", "robin", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"] ] instance.query("ALTER USER robin SETTINGS NONE") @@ -215,11 +216,12 @@ def test_settings_from_granted_role(): 110000000, "\\N", "\\N", + "\\N", ], - ["xyz", "\\N", "\\N", 1, "max_ast_depth", 2000, "\\N", "\\N", "\\N", "\\N"], + ["xyz", "\\N", "\\N", 1, "max_ast_depth", 2000, "\\N", "\\N", "\\N", "\\N", "\\N"], ] assert system_settings_profile_elements(role_name="worker") == [ - ["\\N", "\\N", "worker", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"] + ["\\N", "\\N", "worker", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"] ] instance.query("REVOKE worker FROM robin") @@ -315,13 +317,13 @@ def test_inheritance(): ["xyz", "local directory", 1, 0, "[]", "[]"] ] assert system_settings_profile_elements(profile_name="xyz") == [ - ["xyz", "\\N", "\\N", 0, "max_memory_usage", 100000002, "\\N", "\\N", 1, "\\N"] + ["xyz", "\\N", "\\N", 0, "max_memory_usage", 100000002, "\\N", "\\N", 1, "\\N", "\\N"] ] assert system_settings_profile("alpha") == [ ["alpha", "local directory", 1, 0, "['robin']", "[]"] ] assert system_settings_profile_elements(profile_name="alpha") == [ - ["alpha", "\\N", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"] + ["alpha", "\\N", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"] ] assert system_settings_profile_elements(user_name="robin") == [] diff --git a/tests/queries/0_stateless/01292_create_user.reference b/tests/queries/0_stateless/01292_create_user.reference index 997a9504bb5..454df63d506 100644 --- a/tests/queries/0_stateless/01292_create_user.reference +++ b/tests/queries/0_stateless/01292_create_user.reference @@ -109,9 +109,9 @@ u2_01292 local directory no_password {} [] [] [] ['%.%.myhost.com'] 0 [] [] u3_01292 local directory sha256_password {} ['192.169.1.1','192.168.0.0/16'] ['localhost'] [] [] 0 ['r1_01292'] [] u4_01292 local directory double_sha1_password {} ['::/0'] [] [] [] 1 [] ['r1_01292'] -- system.settings_profile_elements -\N u1_01292 \N 0 readonly 1 \N \N \N \N -\N u2_01292 \N 0 \N \N \N \N \N default -\N u3_01292 \N 0 max_memory_usage 5000000 4000000 6000000 0 \N -\N u4_01292 \N 0 \N \N \N \N \N default -\N u4_01292 \N 1 max_memory_usage 5000000 \N \N \N \N -\N u4_01292 \N 2 readonly 1 \N \N \N \N +\N u1_01292 \N 0 readonly 1 \N \N \N \N \N +\N u2_01292 \N 0 \N \N \N \N \N \N default +\N u3_01292 \N 0 max_memory_usage 5000000 4000000 6000000 0 \N \N +\N u4_01292 \N 0 \N \N \N \N \N \N default +\N u4_01292 \N 1 max_memory_usage 5000000 \N \N \N \N \N +\N u4_01292 \N 2 readonly 1 \N \N \N \N \N