mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
fix trailing comma issue
This commit is contained in:
parent
4c6aca2eed
commit
9abc001296
@ -225,21 +225,35 @@ namespace
|
||||
if (!ParserKeyword{Keyword::IDENTIFIED}.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
bool is_type_specifier_mandatory = ParserKeyword{Keyword::WITH}.ignore(pos, expected);
|
||||
|
||||
std::shared_ptr<ASTAuthenticationData> ast_authentication_data;
|
||||
while (parseAuthenticationData(pos, expected, ast_authentication_data, is_type_specifier_mandatory))
|
||||
// Parse first authentication method which doesn't come with a leading comma
|
||||
{
|
||||
authentication_methods.push_back(ast_authentication_data);
|
||||
bool is_type_specifier_mandatory = ParserKeyword{Keyword::WITH}.ignore(pos, expected);
|
||||
|
||||
if (!ParserToken{TokenType::Comma}.ignore(pos, expected))
|
||||
std::shared_ptr<ASTAuthenticationData> ast_authentication_data;
|
||||
|
||||
if (!parseAuthenticationData(pos, expected, ast_authentication_data, is_type_specifier_mandatory))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
authentication_methods.push_back(ast_authentication_data);
|
||||
}
|
||||
|
||||
// Need to save current position, process comma and only update real position in case there is an authentication method after
|
||||
// the comma. Otherwise, position should not be changed as it needs to be processed by other parsers and possibly throw error
|
||||
// on trailing comma.
|
||||
IParserBase::Pos aux_pos = pos;
|
||||
while (ParserToken{TokenType::Comma}.ignore(aux_pos, expected))
|
||||
{
|
||||
std::shared_ptr<ASTAuthenticationData> ast_authentication_data;
|
||||
|
||||
if (!parseAuthenticationData(aux_pos, expected, ast_authentication_data, false))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ParserToken{TokenType::Whitespace}.ignore(pos, expected);
|
||||
|
||||
is_type_specifier_mandatory = false;
|
||||
pos = aux_pos;
|
||||
authentication_methods.push_back(ast_authentication_data);
|
||||
}
|
||||
|
||||
return !authentication_methods.empty();
|
||||
|
@ -47,3 +47,5 @@ Use WITH without providing authentication type, should fail
|
||||
Syntax error
|
||||
Create user with ADD identification, should fail, add is not allowed for create query
|
||||
BAD_ARGUMENTS
|
||||
Trailing comma should result in syntax error
|
||||
SYNTAX_ERROR
|
||||
|
@ -138,4 +138,7 @@ ${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} IDENTIFIED WITH BY '1';" 2>&1
|
||||
echo "Create user with ADD identification, should fail, add is not allowed for create query"
|
||||
${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} ADD IDENTIFIED WITH plaintext_password by '1'" 2>&1 | grep -m1 -o "BAD_ARGUMENTS"
|
||||
|
||||
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"
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS ${user}"
|
||||
|
Loading…
Reference in New Issue
Block a user