From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
---|---|
To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
Cc: | Melanie Plageman <melanieplageman(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Tomas Vondra <tv(at)fuzzy(dot)cz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: Can rs_cindex be < 0 for bitmap heap scans? |
Date: | 2024-12-19 12:29:27 |
Message-ID: | CAEudQAqyPOT1trOm_AjbAAUJUSm8KjtNb5xt40CCSA6Hmse3iQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Em qua., 18 de dez. de 2024 às 23:50, Richard Guo <guofenglinux(at)gmail(dot)com>
escreveu:
> On Thu, Dec 19, 2024 at 8:18 AM Melanie Plageman
> <melanieplageman(at)gmail(dot)com> wrote:
> > I pushed the straightforward option for now so that it's fixed.
>
> I think this binary search code now has a risk of underflow. If 'mid'
> is calculated as zero, the second 'if' branch will cause 'end' to
> underflow.
>
> Maybe we need to do something like below.
>
> --- a/src/backend/access/heap/heapam_handler.c
> +++ b/src/backend/access/heap/heapam_handler.c
> @@ -2600,7 +2600,11 @@ SampleHeapTupleVisible(TableScanDesc scan, Buffer
> buffer,
> if (tupoffset == curoffset)
> return true;
> else if (tupoffset < curoffset)
> + {
> + if (mid == 0)
> + return false;
> end = mid - 1;
> + }
> else
> start = mid + 1;
> }
>
> Alternatively, we can revert 'start' and 'end' to signed int as they
> were before.
>
How would it be *signed*?
Wouldn't overflow happen in this case?
rs_tuples now can be
UINT_MAX = 4294967295
best regards,
Ranier Vilela
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Banck | 2024-12-19 12:36:44 | Re: [PATCH] Add support for displaying database service in psql prompt |
Previous Message | Ranier Vilela | 2024-12-19 12:22:04 | Re: Can rs_cindex be < 0 for bitmap heap scans? |