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

planner: support foreign key choose parent schema as default in CreateTable stmt (#12548) #12678

Merged
merged 2 commits into from Oct 15, 2019

Conversation

3pointer
Copy link
Contributor

@3pointer 3pointer commented Oct 14, 2019

cherry-pick #12548 to release-2.1


What problem does this PR solve?

Aligned with MySQL behavior

drop database if exists fk_test;
create database if not exists fk_test;
create table fk_test.t1 (c1 int not null primary key);
create table fk_test.t2 (id int not null primary key, c1 int not null, constraint foreign key (c1) references t1(c1));

MySQL can deal with above sql well, but TiDB will get ERROR 1046 (3D000) at line 4: No database selected

What is changed and how it works?

if foreign key has no schema, use parent table schema

Check List

Tests

  • Unit test

Code changes

  • NA

Side effects

  • NA

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Fix a compatibility issue that if the foreign key constraint in CREATE TABLE statement has no schema, schema of the created table should be used instead of returning No Database selected error.

@3pointer 3pointer added status/LGT2 Indicates that a PR has LGTM 2. status/PTAL type/bug-fix This PR fixes a bug. sig/planner SIG: Planner and removed status/LGT2 Indicates that a PR has LGTM 2. labels Oct 14, 2019
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

@crazycs520
Copy link
Contributor

/run-all-tests

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133 bb7133 added status/LGT2 Indicates that a PR has LGTM 2. status/can-merge Indicates a PR has been approved by a committer. labels Oct 15, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 15, 2019

Sorry @bb7133, you don't have permission to trigger auto merge event on this branch.

@ngaut ngaut merged commit d166d19 into pingcap:release-2.1 Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants