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: check foreign key constraint when drop,modify,change column #14043

Merged
merged 12 commits into from
Dec 17, 2019

Conversation

crazycs520
Copy link
Contributor

What problem does this PR solve?

  • Check foreign key constraint when drop,modify,change column.

parser PR: pingcap/parser#675

Otherwise, select information_schema.KEY_COLUMN_USAGE will panic.

create table t1 (a int,b int);
create table t2 (c int,d int,foreign key (d) references t1 (b));
alter table t2 drop column d;
select count(*) from information_schema.KEY_COLUMN_USAGE;

What is changed and how it works?

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Fix issue of select KEY_COLUMN_USAGE table panic cause by the foreign key.

@codecov
Copy link

codecov bot commented Dec 12, 2019

Codecov Report

Merging #14043 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #14043   +/-   ##
===========================================
  Coverage   80.2778%   80.2778%           
===========================================
  Files           483        483           
  Lines        121919     121919           
===========================================
  Hits          97874      97874           
  Misses        16287      16287           
  Partials       7758       7758

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

Rest LGTM

ddl/column.go Show resolved Hide resolved
ddl/db_test.go Show resolved Hide resolved
Copy link
Contributor

@reafans reafans left a comment

Choose a reason for hiding this comment

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

How about this, fristly,drop the constraint Foreign key in t.Meta().ForeignKeys,and then execut "alter table t4 drop column d",it should be no err.

@crazycs520
Copy link
Contributor Author

@reafans, Already add test for the case you said.

@reafans
Copy link
Contributor

reafans commented Dec 16, 2019

/run-all-tests

@reafans
Copy link
Contributor

reafans commented Dec 16, 2019

LGTM

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@zimulala zimulala added status/can-merge Indicates a PR has been approved by a committer. status/LGT3 The PR has already had 3 LGTM. labels Dec 17, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2019

/run-all-tests

@sre-bot sre-bot merged commit 5940bb2 into pingcap:master Dec 17, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2019

cherry pick to release-2.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Dec 17, 2019

cherry pick to release-3.0 failed

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/LGT3 The PR has already had 3 LGTM. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants