mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 11:32:03 +00:00
51 lines
945 B
C++
51 lines
945 B
C++
#pragma once
|
|
|
|
#include <DB/Parsers/IParserBase.h>
|
|
#include <DB/Parsers/ExpressionElementParsers.h>
|
|
#include <DB/Parsers/CommonParsers.h>
|
|
#include <DB/Parsers/ASTIdentifier.h>
|
|
#include <DB/Parsers/ASTUseQuery.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Запрос USE db
|
|
*/
|
|
class ParserUseQuery : public IParserBase
|
|
{
|
|
protected:
|
|
String getName() { return "USE query"; }
|
|
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, String & expected)
|
|
{
|
|
Pos begin = pos;
|
|
|
|
ParserWhiteSpaceOrComments ws;
|
|
ParserString s_use("USE", true, true);
|
|
ParserIdentifier name_p;
|
|
|
|
ASTPtr database;
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
if (!s_use.ignore(pos, end, expected))
|
|
return false;
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
if (!name_p.parse(pos, end, database, expected))
|
|
return false;
|
|
|
|
ws.ignore(pos, end);
|
|
|
|
ASTUseQuery * query = new ASTUseQuery(StringRange(begin, pos));
|
|
node = query;
|
|
|
|
query->database = dynamic_cast<ASTIdentifier &>(*database).name;
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
}
|