Fix crash caused by deleting non-existing edge in DETACH DELETE (#1355)

This commit is contained in:
DavIvek 2023-10-23 08:36:28 +02:00 committed by GitHub
parent af56ab6ea8
commit 3ff2c72db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -354,6 +354,9 @@ EdgeInfoForDeletion Storage::Accessor::PrepareDeletableEdges(const std::unordere
// also add edges which we want to delete from the query // also add edges which we want to delete from the query
for (const auto &edge_accessor : edges) { for (const auto &edge_accessor : edges) {
if (edge_accessor->from_vertex_->deleted || edge_accessor->to_vertex_->deleted) {
continue;
}
partial_src_vertices.insert(edge_accessor->from_vertex_); partial_src_vertices.insert(edge_accessor->from_vertex_);
partial_dest_vertices.insert(edge_accessor->to_vertex_); partial_dest_vertices.insert(edge_accessor->to_vertex_);

View File

@ -209,3 +209,13 @@ Feature: Delete
MATCH (n) DETACH DELETE n SET n.prop = 1 WITH n RETURN n MATCH (n) DETACH DELETE n SET n.prop = 1 WITH n RETURN n
""" """
Then an error should be raised Then an error should be raised
Scenario: Delete a relationship that is already deleted in a previous DETACH DELETE clause
Given an empty graph
When executing query:
"""
CREATE (n0)<-[r0:T]-(n1) DETACH DELETE n0 DETACH DELETE r0 RETURN n1;
"""
Then the result should be:
| n1 |
| () |