]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Reset the per-output-tuple exprcontext each time through the main loop in
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 18 Aug 2010 21:52:32 +0000 (21:52 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 18 Aug 2010 21:52:32 +0000 (21:52 +0000)
ExecModifyTable().  This avoids memory leakage when trigger functions leave
junk behind in that context (as they more or less must).  Problem and solution
identified by Dean Rasheed.

I'm a bit concerned about the longevity of this solution --- once a plan can
have multiple ModifyTable nodes, we are very possibly going to have to do
something different.  But it should hold up for 9.0.

src/backend/executor/nodeModifyTable.c

index adfe97cefde9fad6c0b0def0fadbb4cb8eb7475f..969938130ec5bed7200f7f8c93abf0f1b85a2db1 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/executor/nodeModifyTable.c,v 1.7 2010/02/26 02:00:42 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/executor/nodeModifyTable.c,v 1.7.4.1 2010/08/18 21:52:32 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -682,6 +682,14 @@ ExecModifyTable(ModifyTableState *node)
         */
        for (;;)
        {
+               /*
+                * Reset the per-output-tuple exprcontext.  This is needed because
+                * triggers expect to use that context as workspace.  It's a bit ugly
+                * to do this below the top level of the plan, however.  We might need
+                * to rethink this later.
+                */
+               ResetPerTupleExprContext(estate);
+
                planSlot = ExecProcNode(subplanstate);
 
                if (TupIsNull(planSlot))