diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index dad35e5..dab1251 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -1799,7 +1799,8 @@ grouping_planner(PlannerInfo *root, bool inheritance_update, * target list is already what we need it to be, just leave * this partial path alone. */ - if (equal(scanjoin_target->exprs, subpath->pathtarget->exprs)) + if (equal(scanjoin_target->exprs, subpath->pathtarget->exprs) && + equal(scanjoin_target->sortgrouprefs, subpath->pathtarget->sortgrouprefs)) continue; Assert(subpath->param_info == NULL); diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out index 3c90640..1201b27 100644 --- a/src/test/regress/expected/select_parallel.out +++ b/src/test/regress/expected/select_parallel.out @@ -71,6 +71,21 @@ select length(stringu1) from tenk1 group by length(stringu1); 6 (1 row) +explain (costs off) + select stringu1, count(*) from tenk1 group by stringu1 order by stringu1; + QUERY PLAN +---------------------------------------------------- + Sort + Sort Key: stringu1 + -> Finalize HashAggregate + Group Key: stringu1 + -> Gather + Workers Planned: 4 + -> Partial HashAggregate + Group Key: stringu1 + -> Parallel Seq Scan on tenk1 +(9 rows) + -- test that parallel plan for aggregates is not selected when -- target list contains parallel restricted clause. explain (costs off) diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql index a8cd993..19556e4 100644 --- a/src/test/regress/sql/select_parallel.sql +++ b/src/test/regress/sql/select_parallel.sql @@ -29,6 +29,9 @@ explain (costs off) select length(stringu1) from tenk1 group by length(stringu1); select length(stringu1) from tenk1 group by length(stringu1); +explain (costs off) + select stringu1, count(*) from tenk1 group by stringu1 order by stringu1; + -- test that parallel plan for aggregates is not selected when -- target list contains parallel restricted clause. explain (costs off)