Skip to content

Commit

Permalink
Merge pull request #6802 from saifalharthi/sa-delete-ignore
Browse files Browse the repository at this point in the history
Add optional ignore to delete statement
  • Loading branch information
systay authored Sep 30, 2020
2 parents ac92be2 + 3b36ccb commit 7f22f51
Show file tree
Hide file tree
Showing 4 changed files with 1,217 additions and 1,263 deletions.
4 changes: 4 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ type (
// Delete represents a DELETE statement.
// If you add fields here, consider adding them to calls to validateUnshardedRoute.
Delete struct {
Ignore Ignore
Comments Comments
Targets TableNames
TableExprs TableExprs
Expand Down Expand Up @@ -1041,6 +1042,9 @@ func (node *Update) Format(buf *TrackedBuffer) {
// Format formats the node.
func (node *Delete) Format(buf *TrackedBuffer) {
buf.astPrintf(node, "delete %v", node.Comments)
if node.Ignore {
buf.WriteString("ignore ")
}
if node.Targets != nil {
buf.astPrintf(node, "%v ", node.Targets)
}
Expand Down
6 changes: 6 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,12 @@ var (
input: "delete a from a join b on a.id = b.id where b.name = 'test'",
}, {
input: "delete a, b from a, b where a.id = b.id and b.name = 'test'",
}, {
input: "delete /* simple */ ignore from a",
}, {
input: "delete ignore from a",
}, {
input: "delete /* limit */ ignore from a",
}, {
input: "delete from a1, a2 using t1 as a1 inner join t2 as a2 where a1.id=a2.id",
output: "delete a1, a2 from t1 as a1 join t2 as a2 where a1.id = a2.id",
Expand Down
Loading

0 comments on commit 7f22f51

Please sign in to comment.