From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nitin Motiani <nitinmotiani@google.com>
Cc: Dilip Kumar <dilipbalaut@gmail.com>
Cc: alpkeles99@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19761: btree_gist: "cannot subtract infinite dates" when inserting 'infinity' into a GiST index on date
Date: Mon, 26 Oct 2026 12:10:46 -0400
Message-ID: <638642.1793031046@sss.pgh.pa.us> (raw)
In-Reply-To: <CAH5HC96iozmO=H_sgihkb5F97evpjwb+4bCvY1RWVnxBK4a1hw@mail.gmail.com>
References: <19761-b72cfc453e487610@postgresql.org>
<CAH5HC95Bv34Drxh4DLt1qvCtc5suwKVcmfuQaixqiERJtHSHgg@mail.gmail.com>
<CAFiTN-sUiDN6ef-eONKhP6=Nz1sdaY6S9xHeaPtUgmVpuZ8ROg@mail.gmail.com>
<CAH5HC96OaXibbEbBaPVGTeb6UZyBCsQSWWd5hND+k_uhobTAnQ@mail.gmail.com>
<CAFiTN-s=CrBeXpBiHBXCu0ZpYqB-138vbmn4MajV_zFYPrRjKw@mail.gmail.com>
<CAH5HC96iozmO=H_sgihkb5F97evpjwb+4bCvY1RWVnxBK4a1hw@mail.gmail.com>
Nitin Motiani <nitinmotiani@google.com> writes:
> Thanks for the review, Dilip. I'm attaching the v2 patch which makes
> the change in date_dist also.
I think this is not there yet. An important behavior of the
corresponding code for float8 (float_penalty_num_impl()) is that
it makes the distance between two same-sign infinity values be zero,
not infinity. This is mathematically wrong but we must do it for
indexing purposes, else inserting multiple infinities will end up
splitting each infinity onto its own index page when we want all
identical infinities to pack onto as few index pages as possible.
BTW, while checking this I happened to notice that
gbt_float8_dist has a variant of the same problem:
r = arg1 - arg2;
if (unlikely(isinf(r)) && !isinf(arg1) && !isinf(arg2))
float_overflow_error();
I don't think we want an error thrown there either;
returning the infinite distance (or DBL_MAX?) seems better.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, nitinmotiani@google.com, dilipbalaut@gmail.com, alpkeles99@gmail.com
Subject: Re: BUG #19761: btree_gist: "cannot subtract infinite dates" when inserting 'infinity' into a GiST index on date
In-Reply-To: <638642.1793031046@sss.pgh.pa.us>
References: <19761-b72cfc453e487610@postgresql.org> <CAH5HC95Bv34Drxh4DLt1qvCtc5suwKVcmfuQaixqiERJtHSHgg@mail.gmail.com> <CAFiTN-sUiDN6ef-eONKhP6=Nz1sdaY6S9xHeaPtUgmVpuZ8ROg@mail.gmail.com> <CAH5HC96OaXibbEbBaPVGTeb6UZyBCsQSWWd5hND+k_uhobTAnQ@mail.gmail.com> <CAFiTN-s=CrBeXpBiHBXCu0ZpYqB-138vbmn4MajV_zFYPrRjKw@mail.gmail.com> <CAH5HC96iozmO=H_sgihkb5F97evpjwb+4bCvY1RWVnxBK4a1hw@mail.gmail.com> <638642.1793031046@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox