-
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
improved the error message when encounter overflow. This is just a te… #3017
improved the error message when encounter overflow. This is just a te… #3017
Conversation
This pr addresses this issue. #2862 |
The error message are generated in overflow.go which reside in util/type. These error message requires runtime information i.e. If you guys agree this approach, I can continue to work on this. Otherwise, we can discuss and bring a new and better way to do this. |
The error code is much more important than the error message. |
@zhexuany |
@coocood gotcha. I think I already know a better way to address this issue. |
util/types/overflow.go
Outdated
) | ||
|
||
const ( | ||
CodeUintAdditionOperationOverflow terror.ErrCode = 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.
It is better to move this definition into util/types/errors.go. And if it is a mysql standard error, please also add the error code mapping in init(). Protocol layer will use this mapping to convert it to corresponding mysql error code.
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.
@shenli this pr is not ready yet. I am still doing more work. It is my bad not saying this in this PR. As you can see, the todo list is still marked as todo.
Will push all commits to this PR tonight for reviewing. |
@zhexuany OK |
37e302b
to
adda203
Compare
generates the following error message.
Is this error message ok? |
@zhexuany |
This snippet gives
The error code is correct but in a wired structure. Is this correct? |
@zhexuany |
@coocood I already did that. Actually, my question is the error info's structure.
The first one indicates the error happens in Is this understanding correct? Update: It is just |
64414c2
to
3246ed5
Compare
3246ed5
to
fa17467
Compare
LGTM |
expression/builtin_math.go
Outdated
@@ -24,6 +24,7 @@ import ( | |||
"strconv" | |||
"strings" | |||
|
|||
"fmt" |
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 move this line to line-26.
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
util/types/overflow.go
Outdated
@@ -16,16 +16,14 @@ package types | |||
import ( | |||
"math" | |||
|
|||
"fmt" |
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.
Move this line to line-18.
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
d.SetFloat64(math.Pow(x, y)) | ||
|
||
power := math.Pow(x, y) | ||
if math.IsInf(power, -1) || math.IsInf(power, 1) || math.IsNaN(power) { |
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 tests for this code.
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.
fa17467
to
a090973
Compare
a090973
to
0e0cd9d
Compare
LGTM |
…mp commit. Rebase is needed
This PR aims to improve error handling in
tidb
. Once PR merged into master,tidb
will have same behavior asmysql
does.