From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. |
Date: | 2025-09-17 20:33:10 |
Message-ID: | E1uyypy-001Duf-0u@gemulon.postgresql.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Calculate agglevelsup correctly when Aggref contains a CTE.
If an aggregate function call contains a sub-select that has
an RTE referencing a CTE outside the aggregate, we must treat
that reference like a Var referencing the CTE's query level
for purposes of determining the aggregate's level. Otherwise
we might reach the nonsensical conclusion that the aggregate
should be evaluated at some query level higher than the CTE,
ending in a planner error or a broken plan tree that causes
executor failures.
Bug: #19055
Reported-by: BugForge <dllggyx(at)outlook(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/19055-6970cfa8556a394d@postgresql.org
Backpatch-through: 13
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/e830896c16ee9ea2ba4eaa8a49b6bb3079505003
Modified Files
--------------
src/backend/parser/parse_agg.c | 28 +++++++++++++++++++++++++++-
src/test/regress/expected/with.out | 34 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/with.sql | 14 ++++++++++++++
3 files changed, 75 insertions(+), 1 deletion(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-09-17 23:49:20 | Re: pgsql: Move named LWLock tranche requests to shared memory. |
Previous Message | Nathan Bossart | 2025-09-17 14:34:24 | Re: pgsql: Move named LWLock tranche requests to shared memory. |