1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Prevent loss of init fork when truncating an unlogged table.

Fixes bug #6635, reported by Akira Kurosawa.
This commit is contained in:
Robert Haas
2012-05-11 09:46:42 -04:00
parent b762e8f50b
commit 1331cc6c1a
3 changed files with 23 additions and 15 deletions

View File

@ -1155,6 +1155,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;
@ -1166,6 +1168,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);
}