diff --git a/expression/integration_test.go b/expression/integration_test.go index 710fa471da86d..7ae1430955acd 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -3528,6 +3528,11 @@ func (s *testIntegrationSuite) TestTimeLiteral(c *C) { _, err = tk.Exec("select time '20171231235959.999999';") c.Assert(err, NotNil) c.Assert(terror.ErrorEqual(err, types.ErrIncorrectDatetimeValue.GenWithStackByArgs("20171231235959.999999")), IsTrue) + + _, err = tk.Exec("select ADDDATE('2008-01-34', -1);") + c.Assert(err, IsNil) + tk.MustQuery("Show warnings;").Check(testutil.RowsWithSep("|", + "Warning|1292|Incorrect datetime value: '2008-1-34'")) } func (s *testIntegrationSuite) TestTimestampLiteral(c *C) { diff --git a/types/time.go b/types/time.go index 1915b01873629..cb9355acdafc6 100644 --- a/types/time.go +++ b/types/time.go @@ -1470,7 +1470,7 @@ func checkDateRange(t MysqlTime) error { func checkMonthDay(year, month, day int, allowInvalidDate bool) error { if month < 0 || month > 12 { - return errors.Trace(ErrIncorrectDatetimeValue.GenWithStackByArgs(month)) + return errors.Trace(ErrIncorrectDatetimeValue.GenWithStackByArgs(fmt.Sprintf("%d-%d-%d", year, month, day))) } maxDay := 31 @@ -1484,7 +1484,7 @@ func checkMonthDay(year, month, day int, allowInvalidDate bool) error { } if day < 0 || day > maxDay { - return errors.Trace(ErrIncorrectDatetimeValue.GenWithStackByArgs(day)) + return errors.Trace(ErrIncorrectDatetimeValue.GenWithStackByArgs(fmt.Sprintf("%d-%d-%d", year, month, day))) } return nil }