Commit 6bb0d54e authored by Tom Lane's avatar Tom Lane

Fix a couple of small errors in trigger-list management, as per recent

discussion.
parent 2750b11e
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.169 2004/09/06 23:32:54 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.170 2004/09/07 21:48:30 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2006,13 +2006,13 @@ deferredTriggerInvokeEvents(bool immediate_only) ...@@ -2006,13 +2006,13 @@ deferredTriggerInvokeEvents(bool immediate_only)
int i; int i;
/* /*
* Skip executing cancelled events, and events done by * Skip executing cancelled events, and events already done,
* transactions that are not aborted. * unless they were done by a subtransaction that later aborted.
*/ */
if (!(event->dte_event & TRIGGER_DEFERRED_CANCELED) || if (!(event->dte_event & TRIGGER_DEFERRED_CANCELED) &&
(event->dte_event & TRIGGER_DEFERRED_DONE && !(event->dte_event & TRIGGER_DEFERRED_DONE &&
TransactionIdIsValid(event->dte_done_xid) && TransactionIdIsValid(event->dte_done_xid) &&
!TransactionIdDidAbort(event->dte_done_xid))) !TransactionIdDidAbort(event->dte_done_xid)))
{ {
MemoryContextReset(per_tuple_context); MemoryContextReset(per_tuple_context);
...@@ -2091,7 +2091,7 @@ deferredTriggerInvokeEvents(bool immediate_only) ...@@ -2091,7 +2091,7 @@ deferredTriggerInvokeEvents(bool immediate_only)
*/ */
next_event = event->dte_next; next_event = event->dte_next;
if (still_deferred_ones) if (still_deferred_ones || !immediate_only)
{ {
/* Not done, keep in list */ /* Not done, keep in list */
prev_event = event; prev_event = event;
...@@ -2103,7 +2103,7 @@ deferredTriggerInvokeEvents(bool immediate_only) ...@@ -2103,7 +2103,7 @@ deferredTriggerInvokeEvents(bool immediate_only)
* inside a subtransaction because it could abort later on. We * inside a subtransaction because it could abort later on. We
* will want to check the item again if it does. * will want to check the item again if it does.
*/ */
if (immediate_only && !IsSubTransaction()) if (!IsSubTransaction())
{ {
/* delink it from list and free it */ /* delink it from list and free it */
if (prev_event) if (prev_event)
...@@ -2115,10 +2115,11 @@ deferredTriggerInvokeEvents(bool immediate_only) ...@@ -2115,10 +2115,11 @@ deferredTriggerInvokeEvents(bool immediate_only)
else else
{ {
/* /*
* Mark the event done. * Mark the event-as-a-whole done, but keep it in the list.
*/ */
event->dte_event |= TRIGGER_DEFERRED_DONE; event->dte_event |= TRIGGER_DEFERRED_DONE;
event->dte_done_xid = GetCurrentTransactionId(); event->dte_done_xid = GetCurrentTransactionId();
prev_event = event;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment