Skip to content

Commit

Permalink
Add VSchema DDL support for dropping sequence and auto increment (#13882
Browse files Browse the repository at this point in the history
)

Co-authored-by: Florent Poinsard <[email protected]>
  • Loading branch information
davidpiegza and frouioui authored Sep 21, 2023
1 parent 90b76ff commit 6397944
Show file tree
Hide file tree
Showing 8 changed files with 8,028 additions and 7,823 deletions.
4 changes: 4 additions & 0 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,12 @@ func (node *AlterVschema) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "alter vschema on %v drop vindex %v", node.Table, node.VindexSpec.Name)
case AddSequenceDDLAction:
buf.astPrintf(node, "alter vschema add sequence %v", node.Table)
case DropSequenceDDLAction:
buf.astPrintf(node, "alter vschema drop sequence %v", node.Table)
case AddAutoIncDDLAction:
buf.astPrintf(node, "alter vschema on %v add auto_increment %v", node.Table, node.AutoIncSpec)
case DropAutoIncDDLAction:
buf.astPrintf(node, "alter vschema on %v drop auto_increment %v", node.Table, node.AutoIncSpec)
default:
buf.astPrintf(node, "%s table %v", node.Action.ToString(), node.Table)
}
Expand Down
8 changes: 8 additions & 0 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,12 @@ func (action DDLAction) ToString() string {
return DropColVindexStr
case AddSequenceDDLAction:
return AddSequenceStr
case DropSequenceDDLAction:
return DropSequenceStr
case AddAutoIncDDLAction:
return AddAutoIncStr
case DropAutoIncDDLAction:
return DropAutoIncStr
default:
return "Unknown DDL Action"
}
Expand Down
4 changes: 4 additions & 0 deletions go/vt/sqlparser/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const (
AddColVindexStr = "on table add vindex"
DropColVindexStr = "on table drop vindex"
AddSequenceStr = "add sequence"
DropSequenceStr = "drop sequence"
AddAutoIncStr = "add auto_increment"
DropAutoIncStr = "drop auto_increment"

// ALTER TABLE ALGORITHM string.
DefaultStr = "default"
Expand Down Expand Up @@ -489,7 +491,9 @@ const (
AddColVindexDDLAction
DropColVindexDDLAction
AddSequenceDDLAction
DropSequenceDDLAction
AddAutoIncDDLAction
DropAutoIncDDLAction
RevertDDLAction
)

Expand Down
Loading

0 comments on commit 6397944

Please sign in to comment.