Re: Infinite Interval

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Joseph Koshakow <koshy44(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Infinite Interval
Date: 2023-10-27 08:38:29
Message-ID: CAEZATCXCiqQAD1XerMEpdqKt9zA8xNA32mYGUhsCwmNz-xWX=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 10 Oct 2023 at 12:36, Ashutosh Bapat
<ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> wrote:
>
> > > 2. The various in_range() functions needed adjusting to handle
> > > infinite interval offsets.
> > >
> I think this code is reasonable. But users may find it inconsistent
> with the other ways to achieve the same outcome. For example, We don't
> allow non-finite intervals to be added or subtracted from time or
> timetz. So if someone tries to compare the rows using val >/<= base
> +/- offset, those queries will fail whereas similar implied conditions
> in window specification will not throw an error. If you have
> considered this already, I am fine with the code as is.
>

It's consistent with the documented contract of the in_range support
functions. See https://www.postgresql.org/docs/current/btree-support-funcs.html

In particular, this part:

An additional expectation is that in_range functions should, if
practical, avoid throwing an error if base + offset or base - offset
would overflow. The correct comparison result can be determined even
if that value would be out of the data type's range. Note that if the
data type includes concepts such as "infinity" or "NaN", extra
care may be needed to ensure that in_range's results agree with the
normal sort order of the operator family.

> Added a separate patch (0009) to fix
> brin_minmax_multi_distance_interval().
>

I think we can drop this from this thread now, given the discussion
over on the other thread
(https://www.postgresql.org/message-id/eef0ea8c-4aaa-8d0d-027f-58b1f35dd170%40enterprisedb.com)

> I have added a separate patch (0008) to test negative interval values,
> including -infinity, in preceding and following specification.
>
> Patches from 0001 to 0007 are same as what you attached but rebased on
> the latest HEAD.
>

I'm attaching another update, with a minor change to the aggregate
deserialization function, in line with the recent change to how these
now work elsewhere (see 0c882a298881056176a27ccc44c5c3bb7c8f308c).

0008 seems reasonable. I have added some comments to indicate that
those tests are expected to fail, and why.

> I think we should squash 0002 to 0007.
>

Yes, let's do that with the next update. In fact, we may as well
squash 0002 to 0008.

Regards,
Dean

Attachment Content-Type Size
v27-0003-Introduce-infinity-interval-specification-in-Dec.patch application/x-patch 5.1 KB
v27-0002-Add-infinite-interval-values.patch application/x-patch 96.9 KB
v27-0004-Support-infinite-interval-values-in-sum-and-avg-.patch application/x-patch 25.7 KB
v27-0005-Use-integer-overflow-checking-routines-to-add-an.patch application/x-patch 15.7 KB
v27-0001-Check-for-overflow-in-make_interval.patch application/x-patch 5.8 KB
v27-0006-Implement-serialization-functions-for-interval-a.patch application/x-patch 5.7 KB
v27-0007-Code-review-of-infinite-interval-support.patch application/x-patch 102.2 KB
v27-0008-Add-tests-for-invalid-preceding-or-following-siz.patch application/x-patch 12.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-10-27 08:44:17 Re: pg_upgrade's object listing
Previous Message Dean Rasheed 2023-10-27 08:37:23 Re: Infinite Interval