From 32e38d4b2ef0e6e42002a15f26d1bf88bcebca80 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Sat, 6 Jan 2024 13:39:59 -0500 Subject: [PATCH v5 10/26] Pass heap_prune_chain() PruneResult output parameter Future commits will set other members of PruneResult in heap_prune_chain(), so start passing it as an output parameter now. This eliminates the output parameter htsv -- the array of HTSV_Results -- since that is a member of the PruneResult. --- src/backend/access/heap/pruneheap.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index d8be0f68bf9..94b18017aaa 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -59,8 +59,7 @@ static HTSV_Result heap_prune_satisfies_vacuum(PruneState *prstate, Buffer buffer); static int heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, - int8 *htsv, - PruneState *prstate); + PruneState *prstate, PruneResult *presult); static void heap_prune_record_prunable(PruneState *prstate, TransactionId xid); static void heap_prune_record_redirect(PruneState *prstate, OffsetNumber offnum, OffsetNumber rdoffnum); @@ -321,7 +320,7 @@ heap_page_prune(Relation relation, Buffer buffer, /* Process this item or chain of items */ presult->ndeleted += heap_prune_chain(buffer, offnum, - presult->htsv, &prstate); + &prstate, presult); } /* Clear the offset information once we have processed the given page. */ @@ -423,7 +422,7 @@ heap_prune_satisfies_vacuum(PruneState *prstate, HeapTuple tup, Buffer buffer) /* * Prune specified line pointer or a HOT chain originating at line pointer. * - * Tuple visibility information is provided in htsv. + * Tuple visibility information is provided in presult->htsv. * * If the item is an index-referenced tuple (i.e. not a heap-only tuple), * the HOT chain is pruned by removing all DEAD tuples at the start of the HOT @@ -453,7 +452,7 @@ heap_prune_satisfies_vacuum(PruneState *prstate, HeapTuple tup, Buffer buffer) */ static int heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, - int8 *htsv, PruneState *prstate) + PruneState *prstate, PruneResult *presult) { int ndeleted = 0; Page dp = (Page) BufferGetPage(buffer); @@ -474,7 +473,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, */ if (ItemIdIsNormal(rootlp)) { - Assert(htsv[rootoffnum] != -1); + Assert(presult->htsv[rootoffnum] != -1); htup = (HeapTupleHeader) PageGetItem(dp, rootlp); if (HeapTupleHeaderIsHeapOnly(htup)) @@ -497,7 +496,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, * either here or while following a chain below. Whichever path * gets there first will mark the tuple unused. */ - if (htsv[rootoffnum] == HEAPTUPLE_DEAD && + if (presult->htsv[rootoffnum] == HEAPTUPLE_DEAD && !HeapTupleHeaderIsHotUpdated(htup)) { heap_prune_record_unused(prstate, rootoffnum); @@ -594,7 +593,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum, */ tupdead = recent_dead = false; - switch (htsv_get_valid_status(htsv[offnum])) + switch (htsv_get_valid_status(presult->htsv[offnum])) { case HEAPTUPLE_DEAD: tupdead = true; -- 2.39.2