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:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user