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

parser: add 'INSTANT' alter algorithm #93

Merged
merged 10 commits into from
Feb 19, 2019
30 changes: 30 additions & 0 deletions ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,35 @@ const (
LockTypeExclusive
)

// AlterAlgorithm is the algorithm of the ddl operations.
zimulala marked this conversation as resolved.
Show resolved Hide resolved
// See https://dev.mysql.com/doc/refman/8.0/en/alter-table.html#alter-table-performance.
type AlterAlgorithm byte

// DDL alter algorithms.
// For now, TiDB only supported inplace and instance algorithms. If the user specify `copy`,
// will get an error.
const (
AlterAlgorithmDefault AlterAlgorithm = iota
AlterAlgorithmCopy
AlterAlgorithmInplace
AlterAlgorithmInstant
)

func (a AlterAlgorithm) String() string {
switch a {
case AlterAlgorithmDefault:
return "DEFAULT"
case AlterAlgorithmCopy:
return "COPY"
case AlterAlgorithmInplace:
return "INPLACE"
case AlterAlgorithmInstant:
return "INSTANT"
default:
return "DEFAULT"
}
}

// AlterTableSpec represents alter table specification.
type AlterTableSpec struct {
node
Expand All @@ -1092,6 +1121,7 @@ type AlterTableSpec struct {
OldColumnName *ColumnName
Position *ColumnPosition
LockType LockType
Algorithm AlterAlgorithm
Comment string
FromKey model.CIStr
ToKey model.CIStr
Expand Down
1 change: 1 addition & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ var tokenMap = map[string]int{
"INFILE": infile,
"INNER": inner,
"INPLACE": inplace,
"INSTANT": instant,
"INSERT": insert,
"INT": intType,
"INT1": int1Type,
Expand Down
Loading