From 90dbc5670600679e81e0d38f7a624dd3e96ceec6 Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Tue, 6 Mar 2018 13:26:35 -0500
Subject: [PATCH 2/3] Rejigger test for grouped_rel->pathlist == NIL.

The previous coding made this depend on child_data, but it seems to me that
it actually depends on isPartialAgg.  If isPartialAgg = false, then we
should have created at least one path for grouped_rel; otherwise, we will
not have done so.
---
 src/backend/optimizer/plan/planner.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index a3c4e106ef..934c9d322c 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -3878,24 +3878,13 @@ create_grouping_paths(PlannerInfo *root,
 								  partially_grouped_rel, agg_costs,
 								  agg_final_costs, gd, can_sort, can_hash,
 								  dNumGroups, (List *) havingQual);
-	}
 
-	/* Give a helpful error if we failed to find any implementation */
-	if (!child_data && grouped_rel->pathlist == NIL)
-		ereport(ERROR,
-				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-				 errmsg("could not implement GROUP BY"),
-				 errdetail("Some of the datatypes only support hashing, while others only support sorting.")));
-	else if (child_data)
-	{
-		/*
-		 * Must have a path created above.  If path is present for the whole
-		 * relation, then it should also present for the child relation.  And
-		 * if not, we would have thrown an error already and thus will never
-		 * end up here.
-		 */
-		Assert(grouped_rel->pathlist != NIL ||
-			   partially_grouped_rel->pathlist != NIL);
+		/* Give a helpful error if we failed to find any implementation */
+		if (grouped_rel->pathlist == NIL)
+			ereport(ERROR,
+					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+					 errmsg("could not implement GROUP BY"),
+					 errdetail("Some of the datatypes only support hashing, while others only support sorting.")));
 	}
 
 	/*
-- 
2.14.3 (Apple Git-98)

