postgresql/src/backend
Dean Rasheed 43644bd3b2 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:30:37 +01:00
..
access Update minimum recovery point on truncation during WAL replay of abort record. 2021-07-29 01:35:00 +09:00
bootstrap Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
catalog Make index_set_state_flags() transactional 2021-06-28 10:43:01 +09:00
commands Don't allow to set replication slot_name as ''. 2021-07-19 11:15:03 +05:30
executor Fix usage of "tableoid" in GENERATED expressions. 2021-05-21 15:02:07 -04:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit jit: Don't inline functions that access thread-locals. 2021-07-22 15:07:29 +12:00
lib Fix typo in comment 2021-04-20 14:36:44 +02:00
libpq Don't assume GSSAPI result strings are null-terminated. 2021-06-23 14:01:32 -04:00
main Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00
nodes Ensure that expandTableLikeClause() re-examines the same table. 2020-12-01 14:02:28 -05:00
optimizer Fix planner's row-mark code for inheritance from a foreign table. 2021-06-02 14:38:14 -04:00
parser Reject SELECT ... GROUP BY GROUPING SETS (()) FOR UPDATE. 2021-06-01 11:12:56 -04:00
partitioning Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:24:24 +09:00
po Translation updates 2021-05-10 14:30:04 +02:00
port Fix race condition in our Windows signal emulation. 2019-12-09 15:03:51 -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 Don't try to print data type names in slot_store_error_callback(). 2021-07-02 16:04:54 -04:00
rewrite Reject cases where a query in WITH rewrites to just NOTIFY. 2021-07-09 11:02:26 -04:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Use correct spelling of statistics kind 2021-03-23 04:57:45 +01:00
storage Fix check for conflicting session- vs transaction-level locks. 2021-07-24 18:35:52 -04:00
tcop Use elog, not Assert, to report failure to provide an outer snapshot. 2021-07-31 11:50:14 -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:30:37 +01:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
nls.mk Translation updates 2020-08-10 15:21:18 +02:00