Skip to content

Commit

Permalink
support of character in create table statement (#7378)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lingyu Song authored and shenli committed Aug 13, 2018
1 parent 97ae3b3 commit bfceb50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -6094,6 +6094,17 @@ StringType:
}
$$ = x
}
| "NATIONAL" "CHARACTER" FieldLen OptBinary OptCollate
{
x := types.NewFieldType(mysql.TypeString)
x.Flen = $3.(int)
x.Charset = $4.(*ast.OptBinary).Charset
x.Collate = $5.(string)
if $4.(*ast.OptBinary).IsBinary {
x.Flag |= mysql.BinaryFlag
}
$$ = x
}
| Varchar FieldLen OptBinary OptCollate
{
x := types.NewFieldType(mysql.TypeVarchar)
Expand Down
6 changes: 6 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ func (s *testParserSuite) TestSimple(c *C) {
_, err = parser.ParseOneStmt(src, "", "")
c.Assert(err, IsNil)

// for #7371, support NATIONAL CHARACTER
// reference link: https://dev.mysql.com/doc/refman/5.7/en/charset-national.html
src = "CREATE TABLE t(c1 NATIONAL CHARACTER(10));"
_, err = parser.ParseOneStmt(src, "", "")
c.Assert(err, IsNil)

src = `CREATE TABLE t(a tinyint signed,
b smallint signed,
c mediumint signed,
Expand Down

0 comments on commit bfceb50

Please sign in to comment.