@@ -57,10 +57,8 @@ typedef struct
57
57
static HTSV_Result heap_prune_satisfies_vacuum (PruneState * prstate ,
58
58
HeapTuple tup ,
59
59
Buffer buffer );
60
- static int heap_prune_chain (Buffer buffer ,
61
- OffsetNumber rootoffnum ,
62
- int8 * htsv ,
63
- PruneState * prstate );
60
+ static int heap_prune_chain (Page page , BlockNumber blockno , OffsetNumber maxoff ,
61
+ OffsetNumber rootoffnum , int8 * htsv , PruneState * prstate );
64
62
static void heap_prune_record_prunable (PruneState * prstate , TransactionId xid );
65
63
static void heap_prune_record_redirect (PruneState * prstate ,
66
64
OffsetNumber offnum , OffsetNumber rdoffnum );
@@ -145,6 +143,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
145
143
*/
146
144
if (PageIsFull (page ) || PageGetHeapFreeSpace (page ) < minfree )
147
145
{
146
+ OffsetNumber dummy_off_loc ;
148
147
PruneResult presult ;
149
148
150
149
/*
@@ -153,7 +152,7 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
153
152
* that during on-access pruning with the current implementation.
154
153
*/
155
154
heap_page_prune (relation , buffer , vistest , false,
156
- & presult , PRUNE_ON_ACCESS , NULL );
155
+ & presult , PRUNE_ON_ACCESS , & dummy_off_loc );
157
156
158
157
/*
159
158
* Report the number of tuples reclaimed to pgstats. This is
@@ -296,8 +295,7 @@ heap_page_prune(Relation relation, Buffer buffer,
296
295
* Set the offset number so that we can display it along with any
297
296
* error that occurred while processing this tuple.
298
297
*/
299
- if (off_loc )
300
- * off_loc = offnum ;
298
+ * off_loc = offnum ;
301
299
302
300
presult -> htsv [offnum ] = heap_prune_satisfies_vacuum (& prstate , & tup ,
303
301
buffer );
@@ -315,22 +313,20 @@ heap_page_prune(Relation relation, Buffer buffer,
315
313
continue ;
316
314
317
315
/* see preceding loop */
318
- if (off_loc )
319
- * off_loc = offnum ;
316
+ * off_loc = offnum ;
320
317
321
318
/* Nothing to do if slot is empty */
322
319
itemid = PageGetItemId (page , offnum );
323
320
if (!ItemIdIsUsed (itemid ))
324
321
continue ;
325
322
326
323
/* Process this item or chain of items */
327
- presult -> ndeleted += heap_prune_chain (buffer , offnum ,
324
+ presult -> ndeleted += heap_prune_chain (page , blockno , maxoff , offnum ,
328
325
presult -> htsv , & prstate );
329
326
}
330
327
331
328
/* Clear the offset information once we have processed the given page. */
332
- if (off_loc )
333
- * off_loc = InvalidOffsetNumber ;
329
+ * off_loc = InvalidOffsetNumber ;
334
330
335
331
/* Any error while applying the changes is critical */
336
332
START_CRIT_SECTION ();
@@ -452,30 +448,28 @@ heap_prune_satisfies_vacuum(PruneState *prstate, HeapTuple tup, Buffer buffer)
452
448
* Returns the number of tuples (to be) deleted from the page.
453
449
*/
454
450
static int
455
- heap_prune_chain (Buffer buffer , OffsetNumber rootoffnum ,
456
- int8 * htsv , PruneState * prstate )
451
+ heap_prune_chain (Page page , BlockNumber blockno , OffsetNumber maxoff ,
452
+ OffsetNumber rootoffnum , int8 * htsv , PruneState * prstate )
457
453
{
458
454
int ndeleted = 0 ;
459
- Page dp = (Page ) BufferGetPage (buffer );
460
455
TransactionId priorXmax = InvalidTransactionId ;
461
456
ItemId rootlp ;
462
457
HeapTupleHeader htup ;
463
458
OffsetNumber latestdead = InvalidOffsetNumber ,
464
- maxoff = PageGetMaxOffsetNumber (dp ),
465
459
offnum ;
466
460
OffsetNumber chainitems [MaxHeapTuplesPerPage ];
467
461
int nchain = 0 ,
468
462
i ;
469
463
470
- rootlp = PageGetItemId (dp , rootoffnum );
464
+ rootlp = PageGetItemId (page , rootoffnum );
471
465
472
466
/*
473
467
* If it's a heap-only tuple, then it is not the start of a HOT chain.
474
468
*/
475
469
if (ItemIdIsNormal (rootlp ))
476
470
{
477
471
Assert (htsv [rootoffnum ] != -1 );
478
- htup = (HeapTupleHeader ) PageGetItem (dp , rootlp );
472
+ htup = (HeapTupleHeader ) PageGetItem (page , rootlp );
479
473
480
474
if (HeapTupleHeaderIsHeapOnly (htup ))
481
475
{
@@ -536,7 +530,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum,
536
530
if (prstate -> marked [offnum ])
537
531
break ;
538
532
539
- lp = PageGetItemId (dp , offnum );
533
+ lp = PageGetItemId (page , offnum );
540
534
541
535
/* Unused item obviously isn't part of the chain */
542
536
if (!ItemIdIsUsed (lp ))
@@ -575,7 +569,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum,
575
569
}
576
570
577
571
Assert (ItemIdIsNormal (lp ));
578
- htup = (HeapTupleHeader ) PageGetItem (dp , lp );
572
+ htup = (HeapTupleHeader ) PageGetItem (page , lp );
579
573
580
574
/*
581
575
* Check the tuple XMIN against prior XMAX, if any
@@ -666,8 +660,7 @@ heap_prune_chain(Buffer buffer, OffsetNumber rootoffnum,
666
660
/*
667
661
* Advance to next chain member.
668
662
*/
669
- Assert (ItemPointerGetBlockNumber (& htup -> t_ctid ) ==
670
- BufferGetBlockNumber (buffer ));
663
+ Assert (ItemPointerGetBlockNumber (& htup -> t_ctid ) == blockno );
671
664
offnum = ItemPointerGetOffsetNumber (& htup -> t_ctid );
672
665
priorXmax = HeapTupleHeaderGetUpdateXid (htup );
673
666
}
0 commit comments