More accurate parsing for ALTER USER ... DROP ALL PROFILES/SETTINGS

This commit is contained in:
pufit 2024-12-13 01:02:02 -05:00
parent 296677b9ef
commit e6f137e199
3 changed files with 5 additions and 2 deletions

View File

@ -386,13 +386,13 @@ bool ParserAlterSettingsProfileElements::parseImpl(Pos & pos, ASTPtr & node, Exp
return false; return false;
} }
if (action == "DROP" && target == "ALL PROFILES") if (action == "DROP" && target == "ALL PROFILES" && !drop_all_profiles)
{ {
drop_all_profiles = true; drop_all_profiles = true;
return true; return true;
} }
if (action == "DROP" && target == "ALL SETTINGS") if (action == "DROP" && target == "ALL SETTINGS" && !drop_all_settings)
{ {
drop_all_settings = true; drop_all_settings = true;
return true; return true;

View File

@ -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_a`, INHERIT `profile_d`
CREATE SETTINGS PROFILE `test_profile` SETTINGS INHERIT `profile_e` CREATE SETTINGS PROFILE `test_profile` SETTINGS INHERIT `profile_e`
CREATE SETTINGS PROFILE `test_profile` CREATE SETTINGS PROFILE `test_profile`
OK

View File

@ -69,6 +69,8 @@ run_test user ${test_user}
run_test role ${test_role} run_test role ${test_role}
run_test profile ${test_profile} 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_a};"
$CLICKHOUSE_CLIENT -q "DROP PROFILE ${profile_b};" $CLICKHOUSE_CLIENT -q "DROP PROFILE ${profile_b};"
$CLICKHOUSE_CLIENT -q "DROP PROFILE ${profile_c};" $CLICKHOUSE_CLIENT -q "DROP PROFILE ${profile_c};"