pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix numeric_mul() overflow due to too many digits after decimal
Date: Sat, 10 Jul 2021 11:01:12 -0400
Message-ID: <2387728.1625929272@sss.pgh.pa.us> (raw)
In-Reply-To: <E1m2BYl-0007cF-AL@gemulon.postgresql.org>
References: <E1m2BYl-0007cF-AL@gemulon.postgresql.org>

Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> This fixes an overflow error when using the numeric * operator if the
> result has more than 16383 digits after the decimal point by rounding
> the result. Overflow errors should only occur if the result has too
> many digits *before* the decimal point.

I think this needs a bit more thought.  Before, a case like
	select 1e-16000 * 1e-16000;
produced
	ERROR:  value overflows numeric format
Now you get an exact zero (with a lot of trailing zeroes, but still
it's just zero).  Doesn't that represent catastrophic loss of
precision?

In general, I'm disturbed that we just threw away the previous
promise that numeric multiplication results were exact.  That
seems like a pretty fundamental property --- which is stated
in so many words in the manual, btw --- and I'm not sure I want
to give it up.

			regards, tom lane





view thread (11+ messages)  latest in thread

Message-ID: <2387728.1625929272@sss.pgh.pa.us>
Permalink:  ../2387728.1625929272@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2387728.1625929272@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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Fix numeric_mul() overflow due to too many digits after decimal
  In-Reply-To: <2387728.1625929272@sss.pgh.pa.us>
  References: <E1m2BYl-0007cF-AL@gemulon.postgresql.org> <2387728.1625929272@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