ClickHouse/dbms/src/Parsers/ParserKillQueryQuery.cpp

68 lines
1.8 KiB
C++
Raw Normal View History

2016-11-30 17:31:05 +00:00
#include <DB/Parsers/ParserKillQueryQuery.h>
#include <DB/Parsers/ASTKillQueryQuery.h>
#include <DB/Parsers/ASTIdentifier.h>
#include <DB/Parsers/ASTLiteral.h>
#include <DB/Parsers/CommonParsers.h>
#include <DB/Parsers/ASTSelectQuery.h>
#include <DB/Parsers/ASTTablesInSelectQuery.h>
#include <DB/Parsers/ParserSelectQuery.h>
#include <DB/Parsers/ExpressionElementParsers.h>
#include <DB/Parsers/ExpressionListParsers.h>
#include <DB/Common/typeid_cast.h>
namespace DB
{
bool ParserKillQueryQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected)
{
Pos begin = pos;
auto query = std::make_shared<ASTKillQueryQuery>();
2016-11-30 17:31:05 +00:00
ParserWhiteSpaceOrComments ws;
2016-11-30 17:31:05 +00:00
ws.ignore(pos, end);
2016-11-30 17:31:05 +00:00
if (!ParserString{"KILL", true, true}.ignore(pos, end, max_parsed_pos, expected))
return false;
2016-11-30 17:31:05 +00:00
ws.ignore(pos, end);
2016-11-30 17:31:05 +00:00
if (!ParserString{"QUERY", true, true}.ignore(pos, end, max_parsed_pos, expected))
return false;
2016-11-30 17:31:05 +00:00
ws.ignore(pos, end);
2016-11-30 17:31:05 +00:00
if (!ParserString{"WHERE", true, true}.ignore(pos, end, max_parsed_pos, expected))
return false;
2016-11-30 17:31:05 +00:00
ws.ignore(pos, end);
2016-11-30 17:31:05 +00:00
ParserExpressionWithOptionalAlias p_where_expression(false);
if (!p_where_expression.parse(pos, end, query->where_expression, max_parsed_pos, expected))
return false;
2016-11-30 17:31:05 +00:00
ws.ignore(pos, end);
2016-11-30 17:31:05 +00:00
if (ParserString{"SYNC", true, true}.ignore(pos, end))
query->sync = true;
else if (ParserString{"ASYNC", true, true}.ignore(pos, end))
query->sync = false;
else if (ParserString{"TEST", true, true}.ignore(pos, end))
query->test = true;
else
expected = "[SYNC|ASYNC|TEST]";
2016-11-30 17:31:05 +00:00
ws.ignore(pos, end);
2017-01-24 13:39:39 +00:00
query->range = StringRange(begin, pos);
2017-01-24 13:39:39 +00:00
node = std::move(query);
2016-11-30 17:31:05 +00:00
return true;
2016-11-30 17:31:05 +00:00
}
}