From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | Re: pgsql: Fix numeric_mul() overflow due to too many digits after decimal |
Date: | 2021-07-10 17:03:54 |
Message-ID: | CAEZATCXV6bdUUDckMVD=PtHXRUKTPZeHpy538xWY+wW=DZKYhg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
On Sat, 10 Jul 2021 at 16:01, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> 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?
Hmm, "overflow" isn't a great result for that case either. Zero is the
closest we can get to the exact result with a fixed number of digits
after the decimal point.
> 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.
Perhaps we should amend the statement about numeric multiplication to
say that it's exact within the limits of the numeric type's supported
scale, which we also document in the manual as 16383.
That seems a lot better than throwing an overflow error for a result
that isn't very big, which limits what's possible with numeric
multiplication to much less than 16383 digits.
Regards,
Dean
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-07-10 17:19:48 | pgsql: Fix busted test for ldap_initialize. |
Previous Message | Tom Lane | 2021-07-10 15:01:12 | Re: pgsql: Fix numeric_mul() overflow due to too many digits after decimal |
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2021-07-10 17:08:53 | Re: Enhanced error message to include hint messages for redundant options error |
Previous Message | Fabien COELHO | 2021-07-10 16:55:36 | Re: psql - factor out echo code |