Re: 'infinity'::Interval should be added - Mailing list pgsql-hackers

From Isaac Morland
Subject Re: 'infinity'::Interval should be added
Date
Msg-id CAMsGm5fN0T541Ck6Q7wED5oHLDSjdb10AMMwLzxJEY7+O7fDHw@mail.gmail.com
Whole thread Raw
In response to Re: 'infinity'::Interval should be added  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: 'infinity'::Interval should be added  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, 17 Dec 2018 at 18:00, Tom Lane <tgl@sss.pgh.pa.us> wrote:
 
> so I was thinking that
> postgres=# select 'infinity'::timestamp - 'infinity'::timestamp;
> would be zero rather than an error, for least surprise.

Wrong.  This case needs to be undefined, because "infinity"
isn't a specific value.  That's what makes it okay to define, say,
infinity plus any finite value as infinity.  There are very
well-defined rules about how to calculate with infinity, and
not following them is not the way to proceed here.

tl;dr: we should model it after the behavior of IEEE float infinities,
except we'll want to throw errors where those produce NaNs.

Would it be OK to return NULL for ∞ - ∞? Then anybody who wanted 0 could get it with coalesce (although I think this is a worse idea than anybody who wants it probably realizes), and anybody who wanted the calculation to continue on would just get a NULL propagating.

Also am I right to assume that -infinity would use -INT_MAX, etc.? Or possibly -INT_MAX - 1? 

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Should new partitions inherit their tablespace from their parent?
Next
From: Michael Paquier
Date:
Subject: Re: Fixing typos in tests of partition_info.sql