-
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 some bugs in builtinCastIntAsRealSig
and builtinCastIntAsDecimalSig
that treat unsigned val as signed val
#11745
Conversation
dbda87d
to
bdc8fd9
Compare
builtinCastIntAsRealSig
and builtinCastIntAsDecimalSig
that treat unsigned val as signed valbuiltinCastIntAsRealSig
and builtinCastIntAsDecimalSig
that treat unsigned val as signed val
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
bdc8fd9
to
93d0bae
Compare
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #11745 +/- ##
===============================================
- Coverage 81.4489% 81.442% -0.0069%
===============================================
Files 433 433
Lines 93240 93184 -56
===============================================
- Hits 75943 75891 -52
+ Misses 11867 11865 -2
+ Partials 5430 5428 -2 |
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #11745 +/- ##
===============================================
- Coverage 81.4489% 81.442% -0.0069%
===============================================
Files 433 433
Lines 93240 93184 -56
===============================================
- Hits 75943 75891 -52
+ Misses 11867 11865 -2
+ Partials 5430 5428 -2 |
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
@@ -463,7 +463,7 @@ func (b *builtinCastIntAsRealSig) evalReal(row chunk.Row) (res float64, isNull b | |||
} | |||
if !mysql.HasUnsignedFlag(b.tp.Flag) && !mysql.HasUnsignedFlag(b.args[0].GetType().Flag) { |
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.
Prefer to:
if unsigned := mysql.HasUnsignedFlag(b.args[0].GetType().Flag); !mysql.HasUnsignedFlag(b.tp.Flag) && !unsigned {
} else if b.inUnion && !unsigned {
} else {
}
@@ -489,7 +489,7 @@ func (b *builtinCastIntAsDecimalSig) evalDecimal(row chunk.Row) (res *types.MyDe | |||
} | |||
if !mysql.HasUnsignedFlag(b.tp.Flag) && !mysql.HasUnsignedFlag(b.args[0].GetType().Flag) { | |||
res = types.NewDecFromInt(val) | |||
} else if b.inUnion && val < 0 { | |||
} else if b.inUnion && !mysql.HasUnsignedFlag(b.args[0].GetType().Flag) && val < 0 { |
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.
ditto
Signed-off-by: H-ZeX hzx20112012@gmail.com
What problem does this PR solve?
in the original version, it will check
inUnion && val<0
no matter whether the val is unsigned(the val is always int64, but in sql, it may be unsigned), so in some case, it will dirrerent from mysql5.7What is changed and how it works?
add check of whether unsigned
Check List
Code changes
no.
Side effects
no.
Related changes