Skip to content
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

Merged
merged 12 commits into from
Apr 2, 2019

Conversation

spongedu
Copy link
Contributor

@spongedu spongedu commented Apr 1, 2019

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

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change

Side effects

Related changes

@spongedu spongedu changed the title [WIP]Parser: Support CREATE USER extensions per MySQL 5.7 Parser: Support CREATE USER extensions per MySQL 5.7 Apr 1, 2019
@spongedu
Copy link
Contributor Author

spongedu commented Apr 1, 2019

@morgo PTAL :)

Copy link
Contributor

@morgo morgo left a 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"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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`"},
Copy link
Contributor

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)

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

@morgo morgo left a 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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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
}
Copy link
Contributor

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
}
Copy link
Contributor

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
}
Copy link
Contributor

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
}
Copy link
Contributor

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
}
Copy link
Contributor

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.

@spongedu
Copy link
Contributor Author

spongedu commented Apr 1, 2019

@morgo Thanks very much for pointing out these format issues :) . I forget this every time ...... :P

@morgo
Copy link
Contributor

morgo commented Apr 1, 2019

LGTM

@morgo
Copy link
Contributor

morgo commented Apr 1, 2019

@jackysp PTAL

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support CREATE USER extensions per MySQL 5.7
3 participants