Skip to content

Commit e1b449b

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 0b1b503 commit e1b449b

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
@@ -3741,11 +3741,11 @@ create_grouping_paths(PlannerInfo *root,
37413741
&total_groups);
37423742

37433743
/*
3744-
* Gather is always unsorted, so we'll need to sort, unless
3745-
* there's no GROUP BY clause, in which case there will only be a
3746-
* single group.
3744+
* Since Gather's output is always unsorted, we'll need to sort,
3745+
* unless there's no GROUP BY clause or a degenerate (constant)
3746+
* one, in which case there will only be a single group.
37473747
*/
3748-
if (parse->groupClause)
3748+
if (root->group_pathkeys)
37493749
path = (Path *) create_sort_path(root,
37503750
grouped_rel,
37513751
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