diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8e854279d2a..d6d0de1b01b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1591,19 +1591,22 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged, heap_create_init_fork(rel); heap_relid = RelationGetRelid(rel); - toast_relid = rel->rd_rel->reltoastrelid; /* * The same for the toast table, if any. */ + toast_relid = rel->rd_rel->reltoastrelid; if (OidIsValid(toast_relid)) { - rel = relation_open(toast_relid, AccessExclusiveLock); - RelationSetNewRelfilenode(rel, rel->rd_rel->relpersistence, + Relation toastrel = relation_open(toast_relid, + AccessExclusiveLock); + + RelationSetNewRelfilenode(toastrel, + toastrel->rd_rel->relpersistence, RecentXmin, minmulti); - if (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED) - heap_create_init_fork(rel); - heap_close(rel, NoLock); + if (toastrel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED) + heap_create_init_fork(toastrel); + heap_close(toastrel, NoLock); } /* |