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: fix the bug that wrong collation is used when try fast path for enum or set (#23217) #23293

Conversation

ti-srebot
Copy link
Contributor

@ti-srebot ti-srebot commented Mar 12, 2021

cherry-pick #23217 to release-5.0-rc
You can switch your code base to this Pull Request by using git-extras:

# In tidb repo:
git pr https://github.com/pingcap/tidb/pull/23293

After apply modifications, you can push your change to this PR via:

git push [email protected]:ti-srebot/tidb.git pr/23293:release-5.0-rc-689a5983e1c0

Signed-off-by: wjhuang2016 [email protected]

What problem does this PR solve?

Issue Number: close #23053

Problem Summary:
When comparing datum, we used the wrong collation.

		dVal, err := d.ConvertTo(stmtCtx, &col.FieldType)
		if err != nil {
			if terror.ErrorEqual(types.ErrOverflow, err) {
				return append(nvPairs, nameValuePair{colName: colName.Name.Name.L, value: d, param: param}), true
			}
			// Some scenarios cast to int with error, but we may use this value in point get.
			if !terror.ErrorEqual(types.ErrTruncatedWrongVal, err) {
				return nil, false
			}
		}
		cmp, err := d.CompareDatum(stmtCtx, &dval)

CompareDatum uses the d's collation, which is wrong.

What is changed and how it works?

d.CompareDatum(stmtCtx, &dval) =>
dVal.CompareDatum(stmtCtx, &d)

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

Release note

  • fix the bug that wrong collation is used when try fast path for enum or set

@ti-srebot ti-srebot requested review from a team as code owners March 12, 2021 12:02
@ti-srebot ti-srebot requested review from wshwsh12 and lzmhhh123 and removed request for a team March 12, 2021 12:02
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

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

@wshwsh12
Copy link
Contributor

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • wshwsh12

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 14, 2021
@wshwsh12 wshwsh12 removed their request for review March 14, 2021 13:52
@zz-jason zz-jason closed this Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants