btree_gist: <-> fails on same-sign infinite intervals
Thread notes
1 note#bug
hackorum-bot#bug
@global #bug
Hi,
Commit 15b3dc140d (bug #19761) made same-sign infinities zero distance
apart in btree_gist's date and timestamp opclasses. The interval opclass
still fails:
CREATE EXTENSION btree_gist;
SELECT 'infinity'::interval <-> 'infinity'::interval;
ERROR: interval out of range
interval_dist() computes the result with interval_mi(), which rejects
the difference of two same-sign infinities. So ORDER BY a <-> 'infinity'
(or '-infinity') on an interval column that holds that value fails,
with a KNN index scan as well as with a sort. I see it on master and
18.7; infinite intervals exist since v17.
The attached patch does what ts_dist() now does: same-sign infinities
are zero apart, any other infinite input is infinitely far. It adds
tests to the interval test, which fail without the code change. It
applies to master, REL_18_STABLE and REL_17_STABLE.
Regards,
Sai Pranav
Raja Sai pranav <rajasaipranav0@gmail.com> writes:
The attached patch does what ts_dist() now does: same-sign infinities
are zero apart, any other infinite input is infinitely far. It adds
tests to the interval test, which fail without the code change. It
applies to master, REL_18_STABLE and REL_17_STABLE.
Agreed we should fix this, but you've not fully duplicated the
fixes from 15b3dc140: since you still use interval_mi, it's
still possible to get an overflow error. I think you need to
inline what finite_interval_mi() does and substitute infinity
in the cases where it throws an error.
regards, tom lane