Fix handling of NULLs returned by aggregate combine functions.
authorAndres Freund
Fri, 24 Nov 2017 01:13:09 +0000 (17:13 -0800)
committerAndres Freund
Fri, 24 Nov 2017 01:15:36 +0000 (17:15 -0800)
commitc60b898453f9b4d7de94c8e88bf08e930d117958
tree8cb715d13f892fe7e8d16e6d3c34776234d8416c
parent188140500e42a4266f01b683697ac4f787052f3e
Fix handling of NULLs returned by aggregate combine functions.

When strict aggregate combine functions, used in multi-stage/parallel
aggregation, returned NULL, we didn't check for that, invoking the
combine function with NULL the next round, despite it being strict.

The equivalent code invoking normal transition functions has a check
for that situation, which did not get copied in a7de3dc5c346. Fix the
bug by adding the equivalent check.

Based on a quick look I could not find any strict combine functions in
core actually returning NULL, and it doesn't seem very likely external
users have done so. So this isn't likely to have caused issues in
practice.

Add tests verifying transition / combine functions returning NULL is
tested.

Reported-By: Andres Freund
Author: Andres Freund
Discussion: https://postgr.es/m/20171121033642[email protected]
Backpatch: 9.6, where parallel aggregation was introduced
src/backend/executor/nodeAgg.c
src/test/regress/expected/aggregates.out
src/test/regress/sql/aggregates.sql