-
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: add builtin function WEIGHT_STRING()
#14792
Conversation
PTAL @wjhuang2016 @qw4990 @kennytm |
} | ||
|
||
// TODO: refactor padding codes after padding is supported by collators. | ||
switch b.padding { |
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.
Please update it since the padding PR is merged.
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.
Done.
760b9b5
to
455e361
Compare
455e361
to
c65845b
Compare
01768e5
to
c96e628
Compare
PTAL @qw4990 @kennytm @wjhuang2016 |
c.Assert(test.expect, IsNil) | ||
continue | ||
} | ||
res, err := result.ToString() |
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.
ToString may be wrong if the collation is general_ci
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's fine, the string
in Go does not have to be a valid utf8
sequence.
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.
I've updated the tests for utf8mb4_general_ci
.
3070c68
to
93eb676
Compare
Addressed, PTAL @wjhuang2016 @qw4990 @kennytm |
expression/builtin_string_test.go
Outdated
{nil, "NONE", 0, nil}, | ||
{7, "NONE", 0, nil}, | ||
{"a", "NONE", 0, "a"}, | ||
{"a ", "NONE", 0, "a "}, | ||
{"中", "NONE", 0, "中"}, | ||
{"中 ", "NONE", 0, "中 "}, | ||
{nil, "CHAR", 5, nil}, | ||
{7, "CHAR", 5, nil}, | ||
{"a", "CHAR", 5, "a "}, | ||
{"a ", "CHAR", 5, "a "}, | ||
{"中", "CHAR", 5, "中 "}, | ||
{"中 ", "CHAR", 5, "中 "}, | ||
{nil, "BINARY", 5, nil}, | ||
{7, "BINARY", 2, "7\x00"}, | ||
{"a", "BINARY", 1, "a"}, | ||
{"ab", "BINARY", 1, "a"}, | ||
{"a", "BINARY", 5, "a\x00\x00\x00\x00"}, | ||
{"a ", "BINARY", 5, "a \x00\x00\x00"}, | ||
{"中", "BINARY", 1, "\xe4"}, | ||
{"中", "BINARY", 2, "\xe4\xb8"}, | ||
{"中", "BINARY", 3, "中"}, | ||
{"中", "BINARY", 5, "中\x00\x00"}, |
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.
Test the result when expr
is a datetime or some types else.
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.
It's kind of complicated to add them here, I've added the integration test and put those cases there, PTAL.
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.
Please add some integration tests.
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.
LGTM
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.
LGTM
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.
LGTM
/merge |
/run-all-tests |
@bb7133 merge failed. |
81d7f4f
to
5f9604c
Compare
/run-all-tests |
What problem does this PR solve?
This PR tries to close #3580
Related parser PR: pingcap/parser#743
What is changed and how it works?
Add builtin-function
WEIGHT_STRING()
. MySQL manual described most of its behavior except:str
is of numeric types,WEIGHT_STRING()
in MySQL returnsNULL
, so does this implementation.str
is of other types rather than string or numeric, the result ofWEIGHT_STRING()
in MySQL is not cleared. I simply evaluated the input as string.Check List
Tests
Code changes
Side effects