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

Commitc47a240

Browse files
committed
Fix checksum calculation in the new sorting GiST build.
Since we're bypassing the buffer manager, we need to callPageSetChecksumInplace() directly. As reported by Justin Pryzby.In the passing, add RelationOpenSmgr() calls before all smgrwrite() andsmgrextend() calls. Tom added one before the first smgrextend() call incommitc2bb287, which seems to be enough, but let's play it safe anddo it before each one. That's how it's done in the similar code innbtsort.c, too.Discussion:https://www.postgresql.org/message-id/20200920224446.GF30557@telsasoft.com
1 parentc2bb287 commitc47a240

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎src/backend/access/gist/gistbuild.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,9 @@ gist_indexsortbuild(GISTBuildState *state)
449449
gist_indexsortbuild_flush_ready_pages(state);
450450

451451
/* Write out the root */
452+
RelationOpenSmgr(state->indexrel);
452453
PageSetLSN(pagestate->page,GistBuildLSN);
454+
PageSetChecksumInplace(pagestate->page,GIST_ROOT_BLKNO);
453455
smgrwrite(state->indexrel->rd_smgr,MAIN_FORKNUM,GIST_ROOT_BLKNO,
454456
pagestate->page, true);
455457
if (RelationNeedsWAL(state->indexrel))
@@ -546,21 +548,22 @@ gist_indexsortbuild_flush_ready_pages(GISTBuildState *state)
546548
if (state->ready_num_pages==0)
547549
return;
548550

551+
RelationOpenSmgr(state->indexrel);
552+
549553
for (inti=0;i<state->ready_num_pages;i++)
550554
{
551555
Pagepage=state->ready_pages[i];
556+
BlockNumberblkno=state->ready_blknos[i];
552557

553558
/* Currently, the blocks must be buffered in order. */
554-
if (state->ready_blknos[i]!=state->pages_written)
559+
if (blkno!=state->pages_written)
555560
elog(ERROR,"unexpected block number to flush GiST sorting build");
556561

557562
PageSetLSN(page,GistBuildLSN);
563+
PageSetChecksumInplace(page,blkno);
564+
smgrextend(state->indexrel->rd_smgr,MAIN_FORKNUM,blkno,page, true);
558565

559-
smgrextend(state->indexrel->rd_smgr,
560-
MAIN_FORKNUM,
561-
state->pages_written++,
562-
page,
563-
true);
566+
state->pages_written++;
564567
}
565568

566569
if (RelationNeedsWAL(state->indexrel))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp