From 2ca6bac892aa650154f591c730359a968bea726a Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 11 May 2012 09:46:42 -0400 Subject: Prevent loss of init fork when truncating an unlogged table. Fixes bug #6635, reported by Akira Kurosawa. --- src/backend/commands/tablecmds.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/backend/commands/tablecmds.c') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8f569ed0bd6..11f57b2758d 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1059,6 +1059,8 @@ ExecuteTruncate(TruncateStmt *stmt) * deletion at commit. */ RelationSetNewRelfilenode(rel, RecentXmin); + if (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED) + heap_create_init_fork(rel); heap_relid = RelationGetRelid(rel); toast_relid = rel->rd_rel->reltoastrelid; @@ -1070,6 +1072,8 @@ ExecuteTruncate(TruncateStmt *stmt) { rel = relation_open(toast_relid, AccessExclusiveLock); RelationSetNewRelfilenode(rel, RecentXmin); + if (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED) + heap_create_init_fork(rel); heap_close(rel, NoLock); } -- cgit v1.2.3