Fix eager aggregation below volatile join clauses

Eager aggregation could push a partial aggregation down to a relation
that is later joined using a join clause containing volatile
functions.  The clause is then evaluated once per group rather than
once per input row, which changes the number of times the function is
executed.

To fix, refuse to build grouped paths for a relation if any of its
join clauses contains volatile functions.

Back-patch to v19, where eager aggregation was introduced.

Author: shihao zhong <[email protected]>
Reviewed-by: Manu <[email protected]>
Discussion: 
https://postgr.es/m/CAGRkXqSc_qtpuPm34qoS1z0LVx4+Hc+JcJkbDEVC=z2ai4v...@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0c6e0437110dd6ceb14fdca5b323bc1b058a13cf

Modified Files
--------------
src/backend/optimizer/util/relnode.c          | 13 +++++++++++++
src/test/regress/expected/eager_aggregate.out | 20 ++++++++++++++++++++
src/test/regress/sql/eager_aggregate.sql      |  7 +++++++
3 files changed, 40 insertions(+)

Reply via email to