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

executor: Make tidb_constraint_check_in_place session variable work for unique index #20939

Merged
merged 22 commits into from
Nov 25, 2020

Conversation

xiaodong-ji
Copy link
Contributor

@xiaodong-ji xiaodong-ji commented Nov 9, 2020

What problem does this PR solve?

Issue Number: close #20484

What is changed and how it works?

How it Works: Set the value of the tidb_constraint_check_in_place parameter to 0.

Check List

Tests

  • Unit test

Release note

  • fix: Make @@tidb_constraint_check_in_place session variable work for unique index.

@sre-bot
Copy link
Contributor

sre-bot commented Nov 9, 2020

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@xiaodong-ji xiaodong-ji changed the title Make @@tidb_constraint_check_in_place session variable work for unique index hp: Make tidb_constraint_check_in_place session variable work for unique index Nov 9, 2020
@xiaodong-ji xiaodong-ji changed the title hp: Make tidb_constraint_check_in_place session variable work for unique index executor: Make tidb_constraint_check_in_place session variable work for unique index Nov 9, 2020
@xiaodong-ji
Copy link
Contributor Author

/run-all-tests

@xiaodong-ji xiaodong-ji requested a review from a team as a code owner November 10, 2020 00:58
@xiaodong-ji xiaodong-ji requested review from wshwsh12 and removed request for a team November 10, 2020 00:58
@github-actions github-actions bot added the sig/execution SIG execution label Nov 10, 2020
@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Nov 13, 2020
@xiaodong-ji
Copy link
Contributor Author

/run-check_dev_2

@xiaodong-ji
Copy link
Contributor Author

/run-all-tests

@xiaodong-ji
Copy link
Contributor Author

/run-check_dev_2

@tiancaiamao
Copy link
Contributor

LGTM

@ti-challenge-bot
Copy link

There is no reward for this challenge pull request, so you can request a reward from @tiancaiamao.

Details

Tip : About reward you can refs to reward-command.

Warning: None

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

/reward 600

@ti-challenge-bot
Copy link

This PR's linked issue is not picked.

@xiaodong-ji
Copy link
Contributor Author

/run-all-tests

1 similar comment
@tiancaiamao
Copy link
Contributor

/run-all-tests

@tiancaiamao
Copy link
Contributor

/run-all-tests tidb-test=pr/1105

@tiancaiamao
Copy link
Contributor

/run-check_dev_2

@tiancaiamao
Copy link
Contributor

/run-check_dev_2
/run-unit-test

ti-srebot
ti-srebot previously approved these changes Nov 17, 2020
@coocood
Copy link
Member

coocood commented Nov 17, 2020

update unique is very likely to conflict, we should return error instantly.
So it's better to make it only affects auto-commit UPDATE.

@tiancaiamao
Copy link
Contributor

LGTM @coocood

@coocood
Copy link
Member

coocood commented Nov 25, 2020

@xiaodong-ji

can we remove the modifications like

tk.MustExec("set @@tidb_constraint_check_in_place = 1")

for other tests?

@xiaodong-ji
Copy link
Contributor Author

/run-check_dev_2

@@ -1389,6 +1390,7 @@ func (s *testSuite8) TestUpdate(c *C) {

// Test that in a transaction, when a constraint failed in an update statement, the record is not inserted.
tk.MustExec("create table update_unique (id int primary key, name int unique)")
tk.MustExec("set @@tidb_constraint_check_in_place = 1")
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to change this test?

Copy link
Contributor Author

@xiaodong-ji xiaodong-ji Nov 25, 2020

Choose a reason for hiding this comment

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

There is no begin keyword before the INSERT statement, Is it running in auto-commit mode. ^_^

Copy link
Member

Choose a reason for hiding this comment

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

auto-commit statements should return the same error or no error no mater tidb_constraint_check_in_place is set to '0' or '1'.

@coocood
Copy link
Member

coocood commented Nov 25, 2020

Theoretically, if we only affect auto-commit statements, all the old tests should pass without any modification.

@xiaodong-ji
Copy link
Contributor Author

PTAL @coocood

@coocood
Copy link
Member

coocood commented Nov 25, 2020

LGTM

@ti-srebot ti-srebot removed the status/LGT2 Indicates that a PR has LGTM 2. label Nov 25, 2020
@ti-srebot ti-srebot added the status/LGT3 The PR has already had 3 LGTM. label Nov 25, 2020
@coocood
Copy link
Member

coocood commented Nov 25, 2020

/merge

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

Your auto merge job has been accepted, waiting for:

  • 21268
  • 21268

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

/run-all-tests

@xiaodong-ji
Copy link
Contributor Author

/run-check_dev_2

@tiancaiamao tiancaiamao merged commit afaf38f into pingcap:master Nov 25, 2020
@ti-challenge-bot
Copy link

@xiaodong-ji, Congratulations, you get 600 in this PR, and your total score is 600 in hptc challenge program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution 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.
Projects
None yet
6 participants