*** a/src/backend/access/nbtree/nbtree.c
--- b/src/backend/access/nbtree/nbtree.c
***************
*** 71,78 **** static void btbuildCallback(Relation index,
  static void btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
  			 IndexBulkDeleteCallback callback, void *callback_state,
  			 BTCycleId cycleid);
! static void btvacuumpage(BTVacState *vstate, BlockNumber blkno,
! 			 BlockNumber orig_blkno);
  
  
  /*
--- 71,77 ----
  static void btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
  			 IndexBulkDeleteCallback callback, void *callback_state,
  			 BTCycleId cycleid);
! static void btvacuumpage(BTVacState *vstate, BlockNumber blkno);
  
  
  /*
***************
*** 804,810 **** btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
  		/* Iterate over pages, then loop back to recheck length */
  		for (; blkno < num_pages; blkno++)
  		{
! 			btvacuumpage(&vstate, blkno, blkno);
  		}
  	}
  
--- 803,809 ----
  		/* Iterate over pages, then loop back to recheck length */
  		for (; blkno < num_pages; blkno++)
  		{
! 			btvacuumpage(&vstate, blkno);
  		}
  	}
  
***************
*** 848,859 **** btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
   * must go back and re-examine previously-scanned pages; this routine
   * recurses when necessary to handle that case.
   *
!  * blkno is the page to process.  orig_blkno is the highest block number
!  * reached by the outer btvacuumscan loop (the same as blkno, unless we
!  * are recursing to re-examine a previous page).
   */
  static void
! btvacuumpage(BTVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
  {
  	IndexVacuumInfo *info = vstate->info;
  	IndexBulkDeleteResult *stats = vstate->stats;
--- 847,857 ----
   * must go back and re-examine previously-scanned pages; this routine
   * recurses when necessary to handle that case.
   *
!  * blkno is the page to process.
!  *
   */
  static void
! btvacuumpage(BTVacState *vstate, BlockNumber blkno)
  {
  	IndexVacuumInfo *info = vstate->info;
  	IndexBulkDeleteResult *stats = vstate->stats;
***************
*** 865,870 **** btvacuumpage(BTVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
--- 863,874 ----
  	Buffer		buf;
  	Page		page;
  	BTPageOpaque opaque;
+ 	/*
+ 	 * orig_blkno is the highest block number reached by the outer btvacuumscan
+ 	 * loop (the same as blkno, unless we are recursing to re-examine a
+ 	 * previous page).
+ 	 */
+ 	BlockNumber	orig_blkno = blkno;
  
  restart:
  	delete_now = false;
