From 9187e3d9e5e6b045212e02aac8a660e4b9ddde1c Mon Sep 17 00:00:00 2001 From: Fox Date: Fri, 15 Mar 2019 15:31:13 +0800 Subject: [PATCH] Fix last_day function (#9746) --- expression/builtin_time.go | 2 +- expression/builtin_time_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/expression/builtin_time.go b/expression/builtin_time.go index 7fddd000837aa..42b37ada48c38 100644 --- a/expression/builtin_time.go +++ b/expression/builtin_time.go @@ -5641,7 +5641,7 @@ func (b *builtinLastDaySig) evalTime(row chunk.Row) (types.Time, bool, error) { tm := arg.Time var day int year, month := tm.Year(), tm.Month() - if year == 0 && month == 0 && tm.Day() == 0 { + if month == 0 { return types.Time{}, true, handleInvalidTimeError(b.ctx, types.ErrIncorrectDatetimeValue.GenWithStackByArgs(arg.String())) } day = types.GetLastDay(year, month) diff --git a/expression/builtin_time_test.go b/expression/builtin_time_test.go index c368dbd530a06..b2669ffb5a062 100644 --- a/expression/builtin_time_test.go +++ b/expression/builtin_time_test.go @@ -2428,6 +2428,8 @@ func (s *testEvaluatorSuite) TestLastDay(c *C) { "0000-00-00", "1992-13-00", "2007-10-07 23:59:61", + "2005-00-00", + "2005-00-01", 123456789} for _, i := range testsNull {