Skip to content

Commit

Permalink
parser: Support PACK_KEYS option in CreateTable statement (#5554) (#5602
Browse files Browse the repository at this point in the history
)

Parse but ignore it.
  • Loading branch information
shenli authored and hanfei1991 committed Jan 10, 2018
1 parent 17c1319 commit 571f0bb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ const (
TableOptionRowFormat
TableOptionStatsPersistent
TableOptionShardRowID
TableOptionPackKeys
)

// RowFormat types
Expand Down
1 change: 1 addition & 0 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ import (
or "OR"
order "ORDER"
outer "OUTER"
packKeys "PACK_KEYS"
partition "PARTITION"
precisionType "PRECISION"
primary "PRIMARY"
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 571f0bb

Please sign in to comment.