pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. 7+ messages / 1 participants [nested] [flat]
* pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. @ 2025-09-17 20:33 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-17 20:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@outlook.com> Author: Tom Lane <tgl@sss.pgh.pa.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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. @ 2025-09-17 20:33 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-17 20:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@outlook.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19055-6970cfa8556a394d@postgresql.org Backpatch-through: 13 Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/31bf0963208f1a5121a81aa7c17b4e55bfdc5596 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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. @ 2025-09-17 20:33 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-17 20:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@outlook.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19055-6970cfa8556a394d@postgresql.org Backpatch-through: 13 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7df74e635e65e880c308d52e11d3d603aa1ee9c6 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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. @ 2025-09-17 20:33 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-17 20:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@outlook.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19055-6970cfa8556a394d@postgresql.org Backpatch-through: 13 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/b0cc0a71e0a0a760f54c72edb8cd000e4555442b 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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. @ 2025-09-17 20:33 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-17 20:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@outlook.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19055-6970cfa8556a394d@postgresql.org Backpatch-through: 13 Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b649ef2446a46a800bc031787de1e03cf64fe3d7 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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. @ 2025-09-17 20:33 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-17 20:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@outlook.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19055-6970cfa8556a394d@postgresql.org Backpatch-through: 13 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/afd18f27615b0e452373acbc8de2e5282dfeb31b 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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. @ 2025-09-17 20:33 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2025-09-17 20:33 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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@outlook.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19055-6970cfa8556a394d@postgresql.org Backpatch-through: 13 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4eab456494e3fc20dc0a10dac0466d344c9fbfaf 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(-) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2025-09-17 20:33 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-09-17 20:33 pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-17 20:33 pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-17 20:33 pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-17 20:33 pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-17 20:33 pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-17 20:33 pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. Tom Lane <tgl@sss.pgh.pa.us> 2025-09-17 20:33 pgsql: Calculate agglevelsup correctly when Aggref contains a CTE. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox