aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-31 03:34:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-31 03:34:27 +0000
commite86237ff31c1cb52591065c3d88bb09923b7f459 (patch)
treef9d464cc8f0447a81c543989a9bb69e4223e64a6
parent3405f2b92532cb9559aed1316b3df2262aaadaef (diff)
downloadpostgresql-e86237ff31c1cb52591065c3d88bb09923b7f459.tar.gz
postgresql-e86237ff31c1cb52591065c3d88bb09923b7f459.zip
Fix my brain fade in TRUNCATE triggers patch: can't release relcache refcounts
while EState still contains pointers to those relations. Exposed by the CLOBBER_CACHE_ALWAYS tests that buildfarm member jaguar is running (I knew those cycles would pay off...)
-rw-r--r--src/backend/commands/tablecmds.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index e97a4fc13aa..b507f17b7b6 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.249 2008/03/28 00:21:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.250 2008/03/31 03:34:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -662,8 +662,6 @@ ExecuteTruncate(TruncateStmt *stmt)
heap_relid = RelationGetRelid(rel);
toast_relid = rel->rd_rel->reltoastrelid;
- heap_close(rel, NoLock);
-
/*
* The same for the toast table, if any.
*/
@@ -696,6 +694,14 @@ ExecuteTruncate(TruncateStmt *stmt)
/* We can clean up the EState now */
FreeExecutorState(estate);
+
+ /* And close the rels (can't do this while EState still holds refs) */
+ foreach(cell, rels)
+ {
+ Relation rel = (Relation) lfirst(cell);
+
+ heap_close(rel, NoLock);
+ }
}
/*