From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix loss of fractional digits for large values in cash_numeric() |
Date: | 2019-07-26 16:00:46 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix loss of fractional digits for large values in cash_numeric().
Money values exceeding about 18 digits (depending on lc_monetary)
could be inaccurately converted to numeric, due to select_div_scale()
deciding it didn't need to compute any fractional digits. Force
its hand by setting the dscale of one division input to equal the
number of fractional digits we need.
In passing, rearrange the logic to not do useless work in locales
where money values are considered integral.
Per bug #15925 from Slawomir Chodnicki. Back-patch to all supported
branches.
Discussion: https://postgr.es/m/[email protected]
Branch
------
REL9_4_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/81b29c87114cdcc2ff1a9247124c59d94d20a237
Modified Files
--------------
src/backend/utils/adt/cash.c | 58 ++++++++++++++++++++++++-------------
src/test/regress/expected/money.out | 41 +++++++++++++++++++++++++-
src/test/regress/sql/money.sql | 12 +++++++-
3 files changed, 89 insertions(+), 22 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-07-26 17:07:37 | pgsql: Tweak our special-case logic for the IANA "Factory" timezone. |
Previous Message | Peter Eisentraut | 2019-07-26 08:55:57 | pgsql: doc: Make libpq documentation navigable between functions |