From de7640f55da07512834d5cc40c4b3fb376b5f04f Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Fri, 16 May 2025 22:00:50 +0300 Subject: [PATCH] Use RelationGetSmgr in calls of unlogged_build functions --- src/backend/access/gin/gininsert.c | 6 +++--- src/backend/access/gist/gistbuild.c | 18 +++++++++--------- src/backend/access/spgist/spginsert.c | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index 92057ccd5b7..f7d8b079f7d 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -335,7 +335,7 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo) elog(ERROR, "index \"%s\" already contains data", RelationGetRelationName(index)); - smgr_start_unlogged_build(index->rd_smgr); + smgr_start_unlogged_build(RelationGetSmgr(index)); initGinState(&buildstate.ginstate, index); buildstate.indtuples = 0; @@ -410,7 +410,7 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo) buildstate.buildStats.nTotalPages = RelationGetNumberOfBlocks(index); ginUpdateStats(index, &buildstate.buildStats, true); - smgr_finish_unlogged_build_phase_1(index->rd_smgr); + smgr_finish_unlogged_build_phase_1(RelationGetSmgr(index)); /* * We didn't write WAL records as we built the index, so if WAL-logging is @@ -423,7 +423,7 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo) true); } - smgr_end_unlogged_build(index->rd_smgr); + smgr_end_unlogged_build(RelationGetSmgr(index)); /* * Return statistics diff --git a/src/backend/access/gist/gistbuild.c b/src/backend/access/gist/gistbuild.c index 5269cc57fcc..db0fe085a65 100644 --- a/src/backend/access/gist/gistbuild.c +++ b/src/backend/access/gist/gistbuild.c @@ -297,7 +297,7 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo) Buffer buffer; Page page; - smgr_start_unlogged_build(index->rd_smgr); + smgr_start_unlogged_build(RelationGetSmgr(index)); /* initialize the root page */ buffer = gistNewBuffer(index); @@ -331,7 +331,7 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo) gistFreeBuildBuffers(buildstate.gfbb); } - smgr_finish_unlogged_build_phase_1(index->rd_smgr); + smgr_finish_unlogged_build_phase_1(RelationGetSmgr(index)); /* * We didn't write WAL records as we built the index, so if @@ -343,7 +343,7 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo) 0, RelationGetNumberOfBlocks(index), true); } - smgr_end_unlogged_build(index->rd_smgr); + smgr_end_unlogged_build(RelationGetSmgr(index)); } /* okay, all heap tuples are indexed */ @@ -463,18 +463,18 @@ gist_indexsortbuild(GISTBuildState *state) gist_indexsortbuild_flush_ready_pages(state); /* Write out the root */ - smgr_start_unlogged_build(state->indexrel->rd_smgr); + smgr_start_unlogged_build(RelationGetSmgr(state->indexrel)); PageSetLSN(levelstate->pages[0], GistBuildLSN); PageSetChecksumInplace(levelstate->pages[0], GIST_ROOT_BLKNO); smgrwrite(RelationGetSmgr(state->indexrel), MAIN_FORKNUM, GIST_ROOT_BLKNO, levelstate->pages[0], true); - smgr_finish_unlogged_build_phase_1(state->indexrel->rd_smgr); + smgr_finish_unlogged_build_phase_1(RelationGetSmgr(state->indexrel)); if (RelationNeedsWAL(state->indexrel)) { log_newpage(&state->indexrel->rd_node, MAIN_FORKNUM, GIST_ROOT_BLKNO, levelstate->pages[0], true); } - smgr_end_unlogged_build(state->indexrel->rd_smgr); + smgr_end_unlogged_build(RelationGetSmgr(state->indexrel)); pfree(levelstate->pages[0]); pfree(levelstate); @@ -656,7 +656,7 @@ gist_indexsortbuild_flush_ready_pages(GISTBuildState *state) if (state->ready_num_pages == 0) return; - smgr_start_unlogged_build(state->indexrel->rd_smgr); + smgr_start_unlogged_build(RelationGetSmgr(state->indexrel)); for (int i = 0; i < state->ready_num_pages; i++) { @@ -675,13 +675,13 @@ gist_indexsortbuild_flush_ready_pages(GISTBuildState *state) state->pages_written++; } - smgr_finish_unlogged_build_phase_1(state->indexrel->rd_smgr); + smgr_finish_unlogged_build_phase_1(RelationGetSmgr(state->indexrel)); if (RelationNeedsWAL(state->indexrel)) log_newpages(&state->indexrel->rd_node, MAIN_FORKNUM, state->ready_num_pages, state->ready_blknos, state->ready_pages, true); - smgr_end_unlogged_build(state->indexrel->rd_smgr); + smgr_end_unlogged_build(RelationGetSmgr(state->indexrel)); for (int i = 0; i < state->ready_num_pages; i++) pfree(state->ready_pages[i]); diff --git a/src/backend/access/spgist/spginsert.c b/src/backend/access/spgist/spginsert.c index 89cfa595742..6ef019e7b97 100644 --- a/src/backend/access/spgist/spginsert.c +++ b/src/backend/access/spgist/spginsert.c @@ -85,7 +85,7 @@ spgbuild(Relation heap, Relation index, IndexInfo *indexInfo) elog(ERROR, "index \"%s\" already contains data", RelationGetRelationName(index)); - smgr_start_unlogged_build(index->rd_smgr); + smgr_start_unlogged_build(RelationGetSmgr(index)); /* * Initialize the meta page and root pages @@ -133,7 +133,7 @@ spgbuild(Relation heap, Relation index, IndexInfo *indexInfo) SpGistUpdateMetaPage(index); - smgr_finish_unlogged_build_phase_1(index->rd_smgr); + smgr_finish_unlogged_build_phase_1(RelationGetSmgr(index)); /* * We didn't write WAL records as we built the index, so if WAL-logging is @@ -146,7 +146,7 @@ spgbuild(Relation heap, Relation index, IndexInfo *indexInfo) true); } - smgr_end_unlogged_build(index->rd_smgr); + smgr_end_unlogged_build(RelationGetSmgr(index)); result = (IndexBuildResult *) palloc0(sizeof(IndexBuildResult)); result->heap_tuples = reltuples;