pgsql: Calculate agglevelsup correctly when Aggref contains a CTE.

2025-09-17 Thread Tom Lane
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. Oth

pgsql: Calculate agglevelsup correctly when Aggref contains a CTE.

2025-09-17 Thread Tom Lane
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. Oth

pgsql: Calculate agglevelsup correctly when Aggref contains a CTE.

2025-09-17 Thread Tom Lane
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. Oth

pgsql: Calculate agglevelsup correctly when Aggref contains a CTE.

2025-09-17 Thread Tom Lane
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. Oth

pgsql: Calculate agglevelsup correctly when Aggref contains a CTE.

2025-09-17 Thread Tom Lane
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. Oth

pgsql: Calculate agglevelsup correctly when Aggref contains a CTE.

2025-09-17 Thread Tom Lane
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. Oth

pgsql: Calculate agglevelsup correctly when Aggref contains a CTE.

2025-09-17 Thread Tom Lane
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. Oth