-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
cmd, expression, parser: support GBK for builtin function char() #29543
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
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 submitting an approval review. |
/cc @xiongjiwei @zimulala @tangenta @wjhuang2016 |
expression/builtin_string_vec.go
Outdated
result.AppendString(tempString) | ||
dBytes := b.convertToBytes(bigints) | ||
|
||
resultBytes, err := charset.NewEncoding(b.tp.Charset).Decode(nil, dBytes) |
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.
dest
in the Decode
should not be nil
. We should create a buffer before the loop to avoid to allocate memory in the transform
.
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. @hawkingrei
21ce869
to
deaf542
Compare
@hawkingrei: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
parser/charset/encoding.go
Outdated
// Decode convert bytes from a specific charset to utf-8 charset. | ||
func (e *Encoding) Decode(dest, src []byte) ([]byte, error) { | ||
if !e.enabled() { | ||
if e.name == "utf-8" { |
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.
Use encodingLegacy
instead of utf-8
?
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 think utf-8
is better. encodingLegacy
may change someday, and validUTF8
is only design for utf8
.
parser/charset/encoding.go
Outdated
// Decode convert bytes from a specific charset to utf-8 charset. | ||
func (e *Encoding) Decode(dest, src []byte) ([]byte, error) { | ||
if !e.enabled() { | ||
if e.name == "utf-8" { | ||
return e.validUTF8(src) |
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 do we need to check utf8 here?
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 got it. But it seems that only char
using this check? Has this check been done elsewhere?
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.
If we have some invalid utf8
characters in store, add this check could find them. After add this, the behavior between utf8
and gbk
will be same. @zimulala
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, I mean we already do check on the parser layer, and we'll do it repeatedly when we call it.
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.
// TODO: Uncomment it when issue #29685 be closed | ||
// {"65", -1, 67.5, "utf8", nil, 1}, // with utf8, return nil | ||
// {"a", -1, 67.5, "utf8", nil, 2}, // with utf8, return nil | ||
// TODO: Uncomment it when gbk be added into charsetInfos |
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.
What is the charsetInfos
here?
If it is the session variable, we can try ctx.GetSessionVars().SetSystemVar(variable.CharacterSetConnection, v.charset)
.
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.
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.
Got it.
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 |
This pull request has been accepted and is ready to merge. Commit hash: 43aadbf
|
@Defined2014: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: close #29461
Problem Summary: support GBK for builtin function char()
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note