@@ -1580,7 +1580,7 @@ _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum,
15801580so -> currPos .currPage );
15811581}
15821582
1583- /* initialize remaining currPos fields (before moreLeft/moreright ) */
1583+ /* initialize remaining currPos fields (before moreLeft/moreRight ) */
15841584so -> currPos .lsn = BufferGetLSNAtomic (so -> currPos .buf );
15851585so -> currPos .dir = dir ;
15861586so -> currPos .nextTupleOffset = 0 ;
@@ -2154,7 +2154,7 @@ _bt_readfirstpage(IndexScanDesc scan, OffsetNumber offnum, ScanDirection dir)
21542154so -> numKilled = 0 ;/* just paranoia */
21552155so -> markItemIndex = -1 ;/* ditto */
21562156
2157- /* Initialize currPos for so->currPos */
2157+ /* Initializeso-> currPos forthe first page (page in so->currPos.buf) */
21582158if (so -> needPrimScan )
21592159{
21602160Assert (so -> numArrayKeys );
@@ -2175,7 +2175,7 @@ _bt_readfirstpage(IndexScanDesc scan, OffsetNumber offnum, ScanDirection dir)
21752175}
21762176
21772177/*
2178- * Attempt to load matching tuples from thepage in so->currPos.buf .
2178+ * Attempt to load matching tuples from thefirst page .
21792179 *
21802180 * Note that _bt_readpage will finish initializing the so->currPos fields.
21812181 * _bt_readpage also releases parallel scan (even when it returns false).
@@ -2208,8 +2208,7 @@ _bt_readfirstpage(IndexScanDesc scan, OffsetNumber offnum, ScanDirection dir)
22082208 * Caller's blkno is the next interesting page's link, taken from either the
22092209 * previously-saved right link or left link. lastcurrblkno is the page that
22102210 * was current at the point where the blkno link was saved, which we use to
2211- * reason about concurrent page splits/page deletions during backwards scans
2212- * (_bt_parallel_seize also requires it, regardless of scan direction).
2211+ * reason about concurrent page splits/page deletions during backwards scans.
22132212 *
22142213 * On entry, caller shouldn't hold any locks or pins on any page (we work
22152214 * directly off of blkno and lastcurrblkno instead). Parallel scan callers
@@ -2234,8 +2233,6 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno,
22342233{
22352234Relation rel = scan -> indexRelation ;
22362235BTScanOpaque so = (BTScanOpaque )scan -> opaque ;
2237- Page page ;
2238- BTPageOpaque opaque ;
22392236
22402237Assert (so -> currPos .currPage == lastcurrblkno || scan -> parallel_scan != NULL );
22412238Assert (!BTScanPosIsPinned (so -> currPos ));
@@ -2251,14 +2248,14 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno,
22512248
22522249for (;;)
22532250{
2254- /*
2255- * if we're at end of scan, give up and mark parallel scan as done, so
2256- * that all the workers can finish their scan
2257- */
2251+ Page page ;
2252+ BTPageOpaque opaque ;
2253+
22582254if (blkno == P_NONE ||
22592255(ScanDirectionIsForward (dir ) ?
22602256 !so -> currPos .moreRight : !so -> currPos .moreLeft ))
22612257{
2258+ /* most recent _bt_readpage call (for lastcurrblkno) ended scan */
22622259_bt_parallel_done (scan );
22632260BTScanPosInvalidate (so -> currPos );
22642261return false;