Skip to content

Commit e3a02a3

Browse files
committed
Fix incorrect loop counts in tidbitmap.c.
A couple of places that should have been iterating over WORDS_PER_CHUNK words were iterating over WORDS_PER_PAGE words instead. This thinko accidentally failed to fail, because (at least on common architectures with default BLCKSZ) WORDS_PER_CHUNK is a bit less than WORDS_PER_PAGE, and the extra words being looked at were always zero so nothing happened. Still, it's a bug waiting to happen if anybody ever fools with the parameters affecting TIDBitmap sizes, and it's a small waste of cycles too. So back-patch to all active branches. Etsuro Fujita
1 parent 71ff6c1 commit e3a02a3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/nodes/tidbitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ tbm_union_page(TIDBitmap *a, const PagetableEntry *bpage)
362362
if (bpage->ischunk)
363363
{
364364
/* Scan b's chunk, mark each indicated page lossy in a */
365-
for (wordnum = 0; wordnum < WORDS_PER_PAGE; wordnum++)
365+
for (wordnum = 0; wordnum < WORDS_PER_CHUNK; wordnum++)
366366
{
367367
bitmapword w = bpage->words[wordnum];
368368

@@ -474,7 +474,7 @@ tbm_intersect_page(TIDBitmap *a, PagetableEntry *apage, const TIDBitmap *b)
474474
/* Scan each bit in chunk, try to clear */
475475
bool candelete = true;
476476

477-
for (wordnum = 0; wordnum < WORDS_PER_PAGE; wordnum++)
477+
for (wordnum = 0; wordnum < WORDS_PER_CHUNK; wordnum++)
478478
{
479479
bitmapword w = apage->words[wordnum];
480480

0 commit comments

Comments
 (0)