Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] *: support parsing all PARTITION BY syntax (#345) #395

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
556 changes: 505 additions & 51 deletions ast/ddl.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ast/expressions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (tc *testExpressionsSuite) TestMaxValueExprRestore(c *C) {
{"maxvalue", "MAXVALUE"},
}
extractNodeFunc := func(node Node) Node {
return node.(*AlterTableStmt).Specs[0].PartDefinitions[0].LessThan[0]
return node.(*AlterTableStmt).Specs[0].PartDefinitions[0].Clause.(*PartitionDefinitionClauseLessThan).Exprs[0]
}
RunNodeRestoreTest(c, testCases, "alter table posts add partition ( partition p1 values less than %s)", extractNodeFunc)
}
Expand Down
5 changes: 5 additions & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ var tokenMap = map[string]int{
"DELETE": deleteKwd,
"DESC": desc,
"DESCRIBE": describe,
"DIRECTORY": directory,
"DISABLE": disable,
"DISTINCT": distinct,
"DISTINCTROW": distinct,
Expand Down Expand Up @@ -289,6 +290,7 @@ var tokenMap = map[string]int{
"HASH": hash,
"HAVING": having,
"HIGH_PRIORITY": highPriority,
"HISTORY": history,
"HOUR": hour,
"HOUR_MICROSECOND": hourMicrosecond,
"HOUR_MINUTE": hourMinute,
Expand Down Expand Up @@ -338,6 +340,7 @@ var tokenMap = map[string]int{
"LIMIT": limit,
"LINES": lines,
"LINEAR": linear,
"LIST": list,
"LOAD": load,
"LOCAL": local,
"LOCALTIME": localTime,
Expand Down Expand Up @@ -380,6 +383,7 @@ var tokenMap = map[string]int{
"NO_WRITE_TO_BINLOG": noWriteToBinLog,
"NODE_ID": nodeID,
"NODE_STATE": nodeState,
"NODEGROUP": nodegroup,
"NONE": none,
"NOT": not,
"NOW": now,
Expand Down Expand Up @@ -489,6 +493,7 @@ var tokenMap = map[string]int{
"STATUS": status,
"SWAPS": swaps,
"SWITCHES": switchesSym,
"SYSTEM_TIME": systemTime,
"OPEN": open,
"STD": stddevPop,
"STDDEV": stddevPop,
Expand Down
12 changes: 9 additions & 3 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,11 @@ type PartitionType int

// Partition types.
const (
PartitionTypeRange PartitionType = 1
PartitionTypeHash PartitionType = 2
PartitionTypeList PartitionType = 3
PartitionTypeRange PartitionType = 1
PartitionTypeHash = 2
PartitionTypeList = 3
PartitionTypeKey = 4
PartitionTypeSystemTime = 5
)

func (p PartitionType) String() string {
Expand All @@ -465,6 +467,10 @@ func (p PartitionType) String() string {
return "HASH"
case PartitionTypeList:
return "LIST"
case PartitionTypeKey:
return "KEY"
case PartitionTypeSystemTime:
return "SYSTEM_TIME"
default:
return ""
}
Expand Down
5 changes: 5 additions & 0 deletions mysql/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,11 @@ const (
ErrWindowExplainJson = 3598
ErrWindowFunctionIgnoresFrame = 3599

// MariaDB errors.
ErrOnlyOneDefaultPartionAllowed = 4030
ErrWrongPartitionTypeExpectedSystemTime = 4113
ErrSystemVersioningWrongPartitions = 4128

// TiDB self-defined errors.
ErrMemExceedThreshold = 8001
ErrForUpdateCantRetry = 8002
Expand Down
5 changes: 5 additions & 0 deletions mysql/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,11 @@ var MySQLErrName = map[uint16]string{
ErrRoleNotGranted: "%s is is not granted to %s",
ErrMaxExecTimeExceeded: "Query execution was interrupted, max_execution_time exceeded.",

// MariaDB errors.
ErrOnlyOneDefaultPartionAllowed: "Only one DEFAULT partition allowed",
ErrWrongPartitionTypeExpectedSystemTime: "Wrong partitioning type, expected type: `SYSTEM_TIME`",
ErrSystemVersioningWrongPartitions: "Wrong Partitions: must have at least one HISTORY and exactly one last CURRENT",

// TiDB errors.
ErrMemExceedThreshold: "%s holds %dB memory, exceeds threshold %dB.%s",
ErrForUpdateCantRetry: "[%d] can not retry select for update statement",
Expand Down
Loading