| From: | Raja Sai pranav <rajasaipranav0(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | 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-03 04:59:21 |
| Message-ID: | CAPHduZBW+hm2X3+fj=ttLRfD_+OWzZqyFGFrVR61c575-o9oTg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> I think your fix for interval_dist() is good,
> but I believe that Kirill has identified an independent problem:
> intr2num() and its callers haven't been modernized to handle
> infinite intervals. I don't like the details of what he did though.
> I prefer something more like the attached.
Agreed, both are needed. I tested on master (f68727292a), cassert build,
comparing index-scan vs seqscan ORDER BY v <-> probe LIMIT 20 on a 10k-row
table with +-infinity and near-overflow values:
master: 4 of 10 probes disagree
my v1 only: 2 (the +-178000000 years probes; -infinity rows
ranked near them, which your intr2num() change fixes)
your 0002 only: 2 (the +-2147483647 hours probes; Kirill's case still
gives infinity / wrong row)
both: 0
The two patches apply in either order with offsets only. btree_gist
check passes for each, main regress passes with both. No NaN seen with
infinite keys.
One gap left in my v1: '-2147483647 hours' <-> '2147483647 hours' is
about 497102 years, but v1 returns infinity because the span doesn't fit
in the time field alone, so a KNN scan and a sort still disagree on a
table holding '178000000 years'. The attached v2, on top of your 0002,
spreads such a span over the month and day fields and returns infinity
only when that doesn't fit. It also adds KNN tests for this case and for
-infinity (your 0002 has none); each fails if the matching code is
reverted.
Regards,
Sai Pranav
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-btree_gist-Don-t-report-a-finite-interval-distanc.patch | application/octet-stream | 6.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Lakhin | 2026-12-03 05:00:00 | Re: BUG #19723: CREATE INDEX racing with ALTER INDEX ATTACH PARTITION triggers unexpected internal error |
| Previous Message | Fujii Masao | 2026-12-03 04:24:36 | Re: BUG #19967: ecpg crashes after "cursor does not exist" on FETCH or MOVE |