2018-05-21 13:49:54 +00:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2019-08-08 20:02:30 +00:00
|
|
|
tryGetIdentifierNameInto(database, database_str);
|
|
|
|
tryGetIdentifierNameInto(table, table_str);
|
2018-05-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
database_str = "";
|
2019-08-08 20:02:30 +00:00
|
|
|
tryGetIdentifierNameInto(database, table_str);
|
2018-05-21 13:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|