pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Infinities in type numeric
Date: Fri, 12 Jun 2020 13:00:59 -0400
Message-ID: <702941.1591981259@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoaE3zuGc0L0c-XZ-6BYR1kY=Eqy4bTDvc1m+sHVAdt6jg@mail.gmail.com>
References: <606717.1591924582@sss.pgh.pa.us>
	<CA+TgmoaE3zuGc0L0c-XZ-6BYR1kY=Eqy4bTDvc1m+sHVAdt6jg@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Jun 11, 2020 at 9:16 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> We had a discussion recently about how it'd be a good idea to support
>> infinity values in type numeric [1].

> FWIW, I don't particularly like the idea. Back when I was an
> application developer, I remember having to insert special cases into
> any code that dealt with double precision to deal with +/-Inf and NaN.
> I was happy that I didn't need them for numeric, too. So this change
> would have made me sad.

Well, you're already stuck with special-casing numeric NaN, so I'm
not sure that Inf makes your life noticeably worse on that score.

This does tie into something I have a question about in the patch's
comments though.  As the patch stands, numeric(numeric, integer)
(that is, the typmod-enforcement function) just lets infinities
through regardless of the typmod, on the grounds that it is/was also
letting NaNs through regardless of typmod.  But you could certainly
make the argument that Inf should only be allowed in an unconstrained
numeric column, because by definition it overflows any finite precision
restriction.  If we did that, you'd never see Inf in a
standard-conforming column, since SQL doesn't allow unconstrained
numeric columns IIRC.  That'd at least ameliorate your concern.

If we were designing this today, I think I'd vote to disallow NaN
in a constrained numeric column, too.  But I suppose it's far too
late to change that aspect.

			regards, tom lane





view thread (21+ messages)  latest in thread

Message-ID: <702941.1591981259@sss.pgh.pa.us>
Permalink:  ../702941.1591981259@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/702941.1591981259@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com
  Subject: Re: Infinities in type numeric
  In-Reply-To: <702941.1591981259@sss.pgh.pa.us>
  References: <606717.1591924582@sss.pgh.pa.us> <CA+TgmoaE3zuGc0L0c-XZ-6BYR1kY=Eqy4bTDvc1m+sHVAdt6jg@mail.gmail.com> <702941.1591981259@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox