-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
expression: avoid padding 0 when implicitly cast to binary #35053
Merged
Merged
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5baa9b2
fix(expression): avoid padding 0 when implicitly cast to binary
Willendless 1b91a40
fix: avoid doing cast when agg charset is binary
Willendless 54209f3
chore: remove old workaround
Willendless 8a7b314
Merge branch 'master' into fix-issue-34823
zanmato1984 9800be0
Merge branch 'pingcap:master' into fix-issue-34823
Willendless 2d2990c
fix: use VarString type of cast
Willendless 11b4d2b
test: add between expr binary collation in single side test
Willendless 56a1190
Merge remote-tracking branch 'origin' into fix-issue-34823
Willendless cd70155
feat: use VarString type of cast for in expression
Willendless db1248f
test: add unit test for in expression
Willendless bdb5de1
chore: migrate tests to explain test
Willendless 1f0da0b
Merge branch 'pingcap:master' into fix-issue-34823
Willendless 8cb262c
Merge branch 'master' into fix-issue-34823
ti-chi-bot e010a6b
Merge branch 'master' into fix-issue-34823
ti-chi-bot bc17196
Merge branch 'master' into fix-issue-34823
ti-chi-bot e5b5134
Merge branch 'master' into fix-issue-34823
ti-chi-bot 078019a
Merge branch 'master' into fix-issue-34823
ti-chi-bot 8e668ab
Merge branch 'master' into fix-issue-34823
ti-chi-bot 427c947
Merge branch 'master' into fix-issue-34823
ti-chi-bot d1c04e5
Merge branch 'master' into fix-issue-34823
ti-chi-bot 10588ae
Merge branch 'master' into fix-issue-34823
ti-chi-bot bce6632
Merge branch 'master' into fix-issue-34823
ti-chi-bot 08278cd
Merge branch 'master' into fix-issue-34823
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can not just return if the target charset is
binary
.because we had support charset
gbk
, if charset oft1.a
isgbk
it will have ato_binary
function, after we return directly, it will be missed I think.see why we have
to_binary
#29736There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is wrong because t3.a doesn't convert to binary collation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
gbk
, tidb will build ato_binary
is becausegbk
doesn't belong to legacy charset and when argument is legacy charset (for example the default charset utf8mb4), there is no need to buildto_binary
function according to the code HandleBinaryLiteral.My change actually will still add the
to_binary
function when the code build function forle/ge
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for
It is the expected behavior that t3.a doesn't convert to binary collation since its charset (utf8mb4) is legacy...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that we need to make t3.a <= t4.c use the binary collation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure the behavior of
to_binary
. If it will pad 0 for other charsets then forcing t3.a <= t4.c to use the binary collation might still cause mismatch between tidb and mysql. And mysql actually doesn't do conversion when target charset isbinary
.Issue #34823 shows that the return result of mysql is not the same as using
cast(test.t1.a, binary(20))
since it will pad 0 at the end of a and affect the comparison result.This one is indeed a problem..
There are only following cases:
BuildCastCollationFunction
is not necessarybinary
collation but should not padding 0