-
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
fix compatibility bug with convert string to int return wrong result #7483
Conversation
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
types/convert.go
Outdated
@@ -275,7 +275,8 @@ func floatStrToIntStr(validFloat string) (string, error) { | |||
} | |||
if exp > 0 && int64(intCnt) > (math.MaxInt64-int64(exp)) { | |||
// (exp + incCnt) overflows MaxInt64. | |||
return validFloat, ErrOverflow.GenByArgs("BIGINT", validFloat) | |||
sc.AppendError(ErrOverflow.GenByArgs("BIGINT", oriStr)) |
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.
This means the previous error message is wrong?
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.
yes, the error message in this case is like below
mysql> show warnings;
+---------+------+-------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '125e342.83' |
+---------+------+-------------------------------------------------+
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.
So why AppendError
? Shouldn't we AppendWarning
?
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.
yes, it's should be AppendWarning. Already Fixed
types/convert.go
Outdated
@@ -292,7 +293,8 @@ func floatStrToIntStr(validFloat string) (string, error) { | |||
extraZeroCount := intCnt - len(digits) | |||
if extraZeroCount > 20 { | |||
// Return overflow to avoid allocating too much memory. |
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.
Should we update this comment?
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.
@CodeRushing Please update this comment.
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.
@zz-jason already updated
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
/run-all-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
What problem does this PR solve?
fix the issue#7398
What is changed and how it works?
In types.floatStrToIntStr function, when extraZeroCount or intCnt overflows, just AppendWarning and return nil error
Check List
Tests