On Mon, 17 Dec 2018 at 18:00, Tom Lane <t...@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?