From: | Isaac Morland <isaac(dot)morland(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | simon(at)2ndquadrant(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: 'infinity'::Interval should be added |
Date: | 2018-12-18 01:43:18 |
Message-ID: | CAMsGm5fN0T541Ck6Q7wED5oHLDSjdb10AMMwLzxJEY7+O7fDHw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, 17 Dec 2018 at 18:00, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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?
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2018-12-18 01:57:34 | Re: Fixing typos in tests of partition_info.sql |
Previous Message | Alvaro Herrera | 2018-12-18 01:13:42 | Re: Should new partitions inherit their tablespace from their parent? |