-
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
collation: fix tidb panic when compare string with collation #23760
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/run-check_dev_2 |
/bench |
r1, r2 := rune(0), rune(0) | ||
ai, bi := 0, 0 | ||
for ai < len(a) && bi < len(b) { | ||
r1, ai = decodeRune(a, ai) |
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.
Well, is it possible to keep decodeRune
with some additional validation checks?
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.
that will be the same with the golang library, it's faster because decodeRune
has no validation check.
/build |
tk.MustQuery(`select * from t where a > 0x80;`).Check(testkit.Rows("一 一")) | ||
tk.MustQuery(`select * from t where b > 0x80;`).Check(testkit.Rows("a a", "一 一")) | ||
|
||
// uncomment this when #23759 fix |
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.
#23759 has been fixed, so please uncomment these test.
r2, bsize := utf8.DecodeRuneInString(b) | ||
|
||
// Incorrect string, compare bytewise | ||
if (r1 == utf8.RuneError && asize == 1) || (r2 == utf8.RuneError && bsize == 1) { |
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.
Why need check size == 1
?
for len(str) > 0 { | ||
r, size := utf8.DecodeRuneInString(str) | ||
if r == utf8.RuneError && size == 1 { | ||
return buf |
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.
Any test to cover the change? Or the path is never be taken? I doubt the correctness of returning buf
directly...
What problem does this PR solve?
Issue Number: close #23506
Problem Summary:
please see #23506 (comment)
Check List
Tests
Side effects
since we have to check the string is valid or not, we almost have 20%-25% performance loss.
Release note