Commit 034fffbf authored by Tom Lane's avatar Tom Lane

Fix memory leak created by deferrable-index-constraints patches.

We need to free the OID list returned by ExecInsertIndexTuples to avoid
a query-lifespan memory leak.  When many rows require rechecking, this
can be a significant leak --- it's even more than the space used for the
queued trigger events.

Dean Rasheed
parent f13944e9
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.321 2010/01/15 09:19:01 heikki Exp $ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.322 2010/01/31 18:15:39 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2172,6 +2172,8 @@ CopyFrom(CopyState cstate) ...@@ -2172,6 +2172,8 @@ CopyFrom(CopyState cstate)
ExecARInsertTriggers(estate, resultRelInfo, tuple, ExecARInsertTriggers(estate, resultRelInfo, tuple,
recheckIndexes); recheckIndexes);
list_free(recheckIndexes);
/* /*
* We count only tuples not suppressed by a BEFORE INSERT trigger; * We count only tuples not suppressed by a BEFORE INSERT trigger;
* this is the same definition used by execMain.c for counting * this is the same definition used by execMain.c for counting
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeModifyTable.c,v 1.4 2010/01/02 16:57:44 momjian Exp $ * $PostgreSQL: pgsql/src/backend/executor/nodeModifyTable.c,v 1.5 2010/01/31 18:15:39 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -254,6 +254,8 @@ ExecInsert(TupleTableSlot *slot, ...@@ -254,6 +254,8 @@ ExecInsert(TupleTableSlot *slot,
/* AFTER ROW INSERT Triggers */ /* AFTER ROW INSERT Triggers */
ExecARInsertTriggers(estate, resultRelInfo, tuple, recheckIndexes); ExecARInsertTriggers(estate, resultRelInfo, tuple, recheckIndexes);
list_free(recheckIndexes);
/* Process RETURNING if present */ /* Process RETURNING if present */
if (resultRelInfo->ri_projectReturning) if (resultRelInfo->ri_projectReturning)
return ExecProcessReturning(resultRelInfo->ri_projectReturning, return ExecProcessReturning(resultRelInfo->ri_projectReturning,
...@@ -570,6 +572,8 @@ lreplace:; ...@@ -570,6 +572,8 @@ lreplace:;
ExecARUpdateTriggers(estate, resultRelInfo, tupleid, tuple, ExecARUpdateTriggers(estate, resultRelInfo, tupleid, tuple,
recheckIndexes); recheckIndexes);
list_free(recheckIndexes);
/* Process RETURNING if present */ /* Process RETURNING if present */
if (resultRelInfo->ri_projectReturning) if (resultRelInfo->ri_projectReturning)
return ExecProcessReturning(resultRelInfo->ri_projectReturning, return ExecProcessReturning(resultRelInfo->ri_projectReturning,
......
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