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

Add optional ignore to delete statement #6802

Merged
merged 1 commit into from
Sep 30, 2020
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
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
Comment on lines +151 to 152
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in declaration also we can move Ignore after 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