mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 06:01:57 +00:00
45 lines
913 B
C++
45 lines
913 B
C++
#include "parseDatabaseAndTableName.h"
|
|
#include <Parsers/ExpressionElementParsers.h>
|
|
#include <Parsers/ASTIdentifier.h>
|
|
#include <Parsers/CommonParsers.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
bool parseDatabaseAndTableName(IParser::Pos & pos, Expected & expected, String & database_str, String & table_str)
|
|
{
|
|
ParserToken s_dot(TokenType::Dot);
|
|
ParserIdentifier table_parser;
|
|
|
|
ASTPtr database;
|
|
ASTPtr table;
|
|
|
|
database_str = "";
|
|
table_str = "";
|
|
|
|
if (!table_parser.parse(pos, database, expected))
|
|
return false;
|
|
|
|
if (s_dot.ignore(pos))
|
|
{
|
|
if (!table_parser.parse(pos, table, expected))
|
|
{
|
|
database_str = "";
|
|
return false;
|
|
}
|
|
|
|
getIdentifierName(database, database_str);
|
|
getIdentifierName(table, table_str);
|
|
}
|
|
else
|
|
{
|
|
database_str = "";
|
|
getIdentifierName(database, table_str);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|