Use ALTER USER DROP HOST instead of ALTER USER REMOVE HOST for consistency.

This commit is contained in:
Vitaly Baranov 2020-04-05 21:44:28 +03:00
parent bc3e2cb48c
commit d0af31bbcf
6 changed files with 9 additions and 9 deletions

View File

@ -195,7 +195,7 @@ void ASTCreateUserQuery::formatImpl(const FormatSettings & format, FormatState &
if (add_hosts)
formatHosts("ADD", *add_hosts, format);
if (remove_hosts)
formatHosts("REMOVE", *remove_hosts, format);
formatHosts("DROP", *remove_hosts, format);
if (default_roles)
formatDefaultRoles(*default_roles, format);

View File

@ -19,7 +19,7 @@ class ASTSettingsProfileElements;
* ALTER USER [IF EXISTS] name
* [RENAME TO new_name]
* [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}]
* [[ADD|REMOVE] HOST {LOCAL | NAME 'name' | NAME REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
* [[ADD|DROP] HOST {LOCAL | NAME 'name' | NAME REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
* [DEFAULT ROLE role [,...] | ALL | ALL EXCEPT role [,...] ]
* [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...]
*/

View File

@ -318,7 +318,7 @@ bool ParserCreateUserQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
if (new_name.empty() && parseRenameTo(pos, expected, new_name, new_host_pattern))
continue;
if (parseHosts(pos, expected, "ADD", add_hosts) || parseHosts(pos, expected, "REMOVE", remove_hosts))
if (parseHosts(pos, expected, "ADD", add_hosts) || parseHosts(pos, expected, "DROP", remove_hosts))
continue;
}

View File

@ -14,7 +14,7 @@ namespace DB
* ALTER USER [IF EXISTS] name
* [RENAME TO new_name]
* [IDENTIFIED [WITH {PLAINTEXT_PASSWORD|SHA256_PASSWORD|DOUBLE_SHA1_PASSWORD}] BY {'password'|'hash'}]
* [[ADD|REMOVE] HOST {LOCAL | NAME 'name' | NAME REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
* [[ADD|DROP] HOST {LOCAL | NAME 'name' | NAME REGEXP 'name_regexp' | IP 'address' | LIKE 'pattern'} [,...] | ANY | NONE]
* [SETTINGS variable [= value] [MIN [=] min_value] [MAX [=] max_value] [READONLY|WRITABLE] | PROFILE 'profile_name'] [,...]
*/
class ParserCreateUserQuery : public IParserBase

View File

@ -15,7 +15,7 @@ namespace
boost::algorithm::trim(name);
String pattern = "@";
String pattern = "%";
if (ParserToken{TokenType::At}.ignore(pos, expected))
{
@ -25,7 +25,7 @@ namespace
boost::algorithm::trim(pattern);
}
if (pattern != "@")
if (pattern != "%")
name += '@' + pattern;
user_name = std::move(name);

View File

@ -21,10 +21,10 @@ SHOW CREATE USER test_user_01075;
ALTER USER test_user_01075 ADD HOST IP '127.0.0.1';
SHOW CREATE USER test_user_01075;
ALTER USER test_user_01075 REMOVE HOST IP '2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d';
ALTER USER test_user_01075 DROP HOST IP '2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d';
SHOW CREATE USER test_user_01075;
ALTER USER test_user_01075 REMOVE HOST NAME 'localhost';
ALTER USER test_user_01075 DROP HOST NAME 'localhost';
SHOW CREATE USER test_user_01075;
ALTER USER test_user_01075 HOST LIKE '@.somesite.com';
@ -47,7 +47,7 @@ DROP USER test_user_01075;
CREATE USER test_user_01075_x@localhost;
SHOW CREATE USER test_user_01075_x@localhost;
ALTER USER test_user_01075_x@localhost RENAME TO test_user_01075_x@'@';
ALTER USER test_user_01075_x@localhost RENAME TO test_user_01075_x@'%';
SHOW CREATE USER test_user_01075_x;
ALTER USER test_user_01075_x RENAME TO test_user_01075_x@'192.168.23.15';