expression: fix wrong error info (#22760)

This commit is contained in:
Tjianke
2021-03-07 19:40:34 +08:00
committed by GitHub
parent 3750320899
commit 4218f2836b
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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)
}