2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ParserUseQuery.h>
|
|
|
|
#include <Parsers/ASTIdentifier.h>
|
|
|
|
#include <Parsers/ExpressionElementParsers.h>
|
|
|
|
#include <Parsers/CommonParsers.h>
|
|
|
|
#include <Parsers/ASTUseQuery.h>
|
2017-03-11 00:27:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2018-02-26 03:37:08 +00:00
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
bool ParserUseQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
2017-03-11 00:27:59 +00:00
|
|
|
{
|
2017-06-18 03:07:03 +00:00
|
|
|
ParserKeyword s_use("USE");
|
2017-04-01 07:20:54 +00:00
|
|
|
ParserIdentifier name_p;
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
if (!s_use.ignore(pos, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2019-01-14 18:15:04 +00:00
|
|
|
ASTPtr database;
|
2017-07-10 03:28:12 +00:00
|
|
|
if (!name_p.parse(pos, database, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2018-02-26 03:37:08 +00:00
|
|
|
auto query = std::make_shared<ASTUseQuery>();
|
2019-08-08 20:02:30 +00:00
|
|
|
tryGetIdentifierNameInto(database, query->database);
|
2017-04-01 07:20:54 +00:00
|
|
|
node = query;
|
2017-03-11 00:27:59 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return true;
|
2017-03-11 00:27:59 +00:00
|
|
|
}
|
2018-02-26 03:37:08 +00:00
|
|
|
|
2017-03-11 00:27:59 +00:00
|
|
|
}
|