Skip to content
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
33 changes: 33 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,21 @@ type (
// Rollback represents a Rollback statement.
Rollback struct{}

// SRollback represents a rollback to savepoint statement.
SRollback struct {
Name ColIdent
}

// Savepoint represents a savepoint statement.
Savepoint struct {
Name ColIdent
}

// Release represents a release savepoint statement.
Release struct {
Name ColIdent
}

// Explain represents an EXPLAIN statement
Explain struct {
Type string
Expand Down Expand Up @@ -266,6 +281,9 @@ func (*Use) iStatement() {}
func (*Begin) iStatement() {}
func (*Commit) iStatement() {}
func (*Rollback) iStatement() {}
func (*SRollback) iStatement() {}
func (*Savepoint) iStatement() {}
func (*Release) iStatement() {}
func (*Explain) iStatement() {}
func (*OtherRead) iStatement() {}
func (*OtherAdmin) iStatement() {}
Expand Down Expand Up @@ -1316,6 +1334,21 @@ func (node *Rollback) Format(buf *TrackedBuffer) {
buf.WriteString("rollback")
}

// Format formats the node.
func (node *SRollback) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "rollback to %v", node.Name)
}

// Format formats the node.
func (node *Savepoint) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "savepoint %v", node.Name)
}

// Format formats the node.
func (node *Release) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "release savepoint %v", node.Name)
}

// Format formats the node.
func (node *Explain) Format(buf *TrackedBuffer) {
format := ""
Expand Down
21 changes: 21 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,27 @@ var (
}, {
input: "do funcCall(), 2 = 1, 3 + 1",
output: "otheradmin",
}, {
input: "savepoint a",
}, {
input: "savepoint `@@@;a`",
}, {
input: "rollback to a",
}, {
input: "rollback to `@@@;a`",
}, {
input: "rollback work to a",
output: "rollback to a",
}, {
input: "rollback to savepoint a",
output: "rollback to a",
}, {
input: "rollback work to savepoint a",
output: "rollback to a",
}, {
input: "release savepoint a",
}, {
input: "release savepoint `@@@;a`",
}}
)

Expand Down
21 changes: 21 additions & 0 deletions go/vt/sqlparser/rewriter.go

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

Loading