diff --git a/parser/parser.y b/parser/parser.y index e504f4ef949e6..80b283c5a9a53 100644 --- a/parser/parser.y +++ b/parser/parser.y @@ -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) diff --git a/parser/parser_test.go b/parser/parser_test.go index f74536fe8462f..6ec18688bf07d 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -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,