1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Fix numeric_mul() overflow due to too many digits after decimal point.

This fixes an overflow error when using the numeric * operator if the
result has more than 16383 digits after the decimal point by rounding
the result. Overflow errors should only occur if the result has too
many digits *before* the decimal point.

Discussion: https://postgr.es/m/CAEZATCUmeFWCrq2dNzZpRj5+6LfN85jYiDoqm+ucSXhb9U2TbA@mail.gmail.com
This commit is contained in:
Dean Rasheed
2021-07-10 12:45:00 +01:00
parent 9ffad7ae7f
commit 06883d58ff
3 changed files with 17 additions and 1 deletions

View File

@@ -2145,6 +2145,12 @@ select 4769999999999999999999999999999999999999999999999999999999999999999999999
47699999999999999999999999999999999999999999999999999999999999999999999999999999999999985230000000000000000000000000000000000000000000000000000000000000000000000000000000000001
(1 row)
select trim_scale((0.1 - 2e-16383) * (0.1 - 3e-16383));
trim_scale
------------
0.01
(1 row)
--
-- Test some corner cases for division
--

View File

@@ -1044,6 +1044,8 @@ select 4770999999999999999999999999999999999999999999999999999999999999999999999
select 4769999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999;
select trim_scale((0.1 - 2e-16383) * (0.1 - 3e-16383));
--
-- Test some corner cases for division
--