mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
throw syntax error instead of bad arguments in case of add not identified
This commit is contained in:
parent
623c507e5f
commit
27ee4dd611
@ -223,14 +223,6 @@ namespace
|
||||
{
|
||||
return IParserBase::wrapParseImpl(pos, [&]
|
||||
{
|
||||
if (ParserKeyword{Keyword::NOT_IDENTIFIED}.ignore(pos, expected))
|
||||
{
|
||||
authentication_methods.emplace_back(std::make_shared<ASTAuthenticationData>());
|
||||
authentication_methods.back()->type = AuthenticationType::NO_PASSWORD;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!ParserKeyword{Keyword::IDENTIFIED}.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
@ -269,6 +261,22 @@ namespace
|
||||
});
|
||||
}
|
||||
|
||||
bool parseIdentifiedOrNotIdentified(IParserBase::Pos & pos, Expected & expected, std::vector<std::shared_ptr<ASTAuthenticationData>> & authentication_methods)
|
||||
{
|
||||
return IParserBase::wrapParseImpl(pos, [&]
|
||||
{
|
||||
if (ParserKeyword{Keyword::NOT_IDENTIFIED}.ignore(pos, expected))
|
||||
{
|
||||
authentication_methods.emplace_back(std::make_shared<ASTAuthenticationData>());
|
||||
authentication_methods.back()->type = AuthenticationType::NO_PASSWORD;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return parseIdentifiedWith(pos, expected, authentication_methods);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
bool parseHostsWithoutPrefix(IParserBase::Pos & pos, Expected & expected, AllowedClientHosts & hosts)
|
||||
{
|
||||
@ -545,7 +553,7 @@ bool ParserCreateUserQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
|
||||
{
|
||||
if (auth_data.empty())
|
||||
{
|
||||
parsed_identified_with = parseIdentifiedWith(pos, expected, auth_data);
|
||||
parsed_identified_with = parseIdentifiedOrNotIdentified(pos, expected, auth_data);
|
||||
|
||||
if (!parsed_identified_with)
|
||||
{
|
||||
|
@ -53,3 +53,5 @@ First auth method can't specify type if WITH keyword is not present
|
||||
SYNTAX_ERROR
|
||||
RESET AUTHENTICATION METHODS TO NEW can only be used on alter statement
|
||||
BAD_ARGUMENTS
|
||||
ADD NOT IDENTIFIED should result in syntax error
|
||||
SYNTAX_ERROR
|
||||
|
@ -147,4 +147,7 @@ ${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} IDENTIFIED plaintext_password
|
||||
echo "RESET AUTHENTICATION METHODS TO NEW can only be used on alter statement"
|
||||
${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} RESET AUTHENTICATION METHODS TO NEW" 2>&1 | grep -m1 -o "BAD_ARGUMENTS"
|
||||
|
||||
echo "ADD NOT IDENTIFIED should result in syntax error"
|
||||
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} ADD NOT IDENTIFIED" 2>&1 | grep -m1 -o "SYNTAX_ERROR"
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS ${user}"
|
||||
|
Loading…
Reference in New Issue
Block a user