Skip to content

Commit

Permalink
expression: fix wrong error info (pingcap#22760)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjianke authored Mar 7, 2021
1 parent 3750320 commit 4218f28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion types/overflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions types/overflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 4218f28

Please sign in to comment.