Re: Can rs_cindex be < 0 for bitmap heap scans?

Melanie Plageman <melanieplageman@gmail.com>

From: Melanie Plageman <melanieplageman@gmail.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Ranier Vilela <ranier.vf@gmail.com>, Dilip Kumar <dilipbalaut@gmail.com>, Pg Hackers <pgsql-hackers@postgresql.org>, Tomas Vondra <tv@fuzzy.cz>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2024-12-20T14:45:47Z
Lists: pgsql-hackers
On Thu, Dec 19, 2024 at 9:36 PM Richard Guo <guofenglinux@gmail.com> wrote:
>
> On Fri, Dec 20, 2024 at 7:50 AM Melanie Plageman
> <melanieplageman@gmail.com> wrote:
> Looks correct to me.
>
> BTW, I kind of doubt that the overflow risk fixed in 28328ec87 is a
> real issue in real-world scenarios.  Is it realistically possible to
> have more than INT_MAX tuples fit on one heap page?
>
> If it is, then the statement below could also be prone to overflow.
>
>     uint32      mid = (start + end) / 2;
>
> Maybe you want to change it to:
>
>     uint32      mid = start + (end - start) / 2;

I've done this and pushed.

Thanks to you and Ranier for your help in identifying and fixing this!

- Melanie



Commits

  1. Fix overflow danger in SampleHeapTupleVisible(), take 2

  2. Fix overflow danger in SampleHeapTupleVisible()

  3. Make rs_cindex and rs_ntuples unsigned