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