| From: | Ewan Young <kdbase(dot)hack(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nitin Motiani <nitinmotiani(at)google(dot)com> |
| Subject: | Re: [PATCH] btree_gist: overflow in gbt_numeric_penalty (sibling of 15b3dc140d9) |
| Date: | 2026-11-27 06:23:28 |
| Message-ID: | CAON2xHMPSKF0S2ExXfaPKhmj5yKV78=bkVRt-Q9C8O39mLLHPw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Nov 27, 2026 at 5:43 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Ewan Young <kdbase(dot)hack(at)gmail(dot)com> writes:
> > 15b3dc140d9 fixed overflow in btree_gist's date/float8/timestamp penalty
> > and distance functions, but the numeric opclass has the same problem.
>
> Yeah, we should fix this, but your v1 doesn't feel quite right to me.
>
> 1. Wouldn't it make more sense to treat an overflowed subtraction
> result as Infinity rather than NaN? That's what happens in
> gbt_float8_dist() since 15b3dc140d9.
Agreed, done -- an overflowed width is now treated as infinite.
>
> 2. I'm unconvinced that the ds calculation is entirely safe yet.
> In particular, it seems we could be computing Inf - Inf there,
> which will yield NaN when we'd rather get zero.
Right. v2 attached, which handles a NaN or infinite width (whether
from an overflow or
an actual infinite bound) up front, so ds = us - os only runs when us is
finite.
>
> regards, tom lane
--
Regards,
Ewan Young
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-btree_gist-avoid-numeric-overflow-in-gbt_numeric_penalty.patch | application/octet-stream | 6.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shveta malik | 2026-11-27 06:51:38 | Re: Preserve conflict log table during upgrade |
| Previous Message | Amit Kapila | 2026-11-27 06:19:06 | Re: Preserve conflict log table during upgrade |