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: disallow multi-updates on primary key (#20603) #21113

Merged
merged 8 commits into from
Nov 26, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #20603 to release-4.0


What problem does this PR solve?

Issue Number: close #20594

Problem Summary:

MySQL doesn't allow multi-updates on primary key (i.e. updating primary key of the same table with different alias), but TiDB does.

What is changed and how it works?

  • Check for updates on primary keys and detect for multi-updates conflict.

Related changes

  • Need to cherry-pick to the release branch 3.0, 4.0

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM
  • Breaking backward compatibility

Release note

  • Disallow multi-updates on primary key

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@dyzsr you're already a collaborator in bot's repo.

@dyzsr
Copy link
Contributor

dyzsr commented Nov 17, 2020

/run-all-tests

1 similar comment
@dyzsr
Copy link
Contributor

dyzsr commented Nov 17, 2020

/run-all-tests

@dyzsr
Copy link
Contributor

dyzsr commented Nov 17, 2020

/run-all-tests

@dyzsr
Copy link
Contributor

dyzsr commented Nov 17, 2020

/run-unit-test

if !flags[i] {
continue
}
if col.IsPKHandleColumn(tbl.Meta()) || pkColumnsMap[content.TblID][col.ID] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why constructing a temporary map pkColumnsMap to check whether col is primary key?
Could col.Primary work the same way as pkColumnsMap[content.TblID][col.ID] here?

Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake. Using mysql.HasPriKeyFlag is enough, and I think #20603 should also change to this. Do I have to create another PR for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, of course.
Don't hesitate to improve the code quality, even tiny changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I've put this change into #20493. It may take longer time to review.

@dyzsr
Copy link
Contributor

dyzsr commented Nov 18, 2020

/run-all-tests

@dyzsr
Copy link
Contributor

dyzsr commented Nov 18, 2020

/run-tics-test

Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 19, 2020
@tiancaiamao
Copy link
Contributor

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 20, 2020
tiancaiamao
tiancaiamao previously approved these changes Nov 20, 2020
@tiancaiamao
Copy link
Contributor

/merge

@ti-srebot
Copy link
Contributor Author

Sorry @tiancaiamao, this branch cannot be merged without an approval of release maintainers

@tiancaiamao
Copy link
Contributor

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 26, 2020
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot merged commit 295e702 into pingcap:release-4.0 Nov 26, 2020
@tiancaiamao tiancaiamao deleted the release-4.0-a426a0e5ff45 branch November 26, 2020 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution 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. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants