fix_deferred_trigger.diff

application/octet-stream

Filename: fix_deferred_trigger.diff
Type: application/octet-stream
Part: 0
Message: Re: Eliminating SPI / SQL from some RI triggers - take 3

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/commands/trigger.c 3 3
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 90e94fb8a5a..63355ebb02f 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -6806,10 +6806,10 @@ RegisterAfterTriggerBatchCallback(AfterTriggerBatchCallback callback,
 	 * Allocate in TopTransactionContext so the item survives for the duration
 	 * of the batch, which may span multiple trigger invocations.
 	 *
-	 * Must be called while afterTriggers is active (query_depth >= 0);
+	 * Must be called while afterTriggers is active (MyTriggerDepth > 0);
 	 * callbacks registered outside a trigger-firing context would never fire.
 	 */
-	Assert(afterTriggers.query_depth >= 0);
+	Assert(MyTriggerDepth > 0);
 	oldcxt = MemoryContextSwitchTo(TopTransactionContext);
 	item = palloc(sizeof(AfterTriggerCallbackItem));
 	item->callback = callback;
@@ -6858,5 +6858,5 @@ FireAfterTriggerBatchCallbacks(void)
 bool
 AfterTriggerIsActive(void)
 {
-	return afterTriggers.query_depth >= 0;
+	return MyTriggerDepth > 0;
 }