Re: btree_gist: <-> fails on same-sign infinite intervals

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Raja Sai pranav <rajasaipranav0(at)gmail(dot)com>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: btree_gist: <-> fails on same-sign infinite intervals
Date: 2026-12-05 18:43:59
Message-ID: 182917.1796496239@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Raja Sai pranav <rajasaipranav0(at)gmail(dot)com> writes:
> On Sat, 5 Dec 2026, shihao zhong wrote:
>> v2 still has one ordering problem. From '0', '-2147483648 mons' gets
>> infinity but the farther '-2147483647 mons -2147483647 days' gets a
>> finite distance. So the index and a sort disagree on which is nearest.

> Thanks, I see the same on master (91d71a71cb) + Tom's 0002 + v2: the two
> distances are infinity and '178956970 years 7 mons 2147483647 days', and
> on a small table a GiST scan and a seqscan sort return them in a
> different order.

Yeah. I think actually we should drop the conversion to
time-field-only and just use Shihao's conversion, as attached.
Otherwise there will be weird differences in how overflowed intervals
of different sizes are represented. They will sort correctly
according to interval_cmp, but they will look inconsistent by
eye, and I don't see a reason for that.

regards, tom lane

Attachment Content-Type Size
v4-btree_gist_fixes.patch text/x-diff 8.5 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Konstantin Knizhnik 2026-12-05 20:08:12 Re: BUG #19519: REPACK can fail due to missing chunk for toast value
Previous Message Pavan 2026-12-05 18:38:59 Re: BUG #19790: "cannot start a subtransaction ... inval messages" after "ALTER DOMAIN ... DROP CONSTRAINT"