| From: | Raja Sai pranav <rajasaipranav0(at)gmail(dot)com> |
|---|---|
| To: | tgl(at)sss(dot)pgh(dot)pa(dot)us |
| Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: btree_gist: <-> fails on same-sign infinite intervals |
| Date: | 2026-11-28 15:09:15 |
| Message-ID: | CAPHduZB9te2EFA1-qG3CL9W1rUhHr3=QkuJCCufPG4d8i8YGRg@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:
> 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.
Right. There was a second one too: abs_interval() negates the
difference with interval_um(), which also errors when the difference
fits but its negation doesn't. For example
'-178956970 years -7 months'::interval <-> '1 mon'::interval
subtracts to exactly INT_MIN months.
v2 subtracts the smaller input from the larger (by interval_cmp), so
the result is never negative and isn't negated, and does the
finite_interval_mi() arithmetic inline, returning +infinity when it
overflows. The tests now cover the subtraction overflow, the negation
overflow and an ORDER BY with a sort; each of the three fails with
"interval out of range" with the v1 code and passes with v2.
The master patch applies to REL_19_STABLE. REL_18_STABLE and
REL_17_STABLE differ only in the #include lines; the second
attachment is the REL_18 version, where btree_gist's tests pass and
fail the same way without the fix. I haven't built REL_17.
Regards,
Sai Pranav
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-btree_gist-Don-t-report-overflow-for-interval-int.patch | text/x-patch | 7.6 KB |
| v2-0001-btree_gist-Dont-report-overflow-for-interval-int.REL_18.patch | text/x-patch | 7.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Raja Sai pranav | 2026-11-28 15:09:17 | Re: BUG #19928: pg_upgrade fails on v18 schema with NOT NULL ... NO INHERIT and inheritance |
| Previous Message | Zsolt Parragi | 2026-11-28 12:13:58 | Re: pg_rewind WAL segments deletion pitfall |