diff --git a/parser/parser.y b/parser/parser.y index f865f6b6e0..30e0fdc5bc 100644 --- a/parser/parser.y +++ b/parser/parser.y @@ -3722,9 +3722,10 @@ BlobType: x.Collate = charset.CharsetBin $$ = x } -| "BLOB" +| "BLOB" OptFieldLen { x := types.NewFieldType(mysql.TypeBlob) + x.Flen = $2.(int) x.Charset = charset.CharsetBin x.Collate = charset.CharsetBin $$ = x @@ -3751,9 +3752,10 @@ TextType: $$ = x } -| "TEXT" +| "TEXT" OptFieldLen { x := types.NewFieldType(mysql.TypeBlob) + x.Flen = $2.(int) $$ = x } | "MEDIUMTEXT" diff --git a/parser/parser_test.go b/parser/parser_test.go index 61ef350fcb..18d0fe6e84 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -426,6 +426,9 @@ func (s *testParserSuite) TestParser0(c *C) { // For national {"create table t (c1 national char(2), c2 national varchar(2))", true}, + // For blob and text field length + {"create table t (c1 blob(1024), c2 text(1024))", true}, + // For check {"create table t (c1 bool, c2 bool, check (c1 in (0, 1)), check (c2 in (0, 1)))", true},