Skip to content

Commit

Permalink
Merge branch 'master' into forbit-drop-system-table
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao committed Aug 23, 2018
2 parents 8bbeac7 + 2ac2faf commit ad05169
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ var tokenMap = map[string]int{
"STORED": stored,
"STRAIGHT_JOIN": straightJoin,
"SUBDATE": subDate,
"SUBPARTITION": subpartition,
"SUBPARTITIONS": subpartitions,
"SUBSTR": substring,
"SUBSTRING": substring,
"SUM": sum,
Expand Down
26 changes: 21 additions & 5 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ import (
start "START"
statsPersistent "STATS_PERSISTENT"
status "STATUS"
subpartition "SUBPARTITION"
subpartitions "SUBPARTITIONS"
super "SUPER"
some "SOME"
global "GLOBAL"
Expand Down Expand Up @@ -721,6 +723,8 @@ import (
StatsPersistentVal "stats_persistent value"
StringName "string literal or identifier"
StringList "string list"
SubPartitionOpt "SubPartition option"
SubPartitionNumOpt "SubPartition NUM option"
Symbol "Constraint Symbol"
TableAsName "table alias name"
TableAsNameOpt "table alias name optional"
Expand Down Expand Up @@ -1796,11 +1800,11 @@ PartitionOpt:
{
$$ = nil
}
| "PARTITION" "BY" "RANGE" '(' Expression ')' PartitionNumOpt PartitionDefinitionListOpt
| "PARTITION" "BY" "RANGE" '(' Expression ')' PartitionNumOpt SubPartitionOpt PartitionDefinitionListOpt
{
var defs []*ast.PartitionDefinition
if $8 != nil {
defs = $8.([]*ast.PartitionDefinition)
if $9 != nil {
defs = $9.([]*ast.PartitionDefinition)
}
$$ = &ast.PartitionOptions{
Tp: model.PartitionTypeRange,
Expand All @@ -1821,6 +1825,18 @@ PartitionOpt:
}
}

SubPartitionOpt:
{}
| "SUBPARTITION" "BY" "HASH" '(' Expression ')' SubPartitionNumOpt
{}
| "SUBPARTITION" "BY" "KEY" '(' ColumnNameList ')' SubPartitionNumOpt
{}

SubPartitionNumOpt:
{}
| "SUBPARTITIONS" NUM
{}

PartitionNumOpt:
{}
| "PARTITIONS" NUM
Expand Down Expand Up @@ -2780,8 +2796,8 @@ UnReservedKeyword:
| "COLUMNS" | "COMMIT" | "COMPACT" | "COMPRESSED" | "CONSISTENT" | "DATA" | "DATE" %prec lowerThanStringLitToken| "DATETIME" | "DAY" | "DEALLOCATE" | "DO" | "DUPLICATE"
| "DYNAMIC"| "END" | "ENGINE" | "ENGINES" | "ENUM" | "ERRORS" | "ESCAPE" | "EXECUTE" | "FIELDS" | "FIRST" | "FIXED" | "FLUSH" | "FORMAT" | "FULL" |"GLOBAL"
| "HASH" | "HOUR" | "LESS" | "LOCAL" | "NAMES" | "OFFSET" | "PASSWORD" %prec lowerThanEq | "PREPARE" | "QUICK" | "REDUNDANT"
| "ROLLBACK" | "SESSION" | "SIGNED" | "SNAPSHOT" | "START" | "STATUS" | "TABLES" | "TABLESPACE" | "TEXT" | "THAN" | "TIME" %prec lowerThanStringLitToken | "TIMESTAMP" %prec lowerThanStringLitToken
| "TRACE" | "TRANSACTION" | "TRUNCATE" | "UNKNOWN" | "VALUE" | "WARNINGS" | "YEAR" | "MODE" | "WEEK" | "ANY" | "SOME" | "USER" | "IDENTIFIED"
| "ROLLBACK" | "SESSION" | "SIGNED" | "SNAPSHOT" | "START" | "STATUS" | "SUBPARTITIONS" | "SUBPARTITION" | "TABLES" | "TABLESPACE" | "TEXT" | "THAN" | "TIME" %prec lowerThanStringLitToken
| "TIMESTAMP" %prec lowerThanStringLitToken | "TRACE" | "TRANSACTION" | "TRUNCATE" | "UNKNOWN" | "VALUE" | "WARNINGS" | "YEAR" | "MODE" | "WEEK" | "ANY" | "SOME" | "USER" | "IDENTIFIED"
| "COLLATION" | "COMMENT" | "AVG_ROW_LENGTH" | "CONNECTION" | "CHECKSUM" | "COMPRESSION" | "KEY_BLOCK_SIZE" | "MASTER" | "MAX_ROWS"
| "MIN_ROWS" | "NATIONAL" | "ROW" | "ROW_FORMAT" | "QUARTER" | "GRANTS" | "TRIGGERS" | "DELAY_KEY_WRITE" | "ISOLATION" | "JSON"
| "REPEATABLE" | "COMMITTED" | "UNCOMMITTED" | "ONLY" | "SERIALIZABLE" | "LEVEL" | "VARIABLES" | "SQL_CACHE" | "INDEXES" | "PROCESSLIST"
Expand Down
10 changes: 9 additions & 1 deletion parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *testParserSuite) TestSimple(c *C) {
"date", "datediff", "datetime", "deallocate", "do", "from_days", "end", "engine", "engines", "execute", "first", "full",
"local", "names", "offset", "password", "prepare", "quick", "rollback", "session", "signed",
"start", "global", "tables", "tablespace", "text", "time", "timestamp", "tidb", "transaction", "truncate", "unknown",
"value", "warnings", "year", "now", "substr", "substring", "mode", "any", "some", "user", "identified",
"value", "warnings", "year", "now", "substr", "subpartition", "subpartitions", "substring", "mode", "any", "some", "user", "identified",
"collation", "comment", "avg_row_length", "checksum", "compression", "connection", "key_block_size",
"max_rows", "min_rows", "national", "row", "quarter", "escape", "grants", "status", "fields", "triggers",
"delay_key_write", "isolation", "partitions", "repeatable", "committed", "uncommitted", "only", "serializable", "level",
Expand Down Expand Up @@ -2390,6 +2390,14 @@ func (s *testParserSuite) TestTablePartition(c *C) {
{`create table t1 (a int) partition by range (a)
(PARTITION p0 VALUES LESS THAN (63340531200) COMMENT 'xxx' ENGINE = MyISAM ,
PARTITION p1 VALUES LESS THAN (63342604800) ENGINE = MyISAM)`, true},
{`create table t (id int)
partition by range (id)
subpartition by key (id) subpartitions 2
(partition p0 values less than (42))`, true},
{`create table t (id int)
partition by range (id)
subpartition by hash (id)
(partition p0 values less than (42))`, true},
}
s.RunTest(c, table)

Expand Down

0 comments on commit ad05169

Please sign in to comment.