-
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
types: fix uint64 overflow bug in ConvertJSONToFloat
#11355
Changes from 3 commits
8400b83
424c307
732e3ab
57fbc52
592c82d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,8 +553,7 @@ func ConvertJSONToFloat(sc *stmtctx.StatementContext, j json.BinaryJSON) (float6 | |
case json.TypeCodeInt64: | ||
return float64(j.GetInt64()), nil | ||
case json.TypeCodeUint64: | ||
u, err := ConvertIntToUint(sc, j.GetInt64(), IntergerUnsignedUpperBound(mysql.TypeLonglong), mysql.TypeLonglong) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we consider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to consider this. // GetInt64 gets the int64 value.
func (bj BinaryJSON) GetInt64() int64 {
return int64(endian.Uint64(bj.Value))
}
// GetUint64 gets the uint64 value.
func (bj BinaryJSON) GetUint64() uint64 {
return endian.Uint64(bj.Value)
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need or needn't? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needn't |
||
return float64(u), errors.Trace(err) | ||
return float64(j.GetUint64()), nil | ||
case json.TypeCodeFloat64: | ||
return j.GetFloat64(), nil | ||
case json.TypeCodeString: | ||
|
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 not directly create a json column?
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 directly creat json, then I can not get a uint field(#11386 (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.
how about casting '9223372036854775808' to uint then cast to json?