From 4218f2836bb38ec79fd080fa88d09d3fe3766c3a Mon Sep 17 00:00:00 2001 From: Tjianke <34013484+Tjianke@users.noreply.github.com> Date: Sun, 7 Mar 2021 19:40:34 +0800 Subject: [PATCH] expression: fix wrong error info (#22760) --- types/overflow.go | 2 +- types/overflow_test.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/types/overflow.go b/types/overflow.go index 6bb9d658ac..c1533d4a44 100644 --- a/types/overflow.go +++ b/types/overflow.go @@ -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 diff --git a/types/overflow_test.go b/types/overflow_test.go index 27b7c2f80d..78d214f39b 100644 --- a/types/overflow_test.go +++ b/types/overflow_test.go @@ -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) }