Skip to content

Commit

Permalink
Add flen MAX_DATE_WIDTH=10
Browse files Browse the repository at this point in the history
  • Loading branch information
dawxy committed Jun 23, 2017
1 parent 828035c commit 8078486
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions expression/builtin_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}
Expand All @@ -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)
Expand Down

0 comments on commit 8078486

Please sign in to comment.