*: support parsing all PARTITION BY syntax#345
Merged
bb7133 merged 3 commits intopingcap:masterfrom Jun 11, 2019
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
PTAL @tiancaiamao @winkyao cc @csuzhangxc |
tiancaiamao
reviewed
Jun 10, 2019
|
|
||
| // there must be at least one column/partition/value inside (...) | ||
| {"create table t1 (a int) partition by hash (a) ()", false, ""}, | ||
| {"create table t1 (a int primary key) partition by key ()", true, "CREATE TABLE `t1` (`a` INT PRIMARY KEY) PARTITION BY KEY () PARTITIONS 1"}, |
Collaborator
There was a problem hiding this comment.
by key () ... is this a valid one?
Contributor
Author
There was a problem hiding this comment.
@tiancaiamao Yes it is valid, this means partition by the primary key or a non-null unique key.
https://dev.mysql.com/doc/refman/8.0/en/partitioning-key.html
Where no column name is specified as the partitioning key, the table's primary key is used, if there is one.
If there is no primary key but there is a unique key, then the unique key is used for the partitioning key:
However, if the unique key column were not defined as
NOT NULL, then the previous statement would fail.
Collaborator
|
LGTM |
bb7133
reviewed
Jun 11, 2019
kennytm
added a commit
to kennytm/parser
that referenced
this pull request
Jul 22, 2019
kennytm
added a commit
that referenced
this pull request
Aug 5, 2019
tiancaiamao
pushed a commit
to tiancaiamao/parser
that referenced
this pull request
Apr 27, 2021
lyonzhi
pushed a commit
to lyonzhi/parser
that referenced
this pull request
Apr 25, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Support all PARTITION BY syntax from MariaDB, since DM needs to use pingcap/parser to parse these upstream DDLs.
What is changed and how it works?
Parses all 5 types of partitions supported by MariaDB, i.e.
HASHKEYRANGE— and theVALUES LESS THANclausesLIST— and theVALUES INandDEFAULTclausesSYSTEM_TIME— and theHISTORYandCURRENTclausesThe parse result is now saved entirely into the AST. Constructs like
SUBPARTITIONand options likeENGINEare now part of the Restore text.As partitions options are a subset of table options, the following 4 new table options can now be parsed:
TABLESPACE= identifierDATA DIRECTORY= stringINDEX DIRECTORY= stringNODEGROUP= numberSupport parsing and restoring
ALTER TABLE ... PARTITION BYsyntax. As a side effect,ALTER TABLE t1,;is no longer valid (ALTER TABLE t1;is still valid).In
ALTER TABLE ... DROP PARTITIONandTRUNCATION PARTITION, support parsing and restoring multiple partition names.Support restoring
ALTER TABLE ... ENABLE KEYSandDISABLE KEYS(for easy testing).Corresponding TiDB PR: pingcap/tidb#10672
Check List
Tests
Code changes
Side effects
Related changes