Skip to content

Commit 7defc3b

Browse files
committed
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>
1 parent c32e05b commit 7defc3b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,11 +3714,11 @@ create_grouping_paths(PlannerInfo *root,
37143714
&total_groups);
37153715

37163716
/*
3717-
* Gather is always unsorted, so we'll need to sort, unless
3718-
* there's no GROUP BY clause, in which case there will only be a
3719-
* single group.
3717+
* Since Gather's output is always unsorted, we'll need to sort,
3718+
* unless there's no GROUP BY clause or a degenerate (constant)
3719+
* one, in which case there will only be a single group.
37203720
*/
3721-
if (parse->groupClause)
3721+
if (root->group_pathkeys)
37223722
path = (Path *) create_sort_path(root,
37233723
grouped_rel,
37243724
path,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy