expression: give the full error message when the result of calling the exp function is out of range (#11862)
This commit is contained in:
committed by
pingcap-github-bot
parent
d95a15ee3e
commit
b438bf21f6
@ -1589,7 +1589,7 @@ func (b *builtinExpSig) evalReal(row chunk.Row) (float64, bool, error) {
|
||||
}
|
||||
exp := math.Exp(val)
|
||||
if math.IsInf(exp, 0) || math.IsNaN(exp) {
|
||||
s := fmt.Sprintf("exp(%s)", strconv.FormatFloat(val, 'f', -1, 64))
|
||||
s := fmt.Sprintf("exp(%s)", b.args[0].String())
|
||||
return 0, false, types.ErrOverflow.GenWithStackByArgs("DOUBLE", s)
|
||||
}
|
||||
return exp, false, nil
|
||||
|
||||
@ -422,6 +422,17 @@ func (s *testIntegrationSuite) TestMathBuiltin(c *C) {
|
||||
terr = errors.Cause(err).(*terror.Error)
|
||||
c.Assert(terr.Code(), Equals, terror.ErrCode(mysql.ErrDataOutOfRange))
|
||||
c.Assert(rs.Close(), IsNil)
|
||||
tk.MustExec("drop table if exists t")
|
||||
tk.MustExec("create table t(a float)")
|
||||
tk.MustExec("insert into t values(1000000)")
|
||||
rs, err = tk.Exec("select exp(a) from t")
|
||||
c.Assert(err, IsNil)
|
||||
_, err = session.GetRows4Test(ctx, tk.Se, rs)
|
||||
c.Assert(err, NotNil)
|
||||
terr = errors.Cause(err).(*terror.Error)
|
||||
c.Assert(terr.Code(), Equals, terror.ErrCode(mysql.ErrDataOutOfRange))
|
||||
c.Assert(err.Error(), Equals, "[types:1690]DOUBLE value is out of range in 'exp(test.t.a)'")
|
||||
c.Assert(rs.Close(), IsNil)
|
||||
|
||||
// for conv
|
||||
result = tk.MustQuery("SELECT CONV('a', 16, 2);")
|
||||
|
||||
Reference in New Issue
Block a user