Re: "invalid memory alloc request size " in deferred trigger causes transaction to fail, but the backend keeps running - Mailing list pgsql-bugs

From Tom Lane
Subject Re: "invalid memory alloc request size " in deferred trigger causes transaction to fail, but the backend keeps running
Date
Msg-id 4896.1102357355@sss.pgh.pa.us
Whole thread Raw
In response to Re: "invalid memory alloc request size " in deferred trigger causes transaction to fail, but the backend keeps running  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
Responses Re: "invalid memory alloc request size " in deferred trigger causes transaction to fail, but the backend keeps running  (Frank van Vugt <ftm.van.vugt@foxi.nl>)
List pgsql-bugs
Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> Looking forward to your assesment.

Looks like the problem is associated with DEFERRED AFTER triggers: we
don't normally set a snapshot for TransactionStmt commands, including
COMMIT, but there needs to be a snapshot set when running trigger
functions.  The attached patch fixes the test case you sent; can you
try it against your other problem?

            regards, tom lane

*** src/backend/commands/trigger.c.orig    Sun Nov 14 14:37:05 2004
--- src/backend/commands/trigger.c    Mon Dec  6 13:20:43 2004
***************
*** 2365,2370 ****
--- 2365,2378 ----
      Assert(afterTriggers->query_depth == -1);

      /*
+      * If there are any triggers to fire, make sure we have set a snapshot
+      * for them to use.  (Since PortalRunUtility doesn't set a snap for
+      * COMMIT, we can't assume ActiveSnapshot is valid on entry.)
+      */
+     if (afterTriggers->events.head != NULL)
+         ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
+
+     /*
       * Run all the remaining triggers.  Loop until they are all gone,
       * just in case some trigger queues more for us to do.
       */

pgsql-bugs by date:

Previous
From: "Ed L."
Date:
Subject: Re: serial drop error
Next
From: Tom Lane
Date:
Subject: Re: serial drop error