Re: Infinite Interval

From: Joseph Koshakow <koshy44(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Infinite Interval
Date: 2023-01-07 20:04:25
Message-ID: CAAvxfHf0-T99i=Orve_xfonVCvsCuPy7C4avVm=+yu128ujSGg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 5, 2023 at 11:30 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
>
>
> On Fri, Jan 6, 2023 at 6:54 AM Joseph Koshakow <koshy44(at)gmail(dot)com> wrote:
>>
>> Looks like some of the error messages have changed and we
>> have some issues with parsing "+infinity" after rebasing.
>
>
> There is a commit 2ceea5adb02603ef52579b568ca2c5aebed87358
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=2ceea5adb02603ef52579b568ca2c5aebed87358
> if you pull this commit then you can do select interval '+infinity', even though I don't know why.

It turns out that I was just misreading the error. The test was
expecting us to fail on "+infinity" but we succeeded. I just removed
that test case.

>> pgindent. Looks like some of the error messages have changed

The conditions for checking valid addition/subtraction between infinite
values were missing some cases which explains the change in error
messages. I've updated the logic and removed duplicate checks.

I removed the extract/date_part tests since they were duplicated in a
test above. I also converted the DO command tests to using SQL with
joins so it more closely matches the existing tests.

I've updated the extract/date_part logic for infinite intervals. Fields
that are monotonically increasing should return +/-infinity and all
others should return NULL. For Intervals, the fields are the same as
timestamps plus the hour and day fields since those don't overflow into
the next highest field.

I think this patch is just about ready for review, except for the
following two questions:
1. Should finite checks on intervals only look at months or all three
fields?
2. Should we make the error messages for adding/subtracting infinite
values more generic or leave them as is?

My opinions are
1. We should only look at months.
2. We should make the errors more generic.

Anyone else have any thoughts?

- Joe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joseph Koshakow 2023-01-07 20:05:14 Re: Infinite Interval
Previous Message Tom Lane 2023-01-07 18:50:04 Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher