diff options
author | Andres Freund <andres@anarazel.de> | 2015-07-26 15:17:44 +0200 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2015-07-26 16:46:27 +0200 |
commit | 144666f65b500fef864bca318f6245b03c0f457c (patch) | |
tree | 438e5aa4b1b64a541e3f75fa284acbb6edba9846 /src/backend/optimizer/plan/planner.c | |
parent | cf80ddee57103bb3b454c1607d100a4551d7a48c (diff) | |
download | postgresql-144666f65b500fef864bca318f6245b03c0f457c.tar.gz postgresql-144666f65b500fef864bca318f6245b03c0f457c.zip |
Build column mapping for grouping sets in all required cases.
The previous coding frequently failed to fail because for one it's
unusual to have rollup clauses with one column, and for another
sometimes the wrong mapping didn't cause obvious problems.
Author: Jeevan Chalke
Reviewed-By: Andrew Gierth
Discussion: CAM2+6=W=9=hQOipH0HAPbkun3Z3TFWij_EiHue0_6UX=oR=1kw@mail.gmail.com
Backpatch: 9.5, where grouping sets were introduced
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index b95cc95e5d9..11678388fab 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -2401,13 +2401,8 @@ build_grouping_chain(PlannerInfo *root, * Prepare the grpColIdx for the real Agg node first, because we may need * it for sorting */ - if (list_length(rollup_groupclauses) > 1) - { - Assert(rollup_lists && llast(rollup_lists)); - - top_grpColIdx = - remap_groupColIdx(root, llast(rollup_groupclauses)); - } + if (parse->groupingSets) + top_grpColIdx = remap_groupColIdx(root, llast(rollup_groupclauses)); /* * If we need a Sort operation on the input, generate that. |