Can rs_cindex be < 0 for bitmap heap scans?
Melanie Plageman <melanieplageman@gmail.com>
From: Melanie Plageman <melanieplageman@gmail.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: Tomas Vondra <tv@fuzzy.cz>
Date: 2024-10-23T22:15:37Z
Lists: pgsql-hackers
Attachments
- v1-0001-Remove-unused-rs_cindex-condition-in-heap-AM-bitm.patch (application/octet-stream) patch v1-0001
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
Commits
-
Fix overflow danger in SampleHeapTupleVisible(), take 2
- 94bb6c4410d8 18.0 landed
-
Fix overflow danger in SampleHeapTupleVisible()
- 28328ec87b45 18.0 landed
-
Make rs_cindex and rs_ntuples unsigned
- 68d9662be1c4 18.0 landed