From 571f0bbd28a0b8155a5ee831992c986b90d21ab7 Mon Sep 17 00:00:00 2001 From: Shen Li Date: Wed, 10 Jan 2018 14:09:04 +0800 Subject: [PATCH] parser: Support PACK_KEYS option in CreateTable statement (#5554) (#5602) Parse but ignore it. --- ast/ddl.go | 1 + parser/misc.go | 1 + parser/parser.y | 6 ++++++ parser/parser_test.go | 3 +++ 4 files changed, 11 insertions(+) diff --git a/ast/ddl.go b/ast/ddl.go index cc90698a84756..74d909b41cd46 100644 --- a/ast/ddl.go +++ b/ast/ddl.go @@ -619,6 +619,7 @@ const ( TableOptionRowFormat TableOptionStatsPersistent TableOptionShardRowID + TableOptionPackKeys ) // RowFormat types diff --git a/parser/misc.go b/parser/misc.go index 1a352d6f8668c..bca674becb0e2 100644 --- a/parser/misc.go +++ b/parser/misc.go @@ -362,6 +362,7 @@ var tokenMap = map[string]int{ "QUICK": quick, "SHARD_ROW_ID_BITS": shardRowIDBits, "RANGE": rangeKwd, + "PACK_KEYS": packKeys, "READ": read, "REAL": realType, "REDUNDANT": redundant, diff --git a/parser/parser.y b/parser/parser.y index 6af5fc8a63f1e..6d76da83702c4 100644 --- a/parser/parser.y +++ b/parser/parser.y @@ -172,6 +172,7 @@ import ( or "OR" order "ORDER" outer "OUTER" + packKeys "PACK_KEYS" partition "PARTITION" precisionType "PRECISION" primary "PRIMARY" @@ -5025,6 +5026,11 @@ TableOption: { $$ = &ast.TableOption{Tp: ast.TableOptionShardRowID, UintValue: $3.(uint64)} } +| "PACK_KEYS" EqOpt StatsPersistentVal + { + // Parse it but will ignore it. + $$ = &ast.TableOption{Tp: ast.TableOptionPackKeys} + } StatsPersistentVal: "DEFAULT" diff --git a/parser/parser_test.go b/parser/parser_test.go index 578e2311c666d..cde8addfa27f5 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1290,6 +1290,9 @@ func (s *testParserSuite) TestDDL(c *C) { {"create table t (c int) STATS_PERSISTENT = default", true}, {"create table t (c int) STATS_PERSISTENT = 0", true}, {"create table t (c int) STATS_PERSISTENT = 1", true}, + {"create table t (c int) PACK_KEYS = 1", true}, + {"create table t (c int) PACK_KEYS = 0", true}, + {"create table t (c int) PACK_KEYS = DEFAULT", true}, // partition option {"create table t (c int) PARTITION BY HASH (c) PARTITIONS 32;", true}, {"create table t (c int) PARTITION BY RANGE (Year(VDate)) (PARTITION p1980 VALUES LESS THAN (1980) ENGINE = MyISAM, PARTITION p1990 VALUES LESS THAN (1990) ENGINE = MyISAM, PARTITION pothers VALUES LESS THAN MAXVALUE ENGINE = MyISAM)", true},