Skip to content

Commit e86237f

Browse files
committed
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...)
1 parent 3405f2b commit e86237f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/backend/commands/tablecmds.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.249 2008/03/28 00:21:55 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.250 2008/03/31 03:34:27 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -662,8 +662,6 @@ ExecuteTruncate(TruncateStmt *stmt)
662662
heap_relid = RelationGetRelid(rel);
663663
toast_relid = rel->rd_rel->reltoastrelid;
664664

665-
heap_close(rel, NoLock);
666-
667665
/*
668666
* The same for the toast table, if any.
669667
*/
@@ -696,6 +694,14 @@ ExecuteTruncate(TruncateStmt *stmt)
696694

697695
/* We can clean up the EState now */
698696
FreeExecutorState(estate);
697+
698+
/* And close the rels (can't do this while EState still holds refs) */
699+
foreach(cell, rels)
700+
{
701+
Relation rel = (Relation) lfirst(cell);
702+
703+
heap_close(rel, NoLock);
704+
}
699705
}
700706

701707
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy