2013-09-03 20:21:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Parsers/IParserBase.h>
|
|
|
|
#include <DB/Parsers/CommonParsers.h>
|
|
|
|
#include <DB/Parsers/ExpressionElementParsers.h>
|
|
|
|
#include <DB/Parsers/ASTIdentifier.h>
|
|
|
|
#include <DB/Parsers/ASTShowProcesslistQuery.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Запрос SHOW PROCESSLIST
|
|
|
|
*/
|
|
|
|
class ParserShowProcesslistQuery : public IParserBase
|
|
|
|
{
|
|
|
|
protected:
|
2014-03-10 12:25:37 +00:00
|
|
|
const char * getName() const { return "SHOW PROCESSLIST query"; }
|
2013-09-03 20:21:28 +00:00
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected)
|
2013-09-03 20:21:28 +00:00
|
|
|
{
|
|
|
|
Pos begin = pos;
|
|
|
|
|
|
|
|
ParserWhiteSpaceOrComments ws;
|
|
|
|
ParserString s_show("SHOW", true, true);
|
|
|
|
ParserString s_processlist("PROCESSLIST", true, true);
|
|
|
|
ParserString s_format("FORMAT", true, true);
|
|
|
|
|
|
|
|
ASTPtr format;
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
if (!s_show.ignore(pos, end, max_parsed_pos, expected))
|
2013-09-03 20:21:28 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
if (!s_processlist.ignore(pos, end, max_parsed_pos, expected))
|
2013-09-03 20:21:28 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
if (s_format.ignore(pos, end, max_parsed_pos, expected))
|
2013-09-03 20:21:28 +00:00
|
|
|
{
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
|
|
|
|
ParserIdentifier format_p;
|
|
|
|
|
2015-04-11 03:10:23 +00:00
|
|
|
if (!format_p.parse(pos, end, format, max_parsed_pos, expected))
|
2013-09-03 20:21:28 +00:00
|
|
|
return false;
|
2014-06-26 00:58:14 +00:00
|
|
|
typeid_cast<ASTIdentifier &>(*format).kind = ASTIdentifier::Format;
|
2013-09-03 20:21:28 +00:00
|
|
|
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
ASTShowProcesslistQuery * query = new ASTShowProcesslistQuery(StringRange(begin, pos));
|
|
|
|
query->format = format;
|
|
|
|
node = query;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|