2020-02-04 22:37:04 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
2020-04-05 23:03:20 +00:00
|
|
|
#include <Parsers/ASTQueryWithOnCluster.h>
|
2020-02-04 22:37:04 +00:00
|
|
|
#include <Access/Authentication.h>
|
|
|
|
#include <Access/AllowedClientHosts.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-03-07 17:37:38 +00:00
|
|
|
class ASTExtendedRoleSet;
|
2020-03-18 14:11:44 +00:00
|
|
|
class ASTSettingsProfileElements;
|
2020-02-17 02:59:56 +00:00
|
|
|
|
2020-02-04 22:37:04 +00:00
|
|
|
/** CREATE USER [IF NOT EXISTS | OR REPLACE] name
|
2020-03-18 14:11:44 +00:00
|
|
|
* [IDENTIFIED [WITH {NO_PASSWORD|PLAINTEXT_PASSWORD|SHA256_PASSWORD|SHA256_HASH|DOUBLE_SHA1_PASSWORD|DOUBLE_SHA1_HASH}] BY {'password'|'hash'}]
|
2020-04-08 23:57:45 +00:00
|
|
|
* [HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
|
2020-03-18 14:11:44 +00:00
|
|
|
* [DEFAULT ROLE role [,...]]
|
|
|
|
* [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...]
|
2020-02-04 22:37:04 +00:00
|
|
|
*
|
|
|
|
* ALTER USER [IF EXISTS] name
|
|
|
|
* [RENAME TO new_name]
|
|
|
|
* [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}]
|
2020-04-08 23:57:45 +00:00
|
|
|
* [[ADD|DROP] HOST {LOCAL | NAME 'name' | REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
|
2020-02-17 02:59:56 +00:00
|
|
|
* [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ]
|
2020-03-18 14:11:44 +00:00
|
|
|
* [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...]
|
2020-02-04 22:37:04 +00:00
|
|
|
*/
|
2020-04-05 23:03:20 +00:00
|
|
|
class ASTCreateUserQuery : public IAST, public ASTQueryWithOnCluster
|
2020-02-04 22:37:04 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool alter = false;
|
2020-02-21 19:27:12 +00:00
|
|
|
bool attach = false;
|
2020-02-04 22:37:04 +00:00
|
|
|
|
|
|
|
bool if_exists = false;
|
|
|
|
bool if_not_exists = false;
|
|
|
|
bool or_replace = false;
|
|
|
|
|
|
|
|
String name;
|
|
|
|
String new_name;
|
|
|
|
|
|
|
|
std::optional<Authentication> authentication;
|
|
|
|
|
|
|
|
std::optional<AllowedClientHosts> hosts;
|
|
|
|
std::optional<AllowedClientHosts> add_hosts;
|
|
|
|
std::optional<AllowedClientHosts> remove_hosts;
|
|
|
|
|
2020-03-07 17:37:38 +00:00
|
|
|
std::shared_ptr<ASTExtendedRoleSet> default_roles;
|
2020-02-17 02:59:56 +00:00
|
|
|
|
2020-03-18 14:11:44 +00:00
|
|
|
std::shared_ptr<ASTSettingsProfileElements> settings;
|
2020-02-04 22:37:04 +00:00
|
|
|
|
|
|
|
String getID(char) const override;
|
|
|
|
ASTPtr clone() const override;
|
2020-03-18 14:11:44 +00:00
|
|
|
void formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const override;
|
2020-04-05 23:03:20 +00:00
|
|
|
ASTPtr getRewrittenASTWithoutOnCluster(const std::string &) const override { return removeOnCluster<ASTCreateUserQuery>(clone()); }
|
2020-02-04 22:37:04 +00:00
|
|
|
};
|
|
|
|
}
|