postgresql/src/backend
Dean Rasheed ed3e1663c0 Fix division-by-zero error in to_char() with 'EEEE' format.
This fixes a long-standing bug when using to_char() to format a
numeric value in scientific notation -- if the value's exponent is
less than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced a
division-by-zero error.

The reason for this error was that get_str_from_var_sci() divides its
input by 10^exp, which it produced using power_var_int(). However, the
underflow test in power_var_int() causes it to return zero if the
result scale is too small. That's not a problem for power_var_int()'s
only other caller, power_var(), since that limits the rscale to 1000,
but in get_str_from_var_sci() the exponent can be much smaller,
requiring a much larger rscale. Fix by introducing a new function to
compute 10^exp directly, with no rscale limit. This also allows 10^exp
to be computed more efficiently, without any numeric multiplication,
division or rounding.

Discussion: https://postgr.es/m/CAEZATCWhojfH4whaqgUKBe8D5jNHB8ytzemL-PnRx+KCTyMXmg@mail.gmail.com
2021-08-05 09:35:46 +01:00
..
access Update minimum recovery point on truncation during WAL replay of abort record. 2021-07-29 01:35:52 +09:00
bootstrap Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:15 -07:00
catalog Make index_set_state_flags() transactional 2021-06-28 10:43:13 +09:00
commands Lock the extension during ALTER EXTENSION ADD/DROP. 2021-07-11 12:54:24 -04:00
executor Fix mishandling of resjunk columns in ON CONFLICT ... UPDATE tlists. 2021-05-10 11:02:30 -04:00
foreign Remove GetUserMappingId() and GetUserMappingById(). 2016-07-22 11:32:23 -04:00
lib Revert "Permit dump/reload of not-too-large >1GB tuples" 2016-12-06 12:46:03 -03:00
libpq Don't assume GSSAPI result strings are null-terminated. 2021-06-23 14:01:33 -04:00
main Install Windows crash dump handler before all else. 2017-11-12 14:31:04 -08:00
nodes Ensure that expandTableLikeClause() re-examines the same table. 2020-12-01 14:02:28 -05:00
optimizer Silence another gcc 11 warning. 2021-01-28 17:18:48 -05:00
parser Reject SELECT ... GROUP BY GROUPING SETS (()) FOR UPDATE. 2021-06-01 11:12:56 -04:00
po Translation updates 2021-05-10 14:24:16 +02:00
port Fix race condition in our Windows signal emulation. 2019-12-09 15:03:52 -05:00
postmaster Be more careful about barriers when releasing BackgroundWorkerSlots. 2021-05-15 12:21:06 -04:00
regex Fix another ancient bug in parsing of BRE-mode regular expressions. 2021-02-18 22:38:55 -05:00
replication Fix decoding of speculative aborts. 2021-06-15 09:18:38 +05:30
rewrite Reject cases where a query in WITH rewrites to just NOTIFY. 2021-07-09 11:02:26 -04:00
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Fix check for conflicting session- vs transaction-level locks. 2021-07-24 18:35:52 -04:00
tcop Refactor CHECK_FOR_INTERRUPTS() to add flexibility. 2021-05-14 12:54:26 -04:00
tsearch Don't leak compiled regex(es) when an ispell cache entry is dropped. 2021-03-18 21:44:43 -04:00
utils Fix division-by-zero error in to_char() with 'EEEE' format. 2021-08-05 09:35:46 +01:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile Fix make rules that generate multiple output files. 2018-03-23 13:45:38 -04:00
nls.mk Translation updates 2018-08-06 19:44:29 +02:00