Can rs_cindex be < 0 for bitmap heap scans?

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Tomas Vondra <tv(at)fuzzy(dot)cz>
Subject: Can rs_cindex be < 0 for bitmap heap scans?
Date: 2024-10-23 22:15:37
Message-ID: CAAKRu_bceru9+ur7dTz8-KGAXi+n-DmcnAO9gbMD-tn2A-aCug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

HeapScanDescData->rs_cindex (the current index into the array of
visible tuples stored in the heap scan descriptor) is used for
multiple scan types, but for bitmap heap scans, AFAICT, it should
never be < 0.

As such, I find this test in heapam_scan_bitmap_next_tuple() pretty confusing.

if (hscan->rs_cindex < 0 || hscan->rs_cindex >= hscan->rs_ntuples)

I know it seems innocuous, but I find it pretty distracting. Am I
missing something? Could it somehow be < 0?

If not, I propose removing that part of the if statement like in the
attached patch.

- Melanie

Attachment Content-Type Size
v1-0001-Remove-unused-rs_cindex-condition-in-heap-AM-bitm.patch application/octet-stream 1.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2024-10-23 22:26:19 Re: Refactor to use common function 'get_publications_str'.
Previous Message Melanie Plageman 2024-10-23 22:04:36 Re: Using read_stream in index vacuum