]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Prevent sharing transition states between ordered-set aggregates.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Oct 2017 02:18:01 +0000 (22:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Oct 2017 02:18:01 +0000 (22:18 -0400)
commit604723d29a86f38551e43997e6f40daa94f54b27
tree1862aff0f75091a667e1af4d649eee77862a19ef
parent61ace8fe7fe82dc04c1de493a414597989f05e56
Prevent sharing transition states between ordered-set aggregates.

This ought to work, but the built-in OSAs are not capable of coping,
because their final-functions destructively modify their transition
state (specifically, the contained tuplesort object).  That was fine
when those functions were written, but commit 804163bc2 moved the
goalposts without telling orderedsetaggs.c.

We should fix the built-in OSAs to support this, but it will take
a little work, especially if we don't want to sacrifice performance
in the normal non-shared-state case.  Given that it took a year after
9.6 release for anyone to notice this bug, we should not prioritize
sharable-state over nonsharable-state performance.  And a proper fix
is likely to be more complicated than we'd want to back-patch, too.

Therefore, let's just put in this stop-gap patch to prevent nodeAgg.c
from choosing to use shared state for OSAs.  We can revert it in HEAD
when we get a better fix.

Report from Lukas Eder, diagnosis by me, patch by David Rowley.
Back-patch to 9.6 where the problem was introduced.

Discussion: https://postgr.es/m/CAB4ELO5RZhOamuT9Xsf72ozbenDLLXZKSk07FiSVsuJNZB861A@mail.gmail.com
src/backend/executor/nodeAgg.c
src/test/regress/expected/aggregates.out
src/test/regress/sql/aggregates.sql