2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ParserCheckQuery.h>
|
|
|
|
#include <Parsers/CommonParsers.h>
|
|
|
|
#include <Parsers/ExpressionElementParsers.h>
|
|
|
|
#include <Parsers/ASTCheckQuery.h>
|
2019-07-03 13:17:19 +00:00
|
|
|
#include <Parsers/ParserPartition.h>
|
2021-09-06 22:13:54 +00:00
|
|
|
#include <Parsers/parseDatabaseAndTableName.h>
|
2014-08-05 10:52:06 +00:00
|
|
|
|
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");
|
2019-07-03 13:17:19 +00:00
|
|
|
ParserKeyword s_partition("PARTITION");
|
2017-07-10 03:28:12 +00:00
|
|
|
ParserToken s_dot(TokenType::Dot);
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2019-07-03 13:17:19 +00:00
|
|
|
ParserPartition partition_parser;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
if (!s_check_table.ignore(pos, expected))
|
2014-08-05 10:52:06 +00:00
|
|
|
return false;
|
|
|
|
|
2019-07-03 13:17:19 +00:00
|
|
|
auto query = std::make_shared<ASTCheckQuery>();
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2021-11-16 08:58:28 +00:00
|
|
|
if (!parseDatabaseAndTableAsAST(pos, expected, query->database, query->table))
|
2021-09-06 22:13:54 +00:00
|
|
|
return false;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2019-07-03 13:17:19 +00:00
|
|
|
if (s_partition.ignore(pos, expected))
|
|
|
|
{
|
|
|
|
if (!partition_parser.parse(pos, query->partition, expected))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-09-06 22:13:54 +00:00
|
|
|
if (query->database)
|
|
|
|
query->children.push_back(query->database);
|
|
|
|
|
|
|
|
if (query->table)
|
|
|
|
query->children.push_back(query->table);
|
|
|
|
|
2019-07-03 13:17:19 +00:00
|
|
|
node = query;
|
2014-08-05 10:52:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-20 12:43:20 +00:00
|
|
|
|
|
|
|
}
|