Skip to content

Commit

Permalink
parser: add 'IDENTIFIED WITH' option on create user statement (#7402)
Browse files Browse the repository at this point in the history
* fix issue 7295
  • Loading branch information
Lingyu Song authored and tiancaiamao committed Aug 17, 2018
1 parent 57f1914 commit 2ae4f7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -6561,6 +6561,23 @@ AuthOption:
ByAuthString: true,
}
}
| "IDENTIFIED" "WITH" StringName
{
$$ = nil
}
| "IDENTIFIED" "WITH" StringName "BY" AuthString
{
$$ = &ast.AuthOption {
AuthString: $5.(string),
ByAuthString: true,
}
}
| "IDENTIFIED" "WITH" StringName "AS" HashString
{
$$ = &ast.AuthOption{
HashString: $5.(string),
}
}
| "IDENTIFIED" "BY" "PASSWORD" HashString
{
$$ = &ast.AuthOption{
Expand Down
3 changes: 3 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,9 @@ func (s *testParserSuite) TestPrivilege(c *C) {
{"CREATE USER 'uesr1'@'localhost'", true},
{"CREATE USER 'uesr1'@`localhost`", true},
{"CREATE USER `uesr1`@'localhost'", true},
{"create user 'bug19354014user'@'%' identified WITH mysql_native_password", true},
{"create user 'bug19354014user'@'%' identified WITH mysql_native_password by 'new-password'", true},
{"create user 'bug19354014user'@'%' identified WITH mysql_native_password as 'hashstring'", true},
{`CREATE USER IF NOT EXISTS 'root'@'localhost' IDENTIFIED BY 'new-password'`, true},
{`CREATE USER 'root'@'localhost' IDENTIFIED BY 'new-password'`, true},
{`CREATE USER 'root'@'localhost' IDENTIFIED BY PASSWORD 'hashstring'`, true},
Expand Down

0 comments on commit 2ae4f7f

Please sign in to comment.