aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/xml.c
diff options
context:
space:
mode:
authorDean Rasheed <dean.a.rasheed@gmail.com>2024-07-08 17:55:31 +0100
committerDean Rasheed <dean.a.rasheed@gmail.com>2024-07-08 17:55:31 +0100
commita3c0124f69ffd2a299f099d4037ba8c6d2293aba (patch)
tree0631d8c32a0836b73b7c4a431f32ae4a5b45b29f /src/backend/utils/adt/xml.c
parentc2342a925b7042f3e4d8440e66bd7b61d80a961c (diff)
downloadpostgresql-a3c0124f69ffd2a299f099d4037ba8c6d2293aba.tar.gz
postgresql-a3c0124f69ffd2a299f099d4037ba8c6d2293aba.zip
Fix scale clamping in numeric round() and trunc().
The numeric round() and trunc() functions clamp the scale argument to the range between +/- NUMERIC_MAX_RESULT_SCALE (2000), which is much smaller than the actual allowed range of type numeric. As a result, they return incorrect results when asked to round/truncate more than 2000 digits before or after the decimal point. Fix by using the correct upper and lower scale limits based on the actual allowed (and documented) range of type numeric. While at it, use the new NUMERIC_WEIGHT_MAX constant instead of SHRT_MAX in all other overflow checks, and fix a comment thinko in power_var() introduced by e54a758d24 -- the minimum value of ln_dweight is -NUMERIC_DSCALE_MAX (-16383), not -SHRT_MAX, though this doesn't affect the point being made in the comment, that the resulting local_rscale value may exceed NUMERIC_MAX_DISPLAY_SCALE (1000). Back-patch to all supported branches. Dean Rasheed, reviewed by Joel Jacobson. Discussion: https://postgr.es/m/CAEZATCXB%2BrDTuMjhK5ZxcouufigSc-X4tGJCBTMpZ3n%3DxxQuhg%40mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/xml.c')
0 files changed, 0 insertions, 0 deletions