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

Commit68d9662

Browse files
Make rs_cindex and rs_ntuples unsigned
HeapScanDescData.rs_cindex and rs_ntuples can't be less than 0. All scantypes using the heap scan descriptor expect these values to be >= 0.Make that expectation clear by making rs_cindex and rs_ntuples unsigned.Also remove the test in heapam_scan_bitmap_next_tuple() that checks ifrs_cindex < 0. This was never true, but now that rs_cindex is unsigned,it makes even less sense.While we are at it, initialize both rs_cindex and rs_ntuples to 0 ininitscan().Author: Melanie PlagemanReviewed-by: Dilip KumarDiscussion:https://postgr.es/m/CAAKRu_ZxF8cDCM_BFi_L-t%3DRjdCZYP1usd1Gd45mjHfZxm0nZw%40mail.gmail.com
1 parent1f0de66 commit68d9662

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ initscan(HeapScanDesc scan, ScanKey key, bool keep_startblock)
378378
ItemPointerSetInvalid(&scan->rs_ctup.t_self);
379379
scan->rs_cbuf=InvalidBuffer;
380380
scan->rs_cblock=InvalidBlockNumber;
381+
scan->rs_ntuples=0;
382+
scan->rs_cindex=0;
381383

382384
/*
383385
* Initialize to ForwardScanDirection because it is most common and
@@ -943,8 +945,8 @@ heapgettup_pagemode(HeapScanDesc scan,
943945
{
944946
HeapTupletuple=&(scan->rs_ctup);
945947
Pagepage;
946-
intlineindex;
947-
intlinesleft;
948+
uint32lineindex;
949+
uint32linesleft;
948950

949951
if (likely(scan->rs_inited))
950952
{
@@ -989,6 +991,7 @@ heapgettup_pagemode(HeapScanDesc scan,
989991
ItemIdlpp;
990992
OffsetNumberlineoff;
991993

994+
Assert(lineindex <=scan->rs_ntuples);
992995
lineoff=scan->rs_vistuples[lineindex];
993996
lpp=PageGetItemId(page,lineoff);
994997
Assert(ItemIdIsNormal(lpp));

‎src/backend/access/heap/heapam_handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ heapam_scan_bitmap_next_tuple(TableScanDesc scan,
23032303
/*
23042304
* Out of range? If so, nothing more to look at on this page
23052305
*/
2306-
if (hscan->rs_cindex<0||hscan->rs_cindex>=hscan->rs_ntuples)
2306+
if (hscan->rs_cindex >=hscan->rs_ntuples)
23072307
return false;
23082308

23092309
targoffset=hscan->rs_vistuples[hscan->rs_cindex];

‎src/include/access/heapam.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ typedef struct HeapScanDescData
103103
intrs_empty_tuples_pending;
104104

105105
/* these fields only used in page-at-a-time mode and for bitmap scans */
106-
intrs_cindex;/* current tuple's index in vistuples */
107-
intrs_ntuples;/* number of visible tuples on page */
106+
uint32rs_cindex;/* current tuple's index in vistuples */
107+
uint32rs_ntuples;/* number of visible tuples on page */
108108
OffsetNumberrs_vistuples[MaxHeapTuplesPerPage];/* their offsets */
109109
}HeapScanDescData;
110110
typedefstructHeapScanDescData*HeapScanDesc;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp