diff --git a/types/time.go b/types/time.go index 6547eebd65191..f9e4d9e68ca2a 100644 --- a/types/time.go +++ b/types/time.go @@ -562,10 +562,8 @@ func (t *Time) check(sc *stmtctx.StatementContext) error { switch t.Type { case mysql.TypeTimestamp: err = checkTimestampType(sc, t.Time) - case mysql.TypeDatetime: + case mysql.TypeDatetime, mysql.TypeDate: err = checkDatetimeType(t.Time, allowZeroInDate, allowInvalidDate) - case mysql.TypeDate: - err = checkDateType(t.Time, allowZeroInDate, allowInvalidDate) } return errors.Trace(err) } diff --git a/types/time_test.go b/types/time_test.go index 5a00a4dca0f7f..01ba8f7710883 100644 --- a/types/time_test.go +++ b/types/time_test.go @@ -110,6 +110,8 @@ func (s *testTimeSuite) TestDateTime(c *C) { errTable := []string{ "1000-01-01 00:00:70", "1000-13-00 00:00:00", + "1201012736.0000", + "1201012736", "10000-01-01 00:00:00", "1000-09-31 00:00:00", "1001-02-29 00:00:00", @@ -177,6 +179,8 @@ func (s *testTimeSuite) TestDate(c *C) { errTable := []string{ "0121231", + "1201012736.0000", + "1201012736", "2019.01", }