Re: [PATCH] btree_gist: overflow in gbt_numeric_penalty (sibling of 15b3dc140d9)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
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-26 21:43:44
Message-ID: 1941808.1795729424@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

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.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Koshino Taiki 2026-11-26 22:08:34 [PATCH] Improve tab completion after CREATE INDEX key list
Previous Message Peter Smith 2026-11-26 21:22:44 Re: DOC: Minor updates for logical replication conflicts