2019-12-01 22:01:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-09-15 09:55:57 +00:00
|
|
|
|
|
|
|
using Strings = std::vector<String>;
|
|
|
|
|
2020-02-10 02:26:56 +00:00
|
|
|
/// Represents a set of users/roles like
|
2021-02-26 22:37:00 +00:00
|
|
|
/// {user_name | role_name | CURRENT_USER | ALL | NONE} [,...]
|
|
|
|
/// [EXCEPT {user_name | role_name | CURRENT_USER | ALL | NONE} [,...]]
|
2020-05-30 20:10:45 +00:00
|
|
|
class ASTRolesOrUsersSet : public IAST
|
2019-12-01 22:01:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-02-26 22:37:00 +00:00
|
|
|
bool all = false;
|
2020-02-10 15:24:33 +00:00
|
|
|
Strings names;
|
2019-12-01 22:01:05 +00:00
|
|
|
bool current_user = false;
|
2020-02-10 15:24:33 +00:00
|
|
|
Strings except_names;
|
2019-12-01 22:01:05 +00:00
|
|
|
bool except_current_user = false;
|
2020-05-29 06:54:27 +00:00
|
|
|
|
2021-03-11 13:44:00 +00:00
|
|
|
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
|
2019-12-01 22:01:05 +00:00
|
|
|
|
2020-02-10 15:24:33 +00:00
|
|
|
bool empty() const { return names.empty() && !current_user && !all; }
|
2021-02-26 22:37:00 +00:00
|
|
|
void replaceCurrentUserTag(const String & current_user_name);
|
2019-12-01 22:01:05 +00:00
|
|
|
|
2020-05-30 20:10:45 +00:00
|
|
|
String getID(char) const override { return "RolesOrUsersSet"; }
|
|
|
|
ASTPtr clone() const override { return std::make_shared<ASTRolesOrUsersSet>(*this); }
|
2019-12-01 22:01:05 +00:00
|
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
|
|
};
|
|
|
|
}
|