ASTRolesOrUsersSet.h 1.2 KB
Newer Older
V
Vitaly Baranov 已提交
1 2 3 4 5 6 7
#pragma once

#include <Parsers/IAST.h>


namespace DB
{
A
Artem Zuikov 已提交
8 9 10

using Strings = std::vector<String>;

11
/// Represents a set of users/roles like
12 13
/// {user_name | role_name | CURRENT_USER | ALL | NONE} [,...]
/// [EXCEPT {user_name | role_name | CURRENT_USER | ALL | NONE} [,...]]
14
class ASTRolesOrUsersSet : public IAST
V
Vitaly Baranov 已提交
15 16
{
public:
17
    bool all = false;
18
    Strings names;
V
Vitaly Baranov 已提交
19
    bool current_user = false;
20
    Strings except_names;
V
Vitaly Baranov 已提交
21
    bool except_current_user = false;
22

23 24 25 26
    bool allow_users = true;      /// whether this set can contain names of users
    bool allow_roles = true;      /// whether this set can contain names of roles
    bool id_mode = false;         /// whether this set keep UUIDs instead of names
    bool use_keyword_any = false; /// whether the keyword ANY should be used instead of the keyword ALL
V
Vitaly Baranov 已提交
27

28
    bool empty() const { return names.empty() && !current_user && !all; }
29
    void replaceCurrentUserTag(const String & current_user_name);
V
Vitaly Baranov 已提交
30

31 32
    String getID(char) const override { return "RolesOrUsersSet"; }
    ASTPtr clone() const override { return std::make_shared<ASTRolesOrUsersSet>(*this); }
V
Vitaly Baranov 已提交
33 34 35
    void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
};
}