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

ddl: fix create table check for range columns partition #12622

Merged
merged 2 commits into from
Oct 15, 2019

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Oct 11, 2019

What problem does this PR solve?

This SQL should not success:

CREATE TABLE `t` ( 
`a` int(11) NOT NULL, 
`b` int(11) NOT NULL, 
`c` int(11) DEFAULT NULL, 
`d` int(11) DEFAULT NULL, 
`e` int(11) DEFAULT NULL, 
PRIMARY KEY (`a`,`b`), 
UNIQUE KEY (c,d) 
) PARTITION BY RANGE COLUMNS (b) ( 
PARTITION p0 VALUES LESS THAN (4), 
PARTITION p1 VALUES LESS THAN (7), 
PARTITION p2 VALUES LESS THAN (11) 
)

It should get an error like this:

"ERROR 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function"

What is changed and how it works?

We checked the constraint for "partition by range", but forget the "partition by range columns".

Fix bug, check the constraint.

Every unique key on the table must use every column in the table's partitioning expression.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Write release note for bug-fix or new feature.

Every unique key on the table must use every column in the table's partitioning expression.
Including range columns partitioned table.
@tiancaiamao
Copy link
Contributor Author

PTAL @crazycs520 @winkyao @zimulala

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 14, 2019
@tiancaiamao
Copy link
Contributor Author

PTAL @winkyao @jackysp

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

@jackysp jackysp added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 15, 2019
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

@tiancaiamao tiancaiamao added the status/can-merge Indicates a PR has been approved by a committer. label Oct 15, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 15, 2019

/run-all-tests

@sre-bot sre-bot merged commit 8a8f41d into pingcap:master Oct 15, 2019
@tiancaiamao tiancaiamao deleted the range-partition-check branch October 15, 2019 07:08
@sre-bot
Copy link
Contributor

sre-bot commented Oct 15, 2019

cherry pick to release-3.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Oct 15, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-3.0. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @tiancaiamao PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants