Re: Infinite Interval

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(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-30 10:00:56
Message-ID: CAExHW5sa3D4bgKpsPHYVR69yVfRPrOYkn61XPV4-MpqO+-cCuw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Oct 29, 2023 at 10:09 PM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> On Fri, 27 Oct 2023 at 09:38, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> >
> > On Tue, 10 Oct 2023 at 12:36, Ashutosh Bapat
> >
> > > 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.
> >
>
> I have pushed 0001. Here is 0002-0008, squashed down to one commit,
> plus the change discussed to use INTERVAL_NOBEGIN() in the btree_gin
> code.

Thanks. I had to leave this halfway on Friday because of severe tooth ache.

I was actually working on the test part of 0009. Though the code
changes are not required, I think it's better to have a test case
along the same lines as the tests added by Tomas (now committed in
8da86d62a11269e926765c0d6ef6f532b2b8b749). I have attached 0002 for
the same along with your v28.

>
> It could use another read-through, and then I think it will be ready for commit.
>
Thanks. I went through the whole patch again and am quite fine with it.

Here's my version of commit message

```
Support Infinite interval values

Interval datatype uses the same input and output representation for
infinite intervals as other datatypes representing time that support
infinity. An interval larger than any other interval is represented by
string literal 'infinity' or '+infinity'. An interval which is smaller
than any other interval is represented as '-infinity'. Internally
positive infinity is represented as maximum values supported by all
the member types of Interval datastructure and negative infinity is
represented as minimum values set to all the members. INTERVAL_NOBEGIN
and INTERVAL_NOEND macros can be used to set an Interval structure to
negative and positive infinity respectively. INTERVAL_IS_NOBEGIN and
INTERVAL_IS_NOEND macros are used to test respective values.
INTERVAL_NOT_FINITE macro is used to test whether a given Interval
value is infinite.

Implementation of all known operators now handles infinite interval
values along with operations related to BRIN index, windowing and
selectivity. Regression tests are added to test these implementation.

If a user has stored interval values '-2147483648 months -2147483648
days -9223372036854775807 us' and '2147483647 months 2147483647 days
9223372036854775806 us' in PostgreSQL versions 16 or earlier. Those
values will turn into '-infinity' and 'infinity' respectively after
upgrading to v17. These values are outside the documented range
supported by interval datatype and thus there's almost no possibility
of this occurrence. But it will be good to watch for these values
during upgrade.
```

--
Best Wishes,
Ashutosh Bapat

Attachment Content-Type Size
v28-0001-Support-infinite-interval-values.patch text/x-patch 159.7 KB
0002-BRIN-test-for-infinite-interval-values-20231030.patch text/x-patch 3.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-10-30 10:24:39 Re: Is this a problem in GenericXLogFinish()?
Previous Message Peter Eisentraut 2023-10-30 09:45:52 Explicitly skip TAP tests under Meson if disabled