1#include <Parsers/ParserShowRowPoliciesQuery.h>
2#include <Parsers/ASTShowRowPoliciesQuery.h>
3#include <Parsers/CommonParsers.h>
4#include <Parsers/parseDatabaseAndTableName.h>
5
6
7namespace DB
8{
9namespace
10{
11 bool parseONDatabaseAndTableName(IParserBase::Pos & pos, Expected & expected, String & database, String & table_name)
12 {
13 return IParserBase::wrapParseImpl(pos, [&]
14 {
15 database.clear();
16 table_name.clear();
17 return ParserKeyword{"ON"}.ignore(pos, expected) && parseDatabaseAndTableName(pos, expected, database, table_name);
18 });
19 }
20}
21
22
23bool ParserShowRowPoliciesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
24{
25 if (!ParserKeyword{"SHOW POLICIES"}.ignore(pos, expected) && !ParserKeyword{"SHOW ROW POLICIES"}.ignore(pos, expected))
26 return false;
27
28 bool current = ParserKeyword{"CURRENT"}.ignore(pos, expected);
29
30 String database, table_name;
31 parseONDatabaseAndTableName(pos, expected, database, table_name);
32
33 auto query = std::make_shared<ASTShowRowPoliciesQuery>();
34 query->current = current;
35 query->database = std::move(database);
36 query->table_name = std::move(table_name);
37 node = query;
38 return true;
39}
40}
41