Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjn3C-00071R-A0 for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jun 2020 17:01:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jjn3B-0006M9-4C for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jun 2020 17:01:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjn3A-0006M2-T1 for pgsql-hackers@lists.postgresql.org; Fri, 12 Jun 2020 17:01:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjn37-0008QF-Mi for pgsql-hackers@lists.postgresql.org; Fri, 12 Jun 2020 17:01:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 05CH0xmx702942; Fri, 12 Jun 2020 13:00:59 -0400 From: Tom Lane To: Robert Haas cc: PostgreSQL Hackers Subject: Re: Infinities in type numeric In-reply-to: References: <606717.1591924582@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 12 Jun 2020 12:51:18 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <702940.1591981259.1@sss.pgh.pa.us> Date: Fri, 12 Jun 2020 13:00:59 -0400 Message-ID: <702941.1591981259@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Thu, Jun 11, 2020 at 9:16 PM Tom Lane 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