@@ -1580,7 +1580,7 @@ _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum,
1580
1580
so -> currPos .currPage );
1581
1581
}
1582
1582
1583
- /* initialize remaining currPos fields (before moreLeft/moreright ) */
1583
+ /* initialize remaining currPos fields (before moreLeft/moreRight ) */
1584
1584
so -> currPos .lsn = BufferGetLSNAtomic (so -> currPos .buf );
1585
1585
so -> currPos .dir = dir ;
1586
1586
so -> currPos .nextTupleOffset = 0 ;
@@ -2154,7 +2154,7 @@ _bt_readfirstpage(IndexScanDesc scan, OffsetNumber offnum, ScanDirection dir)
2154
2154
so -> numKilled = 0 ; /* just paranoia */
2155
2155
so -> markItemIndex = -1 ; /* ditto */
2156
2156
2157
- /* Initialize currPos for so->currPos */
2157
+ /* Initialize so-> currPos for the first page (page in so->currPos.buf) */
2158
2158
if (so -> needPrimScan )
2159
2159
{
2160
2160
Assert (so -> numArrayKeys );
@@ -2175,7 +2175,7 @@ _bt_readfirstpage(IndexScanDesc scan, OffsetNumber offnum, ScanDirection dir)
2175
2175
}
2176
2176
2177
2177
/*
2178
- * Attempt to load matching tuples from the page in so->currPos.buf .
2178
+ * Attempt to load matching tuples from the first page .
2179
2179
*
2180
2180
* Note that _bt_readpage will finish initializing the so->currPos fields.
2181
2181
* _bt_readpage also releases parallel scan (even when it returns false).
@@ -2208,8 +2208,7 @@ _bt_readfirstpage(IndexScanDesc scan, OffsetNumber offnum, ScanDirection dir)
2208
2208
* Caller's blkno is the next interesting page's link, taken from either the
2209
2209
* previously-saved right link or left link. lastcurrblkno is the page that
2210
2210
* 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.
2213
2212
*
2214
2213
* On entry, caller shouldn't hold any locks or pins on any page (we work
2215
2214
* directly off of blkno and lastcurrblkno instead). Parallel scan callers
@@ -2234,8 +2233,6 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno,
2234
2233
{
2235
2234
Relation rel = scan -> indexRelation ;
2236
2235
BTScanOpaque so = (BTScanOpaque ) scan -> opaque ;
2237
- Page page ;
2238
- BTPageOpaque opaque ;
2239
2236
2240
2237
Assert (so -> currPos .currPage == lastcurrblkno || scan -> parallel_scan != NULL );
2241
2238
Assert (!BTScanPosIsPinned (so -> currPos ));
@@ -2251,14 +2248,14 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno,
2251
2248
2252
2249
for (;;)
2253
2250
{
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
+
2258
2254
if (blkno == P_NONE ||
2259
2255
(ScanDirectionIsForward (dir ) ?
2260
2256
!so -> currPos .moreRight : !so -> currPos .moreLeft ))
2261
2257
{
2258
+ /* most recent _bt_readpage call (for lastcurrblkno) ended scan */
2262
2259
_bt_parallel_done (scan );
2263
2260
BTScanPosInvalidate (so -> currPos );
2264
2261
return false;
0 commit comments