From c83476c650d1f3fea8a808c293a4aeb8eb3713e8 Mon Sep 17 00:00:00 2001 From: imtbkcat Date: Wed, 15 Aug 2018 16:44:44 +0800 Subject: [PATCH 1/2] fix issue 7295 --- parser/parser.y | 4 ++++ parser/parser_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/parser/parser.y b/parser/parser.y index 73bc66d76c556..d5ce4743ec617 100644 --- a/parser/parser.y +++ b/parser/parser.y @@ -6561,6 +6561,10 @@ AuthOption: ByAuthString: true, } } +| "IDENTIFIED" "WITH" StringName + { + $$ = nil + } | "IDENTIFIED" "BY" "PASSWORD" HashString { $$ = &ast.AuthOption{ diff --git a/parser/parser_test.go b/parser/parser_test.go index b38e1e2de34b0..e28ee13cb676f 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1852,6 +1852,7 @@ 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 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}, From d8c040d9bedf609d3874222f854bf83af838145e Mon Sep 17 00:00:00 2001 From: imtbkcat Date: Thu, 16 Aug 2018 17:19:06 +0800 Subject: [PATCH 2/2] support more grammar --- parser/parser.y | 13 +++++++++++++ parser/parser_test.go | 2 ++ 2 files changed, 15 insertions(+) diff --git a/parser/parser.y b/parser/parser.y index d5ce4743ec617..fca1d0fb1ae2b 100644 --- a/parser/parser.y +++ b/parser/parser.y @@ -6565,6 +6565,19 @@ AuthOption: { $$ = 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{ diff --git a/parser/parser_test.go b/parser/parser_test.go index e28ee13cb676f..05f4934391dd2 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1853,6 +1853,8 @@ func (s *testParserSuite) TestPrivilege(c *C) { {"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},