pgsql: Fix loss of fractional digits for large values incash_numeric()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix loss of fractional digits for large values incash_numeric()
Дата
Msg-id E1hr2eE-0004R8-RU@gemulon.postgresql.org
обсуждение исходный текст
Список 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/15925-da9953e2674bb5c8@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b9d2c5c7ac800bf20ea6cd4c556b6b3305863a8e

Modified Files
--------------
src/backend/utils/adt/cash.c        | 56 ++++++++++++++++++++++++-------------
src/test/regress/expected/money.out | 16 ++++++++++-
src/test/regress/sql/money.sql      |  6 +++-
3 files changed, 57 insertions(+), 21 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: doc: Make libpq documentation navigable between functions
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Tweak our special-case logic for the IANA "Factory" timezone.