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 TABLE ... SELECT' syntax (#4754) #6851

Merged
merged 8 commits into from
Jun 22, 2018

Conversation

bb7133
Copy link
Member

@bb7133 bb7133 commented Jun 16, 2018

What have you changed? (mandatory)

This is the first part of PRs for issue #4754:

  • updated 'parser/parser.y'(as well as some parser related go code like ddl.go/preprocess.go...) to support 'CREATE TABLE ... SELECT' SQL syntax
  • the further implementations(plan/runtime) will be in next PRs, for now, a 'CREATE TABLE ... SELECT is not implemented' error will be returned in preprocess.go

What are the type of the changes (mandatory)?

  • Bug fix

How has this PR been tested (mandatory)?

Some new SQL statements are added in the tests to verify the parsed result

Does this PR affect documentation (docs/docs-cn) update? (optional)

Nope

Refer to a related PR or issue link (optional)

Issue 4754: #4754

Benchmark result if necessary (optional)

Add a few positive/negative examples (optional)

@sre-bot
Copy link
Contributor

sre-bot commented Jun 16, 2018

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@zz-jason zz-jason added the contribution This PR is from a community contributor. label Jun 19, 2018
@shenli
Copy link
Member

shenli commented Jun 19, 2018

/add-to-whitelist

@shenli
Copy link
Member

shenli commented Jun 19, 2018

/run-all-tests

@winkyao
Copy link
Contributor

winkyao commented Jun 19, 2018

@bb7133 Thanks to your contribution, I'll look into the failed test case.

parser/parser.y Outdated
@@ -600,6 +600,7 @@ import (
ConstraintKeywordOpt "Constraint Keyword or empty"
CreateIndexStmtUnique "CREATE INDEX optional UNIQUE clause"
CreateTableOptionListOpt "create table option list opt"
CreateTableSelectOpt "Select/Union statement in CREATE TABLE ... SELECT"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep the indent.

parser/parser.y Outdated
@@ -653,6 +654,7 @@ import (
JoinType "join type"
KillOrKillTiDB "Kill or Kill TiDB"
LikeEscapeOpt "like escape option"
LikeTableWithOrWithoutParen "LIKE table_name or ( LIKE table_name )"
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

}
| "CREATE" "TABLE" IfNotExists TableName "LIKE" TableName
| "CREATE" "TABLE" IfNotExists TableName LikeTableWithOrWithoutParen
Copy link
Contributor

Choose a reason for hiding this comment

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

Add some test to LikeTableWithOrWithoutParen?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK~

@winkyao
Copy link
Contributor

winkyao commented Jun 20, 2018

/run-integration-common-test -tidb-test=pr/553

@winkyao
Copy link
Contributor

winkyao commented Jun 20, 2018

/run-common-test -tidb-test=pr/553

@winkyao
Copy link
Contributor

winkyao commented Jun 20, 2018

The failed internal tidb test case was fixed by tidb-test/pr/553, please address comments. @bb7133

parser/parser.y Outdated
@@ -1876,6 +1868,57 @@ PartDefStorageOpt:
| "ENGINE" eq Identifier
{}

OnDuplicateCreateTableOpt:
Copy link
Contributor

Choose a reason for hiding this comment

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

s/OnDuplicateCreateTableOpt/DuplicateOpt/g, MySQL name it opt_duplicate here.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, thanks!

| "AS"
{}

CreateTableSelectOpt:
Copy link
Contributor

@winkyao winkyao Jun 21, 2018

Choose a reason for hiding this comment

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

Miss '(' SelectStmt ')' ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is included in 'SubSelect', PTAL thanks

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

reset LGTM

@winkyao
Copy link
Contributor

winkyao commented Jun 21, 2018

/run-all-tests -tidb-test=pr/553

1 similar comment
@winkyao
Copy link
Contributor

winkyao commented Jun 21, 2018

/run-all-tests -tidb-test=pr/553

1. added tests for 'create table ... (like ...)' syntax
2. added more other tests for 'create table ... select' syntax
3. fixed a bug on 'TableMustHaveColumn'(MySQL errcode 1113) error
@winkyao
Copy link
Contributor

winkyao commented Jun 22, 2018

/run-all-tests -tidb-test=pr/553

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM @coocood @zz-jason PTAL

@winkyao winkyao added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 22, 2018
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/parser contribution This PR is from a community contributor. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants