From d2ea4043d44b9cfc66404ff621b3b6d54071bbb6 Mon Sep 17 00:00:00 2001 From: Colm Date: Thu, 18 Sep 2025 13:54:14 +0100 Subject: [PATCH] Postgres 18: fix 'column does not exist' errors in grouping regress tests. (#8199) DESCRIPTION: Fix 'column does not exist' errors in grouping regress tests. Postgres 18's GROUP RTE was being ignored by query pushdown planning when constructing the query tree for the worker subquery. The solution is straightforward - ensure the worker subquery tree has the same groupRTE property as the original query. Postgres ruleutils then does the right thing when generating the pushed down query. Fixes category 1 in #7992. --- src/backend/distributed/planner/query_pushdown_planning.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/planner/query_pushdown_planning.c b/src/backend/distributed/planner/query_pushdown_planning.c index 84f94dbb6..f7232e2bb 100644 --- a/src/backend/distributed/planner/query_pushdown_planning.c +++ b/src/backend/distributed/planner/query_pushdown_planning.c @@ -2029,7 +2029,9 @@ SubqueryPushdownMultiNodeTree(Query *originalQuery) pushedDownQuery->setOperations = copyObject(queryTree->setOperations); pushedDownQuery->querySource = queryTree->querySource; pushedDownQuery->hasSubLinks = queryTree->hasSubLinks; - +#if PG_VERSION_NUM >= PG_VERSION_18 + pushedDownQuery->hasGroupRTE = queryTree->hasGroupRTE; +#endif MultiTable *subqueryNode = MultiSubqueryPushdownTable(pushedDownQuery); SetChild((MultiUnaryNode *) subqueryCollectNode, (MultiNode *) subqueryNode);