Merge pull request #290 from pingcap/siddontang/blob-text-option-length

parser: blob and text support field length option
This commit is contained in:
siddontang
2015-09-29 12:58:44 +08:00
2 changed files with 7 additions and 2 deletions

View File

@ -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"

View File

@ -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},