-
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
*: support parsing all PARTITION BY syntax #345
Conversation
This comment has been minimized.
This comment has been minimized.
PTAL @tiancaiamao @winkyao cc @csuzhangxc |
|
||
// 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"}, |
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.
by key ()
... is this a valid one?
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.
@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.
LGTM |
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?
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.
HASH
KEY
RANGE
— and theVALUES LESS THAN
clausesLIST
— and theVALUES IN
andDEFAULT
clausesSYSTEM_TIME
— and theHISTORY
andCURRENT
clausesThe parse result is now saved entirely into the AST. Constructs like
SUBPARTITION
and options likeENGINE
are 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 BY
syntax. As a side effect,ALTER TABLE t1,;
is no longer valid (ALTER TABLE t1;
is still valid).In
ALTER TABLE ... DROP PARTITION
andTRUNCATION PARTITION
, support parsing and restoring multiple partition names.Support restoring
ALTER TABLE ... ENABLE KEYS
andDISABLE KEYS
(for easy testing).Corresponding TiDB PR: pingcap/tidb#10672
Check List
Tests
Code changes
Side effects
Related changes