static HTSV_Result heap_prune_satisfies_vacuum(PruneState *prstate,
HeapTuple tup,
Buffer buffer);
-static int heap_prune_chain(Buffer buffer,
- OffsetNumber rootoffnum,
- int8 *htsv,
- PruneState *prstate);
+static int heap_prune_chain(Page page, BlockNumber blockno, OffsetNumber maxoff,
+ OffsetNumber rootoffnum, int8 *htsv, PruneState *prstate);
static void heap_prune_record_prunable(PruneState *prstate, TransactionId xid);
static void heap_prune_record_redirect(PruneState *prstate,
OffsetNumber offnum, OffsetNumber rdoffnum);
*/
if (PageIsFull(page) || PageGetHeapFreeSpace(page) < minfree)
{
+ OffsetNumber dummy_off_loc;
PruneResult presult;
/*
* that during on-access pruning with the current implementation.
*/
heap_page_prune(relation, buffer, vistest, false,
- &presult, PRUNE_ON_ACCESS, NULL);
+ &presult, PRUNE_ON_ACCESS, &dummy_off_loc);
/*
* Report the number of tuples reclaimed to pgstats. This is
* Set the offset number so that we can display it along with any
* error that occurred while processing this tuple.
*/
- if (off_loc)
- *off_loc = offnum;
+ *off_loc = offnum;
presult->htsv[offnum] = heap_prune_satisfies_vacuum(&prstate, &tup,
buffer);
continue;
/* see preceding loop */
- if (off_loc)
- *off_loc = offnum;
+ *off_loc = offnum;
/* Nothing to do if slot is empty */
itemid = PageGetItemId(page, offnum);
continue;
/* Process this item or chain of items */
- presult->ndeleted += heap_prune_chain(buffer, offnum,
+ presult->ndeleted += heap_prune_chain(page, blockno, maxoff, offnum,
presult->htsv, &prstate);
}
/* Clear the offset information once we have processed the given page. */
- if (off_loc)
- *off_loc = InvalidOffsetNumber;
+ *off_loc = InvalidOffsetNumber;
/* Any error while applying the changes is critical */
START_CRIT_SECTION();
* Returns the number of tuples (to be) deleted from the page.
*/
static int
-heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum,
- int8 *htsv, PruneState *prstate)
+heap_prune_chain(Page page, BlockNumber blockno, OffsetNumber maxoff,
+ OffsetNumber rootoffnum, int8 *htsv, PruneState *prstate)
{
int ndeleted = 0;
- Page dp = (Page) BufferGetPage(buffer);
TransactionId priorXmax = InvalidTransactionId;
ItemId rootlp;
HeapTupleHeader htup;
OffsetNumber latestdead = InvalidOffsetNumber,
- maxoff = PageGetMaxOffsetNumber(dp),
offnum;
OffsetNumber chainitems[MaxHeapTuplesPerPage];
int nchain = 0,
i;
- rootlp = PageGetItemId(dp, rootoffnum);
+ rootlp = PageGetItemId(page, rootoffnum);
/*
* If it's a heap-only tuple, then it is not the start of a HOT chain.
if (ItemIdIsNormal(rootlp))
{
Assert(htsv[rootoffnum] != -1);
- htup = (HeapTupleHeader) PageGetItem(dp, rootlp);
+ htup = (HeapTupleHeader) PageGetItem(page, rootlp);
if (HeapTupleHeaderIsHeapOnly(htup))
{
if (prstate->marked[offnum])
break;
- lp = PageGetItemId(dp, offnum);
+ lp = PageGetItemId(page, offnum);
/* Unused item obviously isn't part of the chain */
if (!ItemIdIsUsed(lp))
}
Assert(ItemIdIsNormal(lp));
- htup = (HeapTupleHeader) PageGetItem(dp, lp);
+ htup = (HeapTupleHeader) PageGetItem(page, lp);
/*
* Check the tuple XMIN against prior XMAX, if any
/*
* Advance to next chain member.
*/
- Assert(ItemPointerGetBlockNumber(&htup->t_ctid) ==
- BufferGetBlockNumber(buffer));
+ Assert(ItemPointerGetBlockNumber(&htup->t_ctid) == blockno);
offnum = ItemPointerGetOffsetNumber(&htup->t_ctid);
priorXmax = HeapTupleHeaderGetUpdateXid(htup);
}