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

#include <Parsers/IAST.h>


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

19 20 21
    bool id_mode = false;         /// true if `names` and `except_names` keep UUIDs, not names.
    bool allow_role_names = true; /// true if this set can contain names of roles.
    bool allow_user_names = true; /// true if this set can contain names of users.
V
Vitaly Baranov 已提交
22

23
    bool empty() const { return names.empty() && !current_user && !all; }
24
    void replaceCurrentUserTagWithName(const String & current_user_name);
V
Vitaly Baranov 已提交
25

26 27
    String getID(char) const override { return "RolesOrUsersSet"; }
    ASTPtr clone() const override { return std::make_shared<ASTRolesOrUsersSet>(*this); }
V
Vitaly Baranov 已提交
28 29 30
    void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
};
}