Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8be543

Browse files
committed
Avoid creating init fork for unlogged indexes when it already exists.
Report by Greg Sabino Mullane, diagnosis and preliminary patch byAndres Freund, corrections by me.
1 parent3980f7f commitb8be543

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎src/backend/catalog/index.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,9 +1741,14 @@ index_build(Relation heapRelation,
17411741
Assert(PointerIsValid(stats));
17421742

17431743
/*
1744-
* If this is an unlogged index, we need to write out an init fork for it.
1745-
*/
1746-
if (heapRelation->rd_rel->relpersistence==RELPERSISTENCE_UNLOGGED)
1744+
* If this is an unlogged index, we may need to write out an init fork for
1745+
* it -- but we must first check whether one already exists. If, for
1746+
* example, an unlogged relation is truncated in the transaction that
1747+
* created it, or truncated twice in a subsequent transaction, the
1748+
* relfilenode won't change, and nothing needs to be done here.
1749+
*/
1750+
if (heapRelation->rd_rel->relpersistence==RELPERSISTENCE_UNLOGGED
1751+
&& !smgrexists(indexRelation->rd_smgr,INIT_FORKNUM))
17471752
{
17481753
RegProcedureambuildempty=indexRelation->rd_am->ambuildempty;
17491754

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp