2019-11-29 17:22:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
2020-04-05 23:03:20 +00:00
|
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
2019-11-29 17:22:56 +00:00
|
|
|
#include <Access/RowPolicy.h>
|
2020-05-07 02:45:27 +00:00
|
|
|
#include <array>
|
|
|
|
#include <optional>
|
2019-11-29 17:22:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-03-07 17:37:38 +00:00
|
|
|
class ASTExtendedRoleSet;
|
2019-11-29 17:22:56 +00:00
|
|
|
|
|
|
|
/** CREATE [ROW] POLICY [IF NOT EXISTS | OR REPLACE] name ON [database.]table
|
|
|
|
* [AS {PERMISSIVE | RESTRICTIVE}]
|
|
|
|
* [FOR {SELECT | INSERT | UPDATE | DELETE | ALL}]
|
|
|
|
* [USING condition]
|
|
|
|
* [WITH CHECK condition] [,...]
|
|
|
|
* [TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
|
|
|
|
*
|
|
|
|
* ALTER [ROW] POLICY [IF EXISTS] name ON [database.]table
|
|
|
|
* [RENAME TO new_name]
|
|
|
|
* [AS {PERMISSIVE | RESTRICTIVE}]
|
|
|
|
* [FOR {SELECT | INSERT | UPDATE | DELETE | ALL}]
|
|
|
|
* [USING {condition | NONE}]
|
|
|
|
* [WITH CHECK {condition | NONE}] [,...]
|
|
|
|
* [TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
|
|
|
|
*/
|
2020-04-05 23:03:20 +00:00
|
|
|
class ASTCreateRowPolicyQuery : public IAST, public ASTQueryWithOnCluster
|
2019-11-29 17:22:56 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool alter = false;
|
2020-02-21 19:27:12 +00:00
|
|
|
bool attach = false;
|
2019-11-29 17:22:56 +00:00
|
|
|
|
|
|
|
bool if_exists = false;
|
|
|
|
bool if_not_exists = false;
|
|
|
|
bool or_replace = false;
|
|
|
|
|
2020-05-02 22:30:28 +00:00
|
|
|
RowPolicy::NameParts name_parts;
|
|
|
|
String new_short_name;
|
2019-11-29 17:22:56 +00:00
|
|
|
|
|
|
|
std::optional<bool> is_restrictive;
|
2020-05-07 02:45:27 +00:00
|
|
|
std::array<std::optional<ASTPtr>, RowPolicy::MAX_CONDITION_TYPE> conditions; /// `nullopt` means "not set", `nullptr` means set to NONE.
|
2019-11-29 17:22:56 +00:00
|
|
|
|
2020-03-07 17:37:38 +00:00
|
|
|
std::shared_ptr<ASTExtendedRoleSet> roles;
|
2019-11-29 17:22:56 +00:00
|
|
|
|
|
|
|
String getID(char) const override;
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
2020-04-22 05:39:31 +00:00
|
|
|
void replaceCurrentUserTagWithName(const String & current_user_name) const;
|
2020-04-05 23:03:20 +00:00
|
|
|
ASTPtr getRewrittenASTWithoutOnCluster(const std::string &) const override { return removeOnCluster<ASTCreateRowPolicyQuery>(clone()); }
|
2019-11-29 17:22:56 +00:00
|
|
|
};
|
|
|
|
}
|