fix leading id method without WITH and with type specified being allowed

This commit is contained in:
Arthur Passos 2024-08-14 12:39:27 -03:00
parent e8a40d9d52
commit 026fa0a7fd
3 changed files with 17 additions and 3 deletions

View File

@ -48,7 +48,12 @@ namespace
});
}
bool parseAuthenticationData(IParserBase::Pos & pos, Expected & expected, std::shared_ptr<ASTAuthenticationData> & auth_data, bool is_type_specifier_mandatory)
bool parseAuthenticationData(
IParserBase::Pos & pos,
Expected & expected,
std::shared_ptr<ASTAuthenticationData> & auth_data,
bool is_type_specifier_mandatory,
bool is_type_specifier_allowed)
{
return IParserBase::wrapParseImpl(pos, [&]
{
@ -105,6 +110,10 @@ namespace
else if (is_type_specifier_mandatory)
return false;
}
else if (!is_type_specifier_allowed)
{
return false;
}
/// If authentication type is not specified, then the default password type is used
if (!type)
@ -231,7 +240,7 @@ namespace
std::shared_ptr<ASTAuthenticationData> ast_authentication_data;
if (!parseAuthenticationData(pos, expected, ast_authentication_data, is_type_specifier_mandatory))
if (!parseAuthenticationData(pos, expected, ast_authentication_data, is_type_specifier_mandatory, is_type_specifier_mandatory))
{
return false;
}
@ -247,7 +256,7 @@ namespace
{
std::shared_ptr<ASTAuthenticationData> ast_authentication_data;
if (!parseAuthenticationData(aux_pos, expected, ast_authentication_data, false))
if (!parseAuthenticationData(aux_pos, expected, ast_authentication_data, false, true))
{
break;
}

View File

@ -49,3 +49,5 @@ Create user with ADD identification, should fail, add is not allowed for create
BAD_ARGUMENTS
Trailing comma should result in syntax error
SYNTAX_ERROR
First auth method can't specify type if WITH keyword is not present
SYNTAX_ERROR

View File

@ -141,4 +141,7 @@ ${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} ADD IDENTIFIED WITH plaintext_
echo "Trailing comma should result in syntax error"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} ADD IDENTIFIED WITH plaintext_password by '1'," 2>&1 | grep -m1 -o "SYNTAX_ERROR"
echo "First auth method can't specify type if WITH keyword is not present"
${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} IDENTIFIED plaintext_password by '1'" 2>&1 | grep -m1 -o "SYNTAX_ERROR"
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS ${user}"