postgresql/src/backend/utils/adt
Dean Rasheed f025f2390e Prevent numeric overflows in parallel numeric aggregates.
Formerly various numeric aggregate functions supported parallel
aggregation by having each worker convert partial aggregate values to
Numeric and use numeric_send() as part of serializing their state.
That's problematic, since the range of Numeric is smaller than that of
NumericVar, so it's possible for it to overflow (on either side of the
decimal point) in cases that would succeed in non-parallel mode.

Fix by serializing NumericVars instead, to avoid the overflow risk and
ensure that parallel and non-parallel modes work the same.

A side benefit is that this improves the efficiency of the
serialization/deserialization code, which can make a noticeable
difference to performance with large numbers of parallel workers.

No back-patch due to risk from changing the binary format of the
aggregate serialization states, as well as lack of prior field
complaints and low probability of such overflows in practice.

Patch by me. Thanks to David Rowley for review and performance
testing, and Ranier Vilela for an additional suggestion.

Discussion: https://postgr.es/m/CAEZATCUmeFWCrq2dNzZpRj5+6LfN85jYiDoqm+ucSXhb9U2TbA@mail.gmail.com
2021-07-05 10:16:42 +01:00
..
.gitignore Revert "Add gitignore entries for jsonpath_gram.h" 2019-03-23 00:19:34 +01:00
acl.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
amutils.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_expanded.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_typanalyze.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_userfuncs.c Prevent integer overflows in array subscripting calculations. 2021-05-10 10:44:38 -04:00
arrayfuncs.c Prevent integer overflows in array subscripting calculations. 2021-05-10 10:44:38 -04:00
arraysubs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
arrayutils.c Prevent integer overflows in array subscripting calculations. 2021-05-10 10:44:38 -04:00
ascii.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
bool.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
cash.c Expose internal function for converting int64 to numeric 2020-09-09 20:16:28 +02:00
char.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
cryptohashfuncs.c Add result size as argument of pg_cryptohash_final() for overflow checks 2021-02-15 10:18:34 +09:00
date.c Silence some Coverity warnings and improve code consistency. 2021-04-11 17:02:04 -04:00
datetime.c Revert use singular for -1 (commits 9ee7d533da and 5da9868ed9 2021-05-01 10:42:44 -04:00
datum.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
dbsize.c Ensure pg_filenode_relation(0, 0) returns NULL. 2021-06-12 13:29:24 -04:00
domains.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
encode.c Rework refactoring of hex and encoding routines 2021-01-14 11:13:24 +09:00
enum.c Rename "enum blacklist" to "uncommitted enums". 2021-01-05 12:38:48 +13:00
expandeddatum.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
expandedrecord.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
float.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
format_type.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
formatting.c Fix out-of-bound memory access for interval -> char conversion 2021-04-12 11:30:50 +09:00
genfile.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
geo_ops.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
geo_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
geo_spgist.c Fix more confusion in SP-GiST. 2021-04-04 17:57:07 -04:00
inet_cidr_ntop.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
inet_net_pton.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
int8.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
int.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
json.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonb_gin.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonb_op.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonb_util.c Implementation of subscripting for jsonb 2021-01-31 23:50:40 +03:00
jsonb.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonbsubs.c Adjust locations which have an incorrect copyright year 2021-06-04 12:19:50 +12:00
jsonfuncs.c Fix typos and grammar in documentation and code comments 2021-04-09 13:53:07 +09:00
jsonpath_exec.c Fix some typos, grammar and style in docs and comments 2021-02-24 16:13:17 +09:00
jsonpath_gram.y Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonpath_scan.l Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonpath.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
levenshtein.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
like_match.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
like_support.c Avoid divide-by-zero in regex_selectivity() with long fixed prefix. 2021-02-12 16:26:47 -05:00
like.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
lockfuncs.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
mac8.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
mac.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
Makefile Use "-I." in directories holding Bison parsers, for Oracle compilers. 2021-04-12 19:24:41 -07:00
mcxtfuncs.c Reorder superuser check in pg_log_backend_memory_contexts() 2021-06-08 08:53:12 +09:00
misc.c Do not rely on pgstat.h to indirectly include storage/ headers. 2021-04-02 20:02:47 -07:00
multirangetypes_selfuncs.c Fixes for multirange selectivity estimation 2021-06-29 23:18:22 +03:00
multirangetypes.c Message style improvements 2021-06-28 08:36:44 +02:00
name.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
network_gist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
network_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
network_spgist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
network.c Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
numeric.c Prevent numeric overflows in parallel numeric aggregates. 2021-07-05 10:16:42 +01:00
numutils.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
oid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
oracle_compat.c Add bytea equivalents of ltrim() and rtrim(). 2021-01-18 15:11:32 -05:00
orderedsetaggs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
partitionfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_locale.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
pg_lsn.c Simplify printing of LSNs 2021-02-23 10:27:02 +01:00
pg_upgrade_support.c Revert per-index collation version tracking feature. 2021-05-07 21:10:11 +12:00
pgstatfuncs.c Replace magic constants used in pg_stat_get_replication_slot(). 2021-06-30 11:29:53 +05:30
pseudotypes.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
quote.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_gist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_spgist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_typanalyze.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
rangetypes.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
regexp.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
regproc.c Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
ri_triggers.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
rowtypes.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
ruleutils.c Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
selfuncs.c Reject SELECT ... GROUP BY GROUPING SETS (()) FOR UPDATE. 2021-06-01 11:12:56 -04:00
tid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
timestamp.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
trigfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsginidx.c Convert tsginidx.c's GIN indexing logic to fully ternary operation. 2021-02-16 12:07:14 -05:00
tsgistidx.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_cleanup.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_gist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_op.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_rewrite.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_util.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery.c Make websearch_to_tsquery() parse text in quotes as a single token 2021-05-03 04:18:19 +03:00
tsrank.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsvector_op.c Convert tsginidx.c's GIN indexing logic to fully ternary operation. 2021-02-16 12:07:14 -05:00
tsvector_parser.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsvector.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
uuid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
varbit.c Add bit_count SQL function 2021-03-23 10:13:58 +01:00
varchar.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
varlena.c Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
version.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
windowfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
xid8funcs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
xid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
xml.c Refactor some error messages for easier translation 2021-05-12 07:42:51 +02:00