postgresql/src
Tom Lane 77a3be32f7 Fix mishandling of NaN counts in numeric_[avg_]combine.
When merging two NumericAggStates, the code missed adding the new
state's NaNcount unless its N was also nonzero; since those counts
are independent, this is wrong.

This would only have visible effect if some partial aggregate scans
found only NaNs while earlier ones found only non-NaNs; then we could
end up falsely deciding that there were no NaNs and fail to return a
NaN final result as expected.  That's pretty improbable, so it's no
surprise this hasn't been reported from the field.  Still, it's a bug.

I didn't try to produce a regression test that would show the bug,
but I did notice that these functions weren't being reached at all
in our regression tests, so I improved the tests to at least
exercise them.  With these additions, I see pretty complete code
coverage on the aggregation-related functions in numeric.c.

Back-patch to 9.6 where this code was introduced.  (I only added
the improved test case as far back as v10, though, since the
relevant part of aggregates.sql isn't there at all in 9.6.)
2020-06-11 17:38:42 -04:00
..
backend Fix mishandling of NaN counts in numeric_[avg_]combine. 2020-06-11 17:38:42 -04:00
bin pg_dump: Remove dead code 2020-06-11 14:19:32 +02:00
common Move frontend-side archive APIs from src/common/ to src/fe_utils/ 2020-06-11 15:48:46 +09:00
fe_utils Move frontend-side archive APIs from src/common/ to src/fe_utils/ 2020-06-11 15:48:46 +09:00
include Rework HashAgg GUCs. 2020-06-11 12:57:43 -07:00
interfaces Remove redundant grammar symbols 2020-06-10 22:58:46 +02:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Spelling adjustments 2020-06-09 10:41:41 +02:00
port Clear some style deviations. 2020-05-21 08:31:16 -07:00
template Fix compiler warning for ppoll() on Cygwin 2019-12-22 23:20:00 +01:00
test Fix mishandling of NaN counts in numeric_[avg_]combine. 2020-06-11 17:38:42 -04:00
timezone Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
tools Move frontend-side archive APIs from src/common/ to src/fe_utils/ 2020-06-11 15:48:46 +09:00
tutorial Update copyrights for 2020 2020-01-01 12:21:45 -05:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Update Unicode data to Unicode 13.0.0 and CLDR 37 2020-04-24 09:52:59 +02:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00