1#pragma once
2
3#include <Parsers/IAST.h>
4#include <Access/RowPolicy.h>
5#include <utility>
6#include <vector>
7
8
9namespace DB
10{
11class ASTRoleList;
12
13/** CREATE [ROW] POLICY [IF NOT EXISTS | OR REPLACE] name ON [database.]table
14 * [AS {PERMISSIVE | RESTRICTIVE}]
15 * [FOR {SELECT | INSERT | UPDATE | DELETE | ALL}]
16 * [USING condition]
17 * [WITH CHECK condition] [,...]
18 * [TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
19 *
20 * ALTER [ROW] POLICY [IF EXISTS] name ON [database.]table
21 * [RENAME TO new_name]
22 * [AS {PERMISSIVE | RESTRICTIVE}]
23 * [FOR {SELECT | INSERT | UPDATE | DELETE | ALL}]
24 * [USING {condition | NONE}]
25 * [WITH CHECK {condition | NONE}] [,...]
26 * [TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
27 */
28class ASTCreateRowPolicyQuery : public IAST
29{
30public:
31 bool alter = false;
32
33 bool if_exists = false;
34 bool if_not_exists = false;
35 bool or_replace = false;
36
37 RowPolicy::FullNameParts name_parts;
38 String new_policy_name;
39
40 std::optional<bool> is_restrictive;
41 using ConditionIndex = RowPolicy::ConditionIndex;
42 std::vector<std::pair<ConditionIndex, ASTPtr>> conditions;
43
44 std::shared_ptr<ASTRoleList> roles;
45
46 String getID(char) const override;
47 ASTPtr clone() const override;
48 void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
49};
50}
51