| From: | Richard Guo <rguo(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix eager aggregation below volatile join clauses |
| Date: | 2026-10-29 06:34:03 |
| Message-ID: | E1xMJi7-00000001DtG-22XZ@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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 <zhong950419(at)gmail(dot)com>
Reviewed-by: Manu <manuelreyesbravo(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAGRkXqSc_qtpuPm34qoS1z0LVx4+Hc+JcJkbDEVC=z2ai4VQ1w@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(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-10-29 08:11:26 | Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti |
| Previous Message | Jeff Davis | 2026-10-29 06:26:37 | pgsql: PG 19: Add migration note about tsearch & pg_trgm. |