aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-11-10 11:31:56 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-11-10 11:31:56 -0500
commit7defc3b97a31537547053946808a83e7234d1b61 (patch)
tree67007796858e47b04d104d2fb0e3a773e68e26dc /src
parentc32e05bce74cbb965f8f847d65caa20947b4d2bb (diff)
downloadpostgresql-7defc3b97a31537547053946808a83e7234d1b61.tar.gz
postgresql-7defc3b97a31537547053946808a83e7234d1b61.zip
Fix partial aggregation for the case of a degenerate GROUP BY clause.
The plan generated for sorted partial aggregation with "GROUP BY constant" included a Sort node with no sort keys, which the executor does not like. Per report from Steve Randall. I'd add a regression test case if I could think of a compact one, but it doesn't seem worth expending lots of cycles on. Report: <CABVd52UAdGXpg_rCk46egpNKYdXOzCjuJ1zG26E2xBe_8bj+Fg@mail.gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/planner.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index b2656283251..d84f1b7dd8d 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -3714,11 +3714,11 @@ create_grouping_paths(PlannerInfo *root,
&total_groups);
/*
- * Gather is always unsorted, so we'll need to sort, unless
- * there's no GROUP BY clause, in which case there will only be a
- * single group.
+ * Since Gather's output is always unsorted, we'll need to sort,
+ * unless there's no GROUP BY clause or a degenerate (constant)
+ * one, in which case there will only be a single group.
*/
- if (parse->groupClause)
+ if (root->group_pathkeys)
path = (Path *) create_sort_path(root,
grouped_rel,
path,