From ba00e930ea48fa999267c8f3a30be7f7f30c3eec Mon Sep 17 00:00:00 2001 From: Murat Tuncer Date: Mon, 24 Dec 2018 22:31:51 +0300 Subject: [PATCH] Fix having clause bug for complex joins We update column attributes of various clauses for a query inluding target columns, select clauses when we introduce new range table entries in the query. It seems having clause column attributes were not updated. This fix resolves the issue --- .../distributed/planner/multi_physical_planner.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/distributed/planner/multi_physical_planner.c b/src/backend/distributed/planner/multi_physical_planner.c index 35766de01..e1a05ef93 100644 --- a/src/backend/distributed/planner/multi_physical_planner.c +++ b/src/backend/distributed/planner/multi_physical_planner.c @@ -691,6 +691,18 @@ BuildJobQuery(MultiNode *multiNode, List *dependedJobList) } } + /* set correct column attributes for having columns */ + if (updateColumnAttributes) + { + columnCell = NULL; + columnList = pull_var_clause_default((Node *) havingQual); + foreach(columnCell, columnList) + { + Var *column = (Var *) lfirst(columnCell); + UpdateColumnAttributes(column, rangeTableList, dependedJobList); + } + } + /* * Build the From/Where construct. We keep the where-clause list implicitly * AND'd, since both partition and join pruning depends on the clauses being