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
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
bool ParserCheckQuery::parseImpl(IParser::Pos & pos, IParser::Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected)
|
2014-08-05 10:52:06 +00:00
|
|
|
{
|
2017-06-15 17:55:57 +00:00
|
|
|
ParserWhitespaceOrComments ws;
|
2017-04-01 07:20:54 +00:00
|
|
|
ParserString s_check("CHECK", true, true);
|
|
|
|
ParserString s_table("TABLE", true, true);
|
|
|
|
ParserString s_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-04-01 07:20:54 +00:00
|
|
|
auto query = std::make_shared<ASTCheckQuery>(StringRange(pos, end));
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ws.ignore(pos, end);
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
if (!s_check.ignore(pos, end, max_parsed_pos, expected))
|
|
|
|
return false;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ws.ignore(pos, end);
|
|
|
|
s_table.ignore(pos, end, max_parsed_pos, expected);
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ws.ignore(pos, end);
|
|
|
|
if (!table_parser.parse(pos, end, database, max_parsed_pos, expected))
|
|
|
|
return false;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
if (s_dot.ignore(pos, end))
|
|
|
|
{
|
|
|
|
if (!table_parser.parse(pos, end, table, max_parsed_pos, expected))
|
|
|
|
return false;
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
query->database = typeid_cast<const ASTIdentifier &>(*database).name;
|
|
|
|
query->table = typeid_cast<const ASTIdentifier &>(*table).name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
table = database;
|
|
|
|
query->table = typeid_cast<const ASTIdentifier &>(*table).name;
|
|
|
|
}
|
2014-08-05 10:52:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ws.ignore(pos, end);
|
2015-10-16 11:02:26 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
node = query;
|
|
|
|
return true;
|
2014-08-05 10:52:06 +00:00
|
|
|
}
|
2016-11-20 12:43:20 +00:00
|
|
|
|
|
|
|
}
|