summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/createplan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r--src/backend/optimizer/plan/createplan.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 0775a676d05..6fde8322277 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -1042,6 +1042,7 @@ create_unique_plan(PlannerInfo *root, UniquePath *best_path)
numGroupCols,
groupColIdx,
groupOperators,
+ NIL,
numGroups,
subplan);
}
@@ -4492,6 +4493,7 @@ Agg *
make_agg(PlannerInfo *root, List *tlist, List *qual,
AggStrategy aggstrategy, const AggClauseCosts *aggcosts,
int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators,
+ List *groupingSets,
long numGroups,
Plan *lefttree)
{
@@ -4521,10 +4523,12 @@ make_agg(PlannerInfo *root, List *tlist, List *qual,
* group otherwise.
*/
if (aggstrategy == AGG_PLAIN)
- plan->plan_rows = 1;
+ plan->plan_rows = groupingSets ? list_length(groupingSets) : 1;
else
plan->plan_rows = numGroups;
+ node->groupingSets = groupingSets;
+
/*
* We also need to account for the cost of evaluation of the qual (ie, the
* HAVING clause) and the tlist. Note that cost_qual_eval doesn't charge
@@ -4545,6 +4549,7 @@ make_agg(PlannerInfo *root, List *tlist, List *qual,
plan->qual = qual;
plan->targetlist = tlist;
+
plan->lefttree = lefttree;
plan->righttree = NULL;