From 8078486bc2780896d7fd109b3e1c1d0d682d6541 Mon Sep 17 00:00:00 2001 From: dawxy <97687341@qq.com> Date: Fri, 23 Jun 2017 10:02:54 +0800 Subject: [PATCH] Add flen MAX_DATE_WIDTH=10 --- expression/builtin_time.go | 1 + expression/builtin_time_test.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/expression/builtin_time.go b/expression/builtin_time.go index cb3132cb5ce03..01be105f47c60 100644 --- a/expression/builtin_time.go +++ b/expression/builtin_time.go @@ -2024,6 +2024,7 @@ type makeDateFunctionClass struct { func (c *makeDateFunctionClass) getFunction(args []Expression, ctx context.Context) (builtinFunc, error) { tp := types.NewFieldType(mysql.TypeDate) + tp.Flen = 10 types.SetBinChsClnFlag(tp) bf, err := newBaseBuiltinFuncWithTp(args, tp, ctx, tpInt, tpInt) if err != nil { diff --git a/expression/builtin_time_test.go b/expression/builtin_time_test.go index c5b023a728fd6..8371744f3ba8c 100644 --- a/expression/builtin_time_test.go +++ b/expression/builtin_time_test.go @@ -1222,11 +1222,11 @@ func (s *testEvaluatorSuite) TestMakeDate(c *C) { {[]interface{}{10000, 3660}, "", true, false}, {[]interface{}{2060, 2900025}, "9999-12-31", false, false}, {[]interface{}{2060, 2900026}, "", true, false}, - {[]interface{}{nil, 2900025}, "", true, false}, - {[]interface{}{2060, nil}, "", true, false}, {[]interface{}{"71", 1}, "1971-01-01", false, false}, {[]interface{}{71, "1"}, "1971-01-01", false, false}, {[]interface{}{"71", "1"}, "1971-01-01", false, false}, + {[]interface{}{nil, 2900025}, "", true, false}, + {[]interface{}{2060, nil}, "", true, false}, {[]interface{}{nil, nil}, "", true, false}, {[]interface{}{errors.New("must error"), errors.New("must error")}, "", false, true}, } @@ -1239,6 +1239,7 @@ func (s *testEvaluatorSuite) TestMakeDate(c *C) { c.Assert(tp.Charset, Equals, charset.CharsetBin) c.Assert(tp.Collate, Equals, charset.CollationBin) c.Assert(tp.Flag, Equals, uint(mysql.BinaryFlag)) + c.Assert(tp.Flen, Equals, 10) d, err := f.Eval(nil) if t.getErr { c.Assert(err, NotNil)