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

*: fix a bug caused by the wrong collation setting which leads to the wrong result of collation function #17116

Merged
merged 3 commits into from
May 15, 2020

Conversation

wjhuang2016
Copy link
Member

What problem does this PR solve?

Issue Number: close #17115

Problem Summary:

  1. We didn't set collation_connection if the collate is illegal.
  2. The result collation of collation function shouldn't use the argument's collation, or it will lead to unreadable binary output if the collation is binary.

What is changed and how it works?

  1. set the collation to default collation according to the charset if it's illegal.
  2. Set the result collation to collation_connection for collation function.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Integration test

Side effects

Release note

  • Fix a bug caused by the wrong collation setting which leads to the wrong result of collation function.

@wjhuang2016 wjhuang2016 requested a review from a team as a code owner May 12, 2020 05:26
@ghost ghost requested review from qw4990 and removed request for a team May 12, 2020 05:26
@codecov
Copy link

codecov bot commented May 12, 2020

Codecov Report

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

@@             Coverage Diff             @@
##             master     #17116   +/-   ##
===========================================
  Coverage   80.9240%   80.9240%           
===========================================
  Files           511        511           
  Lines        144863     144863           
===========================================
  Hits         117229     117229           
  Misses        18658      18658           
  Partials       8976       8976           

var ok bool
var charsetVal string
var err2 error
if name == CollationConnection {
Copy link
Member

Choose a reason for hiding this comment

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

Using a switch?

Copy link
Member Author

Choose a reason for hiding this comment

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

Double switch makes the code complicated.
I think it's fine since there are only three branches. If four, then I will use switch

Copy link
Contributor

@qw4990 qw4990 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 previously approved these changes May 14, 2020
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 May 14, 2020
@sre-bot
Copy link
Contributor

sre-bot commented May 14, 2020

Your auto merge job has been accepted, waiting for:

  • 16248
  • 17177

@sre-bot
Copy link
Contributor

sre-bot commented May 14, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented May 14, 2020

@wjhuang2016 merge failed.

@bb7133
Copy link
Member

bb7133 commented May 14, 2020

/run-unit-test

@wjhuang2016
Copy link
Member Author

/merge

@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2020

/run-all-tests

@wjhuang2016
Copy link
Member Author

/merge

@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2020

/run-all-tests

@wjhuang2016
Copy link
Member Author

/merge

@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2020

/run-all-tests

@wjhuang2016 wjhuang2016 reopened this May 15, 2020
@wjhuang2016
Copy link
Member Author

/merge

@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2020

@wjhuang2016 merge failed.

@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2020

/run-all-tests

@sre-bot sre-bot merged commit ea2e215 into pingcap:master May 15, 2020
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request May 15, 2020
@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2020

cherry pick to release-4.0 in PR #17231

ti-srebot pushed a commit that referenced this pull request Jul 28, 2020
… wrong result of collation function (#17116) (#17231)

Signed-off-by: sre-bot <[email protected]>
@wjhuang2016 wjhuang2016 deleted the fix_collation_func branch November 17, 2022 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

select collation(user()) get wrong result.
4 participants