From 55c0d45abe6467c02084c2192bca117eda6ce1e7 Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Fri, 16 May 2025 22:01:18 +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 2f161dadb7e..cea86a48888 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 59e2e71a3c5..91e50d4b867 100644 --- a/src/backend/access/gist/gistbuild.c +++ b/src/backend/access/gist/gistbuild.c @@ -290,7 +290,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); @@ -324,7 +324,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 @@ -336,7 +336,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 */ @@ -455,18 +455,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(pagestate->page, GistBuildLSN); PageSetChecksumInplace(pagestate->page, GIST_ROOT_BLKNO); smgrwrite(RelationGetSmgr(state->indexrel), MAIN_FORKNUM, GIST_ROOT_BLKNO, pagestate->page, 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, pagestate->page, true); } - smgr_end_unlogged_build(state->indexrel->rd_smgr); + smgr_end_unlogged_build(RelationGetSmgr(state->indexrel)); pfree(pagestate->page); pfree(pagestate); @@ -583,7 +583,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++) { @@ -602,13 +602,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 2c9e1c0d50d..d2ce85d07d0 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;