expression: fix wrong error info (#22760)
This commit is contained in:
@ -200,7 +200,7 @@ func DivUintWithInt(a uint64, b int64) (uint64, error) {
|
||||
func DivIntWithUint(a int64, b uint64) (uint64, error) {
|
||||
if a < 0 {
|
||||
if uint64(-a) >= b {
|
||||
return 0, ErrOverflow.GenWithStackByArgs("BIGINT", fmt.Sprintf("(%d, %d)", a, b))
|
||||
return 0, ErrOverflow.GenWithStackByArgs("BIGINT UNSIGNED", fmt.Sprintf("(%d, %d)", a, b))
|
||||
}
|
||||
|
||||
return 0, nil
|
||||
|
||||
@ -329,16 +329,18 @@ func (s *testOverflowSuite) TestDiv(c *C) {
|
||||
rsh uint64
|
||||
ret uint64
|
||||
overflow bool
|
||||
err string
|
||||
}{
|
||||
{math.MinInt64, math.MaxInt64, 0, true},
|
||||
{0, 1, 0, false},
|
||||
{-1, math.MaxInt64, 0, false},
|
||||
{math.MinInt64, math.MaxInt64, 0, true, "*BIGINT UNSIGNED value is out of range in '\\(-9223372036854775808, 9223372036854775807\\)'"},
|
||||
{0, 1, 0, false, ""},
|
||||
{-1, math.MaxInt64, 0, false, ""},
|
||||
}
|
||||
|
||||
for _, t := range tblInt2 {
|
||||
ret, err := DivIntWithUint(t.lsh, t.rsh)
|
||||
if t.overflow {
|
||||
c.Assert(err, NotNil)
|
||||
c.Assert(err, ErrorMatches, t.err)
|
||||
} else {
|
||||
c.Assert(ret, Equals, t.ret)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user