From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Fix numeric_mul() overflow due to too many digits after decimal
Date: Sat, 10 Jul 2021 13:30:42 -0400
Message-ID: <2407772.1625938242@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEZATCXV6bdUUDckMVD=PtHXRUKTPZeHpy538xWY+wW=DZKYhg@mail.gmail.com>
References: <E1m2BYl-0007cF-AL@gemulon.postgresql.org>
<2387728.1625929272@sss.pgh.pa.us>
<CAEZATCXV6bdUUDckMVD=PtHXRUKTPZeHpy538xWY+wW=DZKYhg@mail.gmail.com>
[ moving to pghackers for wider visibility ]
Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> On Sat, 10 Jul 2021 at 16:01, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 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.
TBH, I don't agree. I think this is strictly worse than what we
did before, and we should just revert it. It's no longer possible
to reason about what numeric multiplication will do. I think
throwing an error if we can't represent the result exactly is a
preferable behavior. If you don't want exact results, use float8.
regards, tom lane
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, pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Fix numeric_mul() overflow due to too many digits after decimal
In-Reply-To: <2407772.1625938242@sss.pgh.pa.us>
References: <E1m2BYl-0007cF-AL@gemulon.postgresql.org> <2387728.1625929272@sss.pgh.pa.us> <CAEZATCXV6bdUUDckMVD=PtHXRUKTPZeHpy538xWY+wW=DZKYhg@mail.gmail.com> <2407772.1625938242@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