Skip to content
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

expression: fix wrong error info (#22760) #23152

Merged
merged 3 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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