-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser: Support CREATE USER extensions per MySQL 5.7 #269
Conversation
@morgo PTAL :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation, and add another test for the CREATE USER
that matches SHOW CREATE USER
. Thanks!
parser.y
Outdated
@@ -226,6 +227,7 @@ import ( | |||
smallIntType "SMALLINT" | |||
sql "SQL" | |||
sqlCalcFoundRows "SQL_CALC_FOUND_ROWS" | |||
ssl "SSL" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please match the indent level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I'll fix these indent issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I'll fix these indent issues.
parser.y
Outdated
@@ -266,6 +268,7 @@ import ( | |||
natural "NATURAL" | |||
|
|||
/* The following tokens belong to UnReservedKeyword. Notice: make sure these tokens are contained in UnReservedKeyword. */ | |||
account "ACCOUNT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent here is also incorrect.
parser.y
Outdated
@@ -285,6 +288,7 @@ import ( | |||
cascaded "CASCADED" | |||
charsetKwd "CHARSET" | |||
checksum "CHECKSUM" | |||
cipher "CIPHER" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here.
parser.y
Outdated
@@ -333,6 +338,7 @@ import ( | |||
hour "HOUR" | |||
identified "IDENTIFIED" | |||
isolation "ISOLATION" | |||
issuer "ISSUER" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here.
parser.y
Outdated
@@ -403,6 +410,7 @@ import ( | |||
start "START" | |||
statsPersistent "STATS_PERSISTENT" | |||
status "STATUS" | |||
subject "SUBJECT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here.
parser.y
Outdated
@@ -434,6 +442,7 @@ import ( | |||
identSQLErrors "ERRORS" | |||
week "WEEK" | |||
yearType "YEAR" | |||
x509 "X509" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here.
{`CREATE USER 'ttt' REQUIRE NONE;`, true, "CREATE USER `ttt`@`%`"}, | ||
{`CREATE USER 'ttt' REQUIRE ISSUER '/C=SE/ST=Stockholm/L=Stockholm/O=MySQL/CN=CA/emailAddress=ca@example.com' AND CIPHER 'EDH-RSA-DES-CBC3-SHA';`, true, "CREATE USER `ttt`@`%`"}, | ||
{`CREATE USER 'ttt' WITH MAX_QUERIES_PER_HOUR 1;`, true, "CREATE USER `ttt`@`%`"}, | ||
{`CREATE USER 'ttt'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 1 PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK;`, true, "CREATE USER `ttt`@`localhost`"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add the following test-case, since it will be quite common:
mysql> create user u1;
Query OK, 1 row affected (0.01 sec)
mysql> SHOW CREATE USER u1;
+------------------------------------------------------------------------------------------------------------------------+
| CREATE USER for u1@% |
+------------------------------------------------------------------------------------------------------------------------+
| CREATE USER 'u1'@'%' IDENTIFIED WITH 'mysql_native_password' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK |
+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll add this into tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'll add this case into tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, more formatting issues :-)
This is why I love go fmt, shame we can't use it on yacc files.
parser.y
Outdated
@@ -588,6 +597,9 @@ import ( | |||
BeginTransactionStmt "BEGIN TRANSACTION statement" | |||
BinlogStmt "Binlog base64 statement" | |||
CommitStmt "COMMIT statement" | |||
ConnectionOption "single connection options" | |||
ConnectionOptionList "connection options for CREATE USER statement" | |||
ConnectionOptions "optional connection options for CREATE USER statement" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
parser.y
Outdated
@@ -654,6 +666,7 @@ import ( | |||
OptionalBraces "optional braces" | |||
CastType "Cast function target type" | |||
CharsetName "Character set name" | |||
ClearPasswordExpireOptions "Clear password expire options" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
parser.y
Outdated
@@ -683,6 +696,7 @@ import ( | |||
DefaultTrueDistinctOpt "Distinct option which defaults to true" | |||
BuggyDefaultFalseDistinctOpt "Distinct option which accepts DISTINCT ALL and defaults to false" | |||
Enclosed "Enclosed by" | |||
RequireClause "Encrypted connections options" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
parser.y
Outdated
@@ -773,6 +791,8 @@ import ( | |||
OnUpdateOpt "optional ON UPDATE clause" | |||
OptGConcatSeparator "optional GROUP_CONCAT SEPARATOR" | |||
ReferOpt "reference option" | |||
RequireList "require list" | |||
RequireListElement "require list element" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
parser.y
Outdated
@@ -760,7 +774,11 @@ import ( | |||
PartDefOptionsOpt "PartDefOptionList option" | |||
PartDefOptionList "PartDefOption list" | |||
PartDefOption "COMMENT [=] xxx | TABLESPACE [=] tablespace_name | ENGINE [=] xxx" | |||
PasswordExpire "Single password option for create user statement" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
parser.y
Outdated
PasswordOrLockOptions: | ||
{ | ||
$$ = nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curly brackets don't align.
parser.y
Outdated
| PasswordOrLockOptionList | ||
{ | ||
$$ = nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curly brackets don't align.
parser.y
Outdated
PasswordOrLockOption | ||
{ | ||
$$ = nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curly brackets don't align.
parser.y
Outdated
| PasswordOrLockOptionList PasswordOrLockOption | ||
{ | ||
$$ = nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curly brackets don't align.
parser.y
Outdated
ClearPasswordExpireOptions: | ||
{ | ||
$$ = nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curly brackets don't align.
@morgo Thanks very much for pointing out these format issues :) . I forget this every time ...... :P |
LGTM |
@jackysp PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
fix #158
What is changed and how it works?
Support related syntax in Parser side. NOTE that this pr just make parser happy, no other things are really done . The related
ast
structures will be supplemented later.Check List
Tests
Code changes
Side effects
Related changes