From e6f137e199ae4b62e610b6eb896d6a843aa4a405 Mon Sep 17 00:00:00 2001 From: pufit Date: Fri, 13 Dec 2024 01:02:02 -0500 Subject: [PATCH] More accurate parsing for `ALTER USER ... DROP ALL PROFILES/SETTINGS` --- src/Parsers/Access/ParserSettingsProfileElement.cpp | 4 ++-- .../0_stateless/02943_alter_user_modify_profiles.reference | 1 + tests/queries/0_stateless/02943_alter_user_modify_profiles.sh | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Parsers/Access/ParserSettingsProfileElement.cpp b/src/Parsers/Access/ParserSettingsProfileElement.cpp index f76b171aad7..ed3d1b4277e 100644 --- a/src/Parsers/Access/ParserSettingsProfileElement.cpp +++ b/src/Parsers/Access/ParserSettingsProfileElement.cpp @@ -386,13 +386,13 @@ bool ParserAlterSettingsProfileElements::parseImpl(Pos & pos, ASTPtr & node, Exp return false; } - if (action == "DROP" && target == "ALL PROFILES") + if (action == "DROP" && target == "ALL PROFILES" && !drop_all_profiles) { drop_all_profiles = true; return true; } - if (action == "DROP" && target == "ALL SETTINGS") + if (action == "DROP" && target == "ALL SETTINGS" && !drop_all_settings) { drop_all_settings = true; return true; diff --git a/tests/queries/0_stateless/02943_alter_user_modify_profiles.reference b/tests/queries/0_stateless/02943_alter_user_modify_profiles.reference index 98de0d53b2f..29a2e50b828 100644 --- a/tests/queries/0_stateless/02943_alter_user_modify_profiles.reference +++ b/tests/queries/0_stateless/02943_alter_user_modify_profiles.reference @@ -19,3 +19,4 @@ CREATE SETTINGS PROFILE `test_profile` SETTINGS INHERIT `profile_b`, INHERIT `pr CREATE SETTINGS PROFILE `test_profile` SETTINGS INHERIT `profile_a`, INHERIT `profile_d` CREATE SETTINGS PROFILE `test_profile` SETTINGS INHERIT `profile_e` CREATE SETTINGS PROFILE `test_profile` +OK diff --git a/tests/queries/0_stateless/02943_alter_user_modify_profiles.sh b/tests/queries/0_stateless/02943_alter_user_modify_profiles.sh index 8a16cacbbf7..edb8213508f 100755 --- a/tests/queries/0_stateless/02943_alter_user_modify_profiles.sh +++ b/tests/queries/0_stateless/02943_alter_user_modify_profiles.sh @@ -69,6 +69,8 @@ run_test user ${test_user} run_test role ${test_role} run_test profile ${test_profile} +${CLICKHOUSE_CLIENT} --query="ALTER USER user1 DROP ALL PROFILES,,,,,,ADD PROFILE a" 2>&1 | grep -F -q 'Syntax error' && echo 'OK' || echo 'FAIL' + $CLICKHOUSE_CLIENT -q "DROP PROFILE ${profile_a};" $CLICKHOUSE_CLIENT -q "DROP PROFILE ${profile_b};" $CLICKHOUSE_CLIENT -q "DROP PROFILE ${profile_c};"