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-05-30 14:18:08 +00:00
|
|
|
class ASTUserNamesWithHost;
|
2020-05-30 20:10:45 +00:00
|
|
|
class ASTRolesOrUsersSet;
|
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-05-20 20:31:55 +00:00
|
|
|
* [NOT IDENTIFIED | 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]
|
2020-05-20 20:31:55 +00:00
|
|
|
* [NOT IDENTIFIED | 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
|
|
|
* [[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;
|
|
|
|
|
2020-05-30 14:18:08 +00:00
|
|
|
std::shared_ptr<ASTUserNamesWithHost> names;
|
2020-02-04 22:37:04 +00:00
|
|
|
String new_name;
|
|
|
|
|
|
|
|
std::optional<Authentication> authentication;
|
2020-05-20 20:31:55 +00:00
|
|
|
bool show_password = true; /// formatImpl() will show the password or hash.
|
2020-02-04 22:37:04 +00:00
|
|
|
|
|
|
|
std::optional<AllowedClientHosts> hosts;
|
|
|
|
std::optional<AllowedClientHosts> add_hosts;
|
|
|
|
std::optional<AllowedClientHosts> remove_hosts;
|
|
|
|
|
2020-05-30 20:10:45 +00:00
|
|
|
std::shared_ptr<ASTRolesOrUsersSet> 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
|
|
|
};
|
|
|
|
}
|