Skip to content

Commit

Permalink
update msg
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao committed Dec 11, 2023
1 parent 9531ee5 commit 56ff39f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,7 @@ func (du *baseDateArithmetical) intervalReformatString(ec errctx.Context, str st
}

if interval != str {
err = ec.HandleError(types.ErrTruncatedWrongVal.GenWithStackByArgs("INTEGER", str))
err = ec.HandleError(types.ErrTruncatedWrongVal.GenWithStackByArgs("DECIMAL", str))
}
case "SECOND":
// The unit SECOND is specially handled, for example:
Expand All @@ -2891,7 +2891,10 @@ func (du *baseDateArithmetical) intervalReformatString(ec errctx.Context, str st
// date + INTERVAL "1e2" MINUTE = date + INTERVAL 1 MINUTE
// date + INTERVAL "1.6" MINUTE = date + INTERVAL 1 MINUTE
var dec types.MyDecimal
err = ec.HandleError(dec.FromString([]byte(str)))
if err = dec.FromString([]byte(str)); err != nil {
truncatedErr := types.ErrTruncatedWrongVal.GenWithStackByArgs("DECIMAL", str)
err = ec.HandleErrorWithAlias(err, truncatedErr, truncatedErr)
}
interval = string(dec.ToString())
default:
interval = str
Expand Down
2 changes: 1 addition & 1 deletion tests/integrationtest/r/expression/time.result
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ set @@sql_mode=@old_sql_mode;
insert into t2 values('1', "1000-01-01 00:00:00" + INTERVAL "+1" YEAR);
insert into t2 values('-1', "1000-01-01 00:00:00" + INTERVAL "-1" YEAR);
insert into t2 values('0', "1000-01-01 00:00:00" + INTERVAL "XXX" YEAR);
Error 1292 (22007): Truncated incorrect INTEGER value: 'XXX'
Error 1292 (22007): Truncated incorrect DECIMAL value: 'XXX'
insert into t2 values('99999', "1000-01-01 00:00:00" + INTERVAL 99999 YEAR);
Error 1441 (22008): Datetime function: datetime field overflow
insert into t2 values('116777216', "1000-01-01 00:00:00" + INTERVAL 116777216 YEAR);
Expand Down

0 comments on commit 56ff39f

Please sign in to comment.