pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make int64_div_fast_to_numeric() more robust.
Date: Fri, 03 Feb 2023 11:15:51 +0000
Message-ID: <E1pNu2o-001NOx-KZ@gemulon.postgresql.org> (raw)

Make int64_div_fast_to_numeric() more robust.

The prior coding of int64_div_fast_to_numeric() had a number of bugs
that would cause it to fail under different circumstances, such as
with log10val2 <= 0, or log10val2 a multiple of 4, or in the "slow"
numeric path with log10val2 >= 10.

None of those could be triggered by any of our current code, which
only uses log10val2 = 3 or 6. However, they made it a hazard for any
future code that might use it. Also, since this is exported by
numeric.c, users writing their own C code might choose to use it.

Therefore fix, and back-patch to v14, where it was introduced.

Dean Rasheed, reviewed by Tom Lane.

Discussion: https://postgr.es/m/CAEZATCW8gXgW0tgPxPgHDPhVX71%2BSWFRkhnXy%2BTfGDsKLepu2g%40mail.gmail.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4f74741a5cea38228fdb0fb2967fa2137ea02cbf

Modified Files
--------------
src/backend/utils/adt/numeric.c | 80 +++++++++++++++++++++++++++--------------
1 file changed, 54 insertions(+), 26 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1pNu2o-001NOx-KZ@gemulon.postgresql.org>
Permalink:  ../E1pNu2o-001NOx-KZ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pNu2o-001NOx-KZ@gemulon.postgresql.org

 · 

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: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Make int64_div_fast_to_numeric() more robust.
  In-Reply-To: <E1pNu2o-001NOx-KZ@gemulon.postgresql.org>
  References: <E1pNu2o-001NOx-KZ@gemulon.postgresql.org>

* 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