Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06b10f8

Browse files
committed
Remove BTScanOpaqueData.firstPage
It's not necessary to keep the firstPage flag as a field of BTScanOpaqueData.This commit makes it an argument of the _bt_readpage() function. We can easilydistinguish first-time and repeated calls (within the scan) of this function.Reported-by: Peter GeogheganDiscussion:https://postgr.es/m/CAH2-Wzk4SOsw%2BtHuTFiz8U9Jqj-R77rYPkhWKODCBb1mdHACXA%40mail.gmail.comReviewed-by: Pavel Borisov
1 parent3e527ae commit06b10f8

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

‎src/backend/access/nbtree/nbtree.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@ btrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
409409

410410
so->markItemIndex=-1;
411411
so->arrayKeyCount=0;
412-
so->firstPage= false;
413412
BTScanPosUnpinIfPinned(so->markPos);
414413
BTScanPosInvalidate(so->markPos);
415414

‎src/backend/access/nbtree/nbtsearch.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static OffsetNumber _bt_binsrch(Relation rel, BTScanInsert key, Buffer buf);
3030
staticint_bt_binsrch_posting(BTScanInsertkey,Pagepage,
3131
OffsetNumberoffnum);
3232
staticbool_bt_readpage(IndexScanDescscan,ScanDirectiondir,
33-
OffsetNumberoffnum);
33+
OffsetNumberoffnum,boolfirstPage);
3434
staticvoid_bt_saveitem(BTScanOpaqueso,intitemIndex,
3535
OffsetNumberoffnum,IndexTupleitup);
3636
staticint_bt_setuppostingitems(BTScanOpaqueso,intitemIndex,
@@ -1395,7 +1395,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
13951395
offnum=_bt_binsrch(rel,&inskey,buf);
13961396
Assert(!BTScanPosIsValid(so->currPos));
13971397
so->currPos.buf=buf;
1398-
so->firstPage= true;
13991398

14001399
/*
14011400
* Now load data from the first page of the scan.
@@ -1416,7 +1415,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
14161415
* for the page. For example, when inskey is both < the leaf page's high
14171416
* key and > all of its non-pivot tuples, offnum will be "maxoff + 1".
14181417
*/
1419-
if (!_bt_readpage(scan,dir,offnum))
1418+
if (!_bt_readpage(scan,dir,offnum, true))
14201419
{
14211420
/*
14221421
* There's no actually-matching data on this page. Try to advance to
@@ -1520,7 +1519,8 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
15201519
* Returns true if any matching items found on the page, false if none.
15211520
*/
15221521
staticbool
1523-
_bt_readpage(IndexScanDescscan,ScanDirectiondir,OffsetNumberoffnum)
1522+
_bt_readpage(IndexScanDescscan,ScanDirectiondir,OffsetNumberoffnum,
1523+
boolfirstPage)
15241524
{
15251525
BTScanOpaqueso= (BTScanOpaque)scan->opaque;
15261526
Pagepage;
@@ -1601,7 +1601,7 @@ _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum)
16011601
* We skip this for the first page in the scan to evade the possible
16021602
* slowdown of the point queries.
16031603
*/
1604-
if (!so->firstPage&&minoff<maxoff)
1604+
if (!firstPage&&minoff<maxoff)
16051605
{
16061606
ItemIdiid;
16071607
IndexTupleitup;
@@ -1620,7 +1620,6 @@ _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum)
16201620
}
16211621
else
16221622
{
1623-
so->firstPage= false;
16241623
requiredMatchedByPrecheck= false;
16251624
}
16261625

@@ -2079,7 +2078,7 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir)
20792078
PredicateLockPage(rel,blkno,scan->xs_snapshot);
20802079
/* see if there are any matches on this page */
20812080
/* note that this will clear moreRight if we can stop */
2082-
if (_bt_readpage(scan,dir,P_FIRSTDATAKEY(opaque)))
2081+
if (_bt_readpage(scan,dir,P_FIRSTDATAKEY(opaque), false))
20832082
break;
20842083
}
20852084
elseif (scan->parallel_scan!=NULL)
@@ -2170,7 +2169,7 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir)
21702169
PredicateLockPage(rel,BufferGetBlockNumber(so->currPos.buf),scan->xs_snapshot);
21712170
/* see if there are any matches on this page */
21722171
/* note that this will clear moreLeft if we can stop */
2173-
if (_bt_readpage(scan,dir,PageGetMaxOffsetNumber(page)))
2172+
if (_bt_readpage(scan,dir,PageGetMaxOffsetNumber(page), false))
21742173
break;
21752174
}
21762175
elseif (scan->parallel_scan!=NULL)
@@ -2487,14 +2486,13 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
24872486

24882487
/* remember which buffer we have pinned */
24892488
so->currPos.buf=buf;
2490-
so->firstPage= true;
24912489

24922490
_bt_initialize_more_data(so,dir);
24932491

24942492
/*
24952493
* Now load data from the first page of the scan.
24962494
*/
2497-
if (!_bt_readpage(scan,dir,start))
2495+
if (!_bt_readpage(scan,dir,start, false))
24982496
{
24992497
/*
25002498
* There's no actually-matching data on this page. Try to advance to

‎src/include/access/nbtree.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,6 @@ typedef struct BTScanOpaqueData
10511051
int*killedItems;/* currPos.items indexes of killed items */
10521052
intnumKilled;/* number of currently stored items */
10531053

1054-
/* flag indicating the first page in the scan */
1055-
boolfirstPage;
1056-
10571054
/*
10581055
* If we are doing an index-only scan, these are the tuple storage
10591056
* workspaces for the currPos and markPos respectively. Each is of size

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp