Skip to content

Commit

Permalink
Fixed #6838: Deleting multiple rows from a view with triggers may cau…
Browse files Browse the repository at this point in the history
…se triggers to fire just once
  • Loading branch information
dyemanov committed Jun 2, 2021
1 parent f4f112a commit 0c797c6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dsql/StmtNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2692,8 +2692,14 @@ const StmtNode* EraseNode::erase(thread_db* tdbb, jrd_req* request, WhichTrigger
// This is required for cascading referential integrity, which can be implemented as
// post_erase triggers.

if (!relation->rel_file && !relation->rel_view_rse && !relation->isVirtual())
IDX_erase(tdbb, rpb, transaction);
if (!relation->rel_view_rse)
{
if (!relation->rel_file && !relation->isVirtual())
IDX_erase(tdbb, rpb, transaction);

// Mark this rpb as already deleted to skip the subsequent attempts
rpb->rpb_runtime_flags |= RPB_just_deleted;
}

if (!relation->rel_view_rse || (whichTrig == ALL_TRIGS || whichTrig == POST_TRIG))
{
Expand All @@ -2702,7 +2708,6 @@ const StmtNode* EraseNode::erase(thread_db* tdbb, jrd_req* request, WhichTrigger
}

rpb->rpb_number.setValid(false);
rpb->rpb_runtime_flags |= RPB_just_deleted;

return parentStmt;
}
Expand Down

0 comments on commit 0c797c6

Please sign in to comment.