2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ParserCheckQuery.h>
|
|
|
|
#include <Parsers/CommonParsers.h>
|
|
|
|
#include <Parsers/ASTIdentifier.h>
|
|
|
|
#include <Parsers/ExpressionElementParsers.h>
|
|
|
|
#include <Parsers/ASTCheckQuery.h>
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/typeid_cast.h>
|
2016-11-20 12:43:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
bool ParserCheckQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
2014-08-05 10:52:06 +00:00
|
|
|
{
|
2017-06-18 03:07:03 +00:00
|
|
|
ParserKeyword s_check_table("CHECK TABLE");
|
2017-07-10 03:28:12 +00:00
|
|
|
ParserToken s_dot(TokenType::Dot);
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ParserIdentifier table_parser;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTPtr table;
|
|
|
|
ASTPtr database;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
if (!s_check_table.ignore(pos, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2017-07-10 03:28:12 +00:00
|
|
|
if (!table_parser.parse(pos, database, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
if (s_dot.ignore(pos))
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2017-07-10 03:28:12 +00:00
|
|
|
if (!table_parser.parse(pos, table, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2018-02-26 03:37:08 +00:00
|
|
|
auto query = std::make_shared<ASTCheckQuery>();
|
2017-04-01 07:20:54 +00:00
|
|
|
query->database = typeid_cast<const ASTIdentifier &>(*database).name;
|
|
|
|
query->table = typeid_cast<const ASTIdentifier &>(*table).name;
|
2017-07-10 03:28:12 +00:00
|
|
|
node = query;
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
table = database;
|
2018-02-26 03:37:08 +00:00
|
|
|
auto query = std::make_shared<ASTCheckQuery>();
|
2017-04-01 07:20:54 +00:00
|
|
|
query->table = typeid_cast<const ASTIdentifier &>(*table).name;
|
2017-07-10 03:28:12 +00:00
|
|
|
node = query;
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return true;
|
2014-08-05 10:52:06 +00:00
|
|
|
}
|
2016-11-20 12:43:20 +00:00
|
|
|
|
|
|
|
}
|