diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index 4e7600e4ed6074e780d95030c63e2407195a7cc0..7cf001518a14cf6cc2b720f18c2b240553ffd7a0 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -212,11 +212,17 @@ BuildTupleHashTable(PlanState *parent,
 													&TTSOpsMinimalTuple, &TTSOpsMinimalTuple,
 													numCols,
 													keyColIdx, eqfuncoids,
-													parent);
+													NULL);
 
-	MemoryContextSwitchTo(oldcontext);
+	/*
+	 * While not pretty, it's ok to not shut down this context, but instead
+	 * rely on the containing memory context being reset, as
+	 * ExecBuildGroupingEqual() only builds a very simple expression calling
+	 * functions (i.e. nothing that'd employ RegisterExprContextCallback()).
+	 */
+	hashtable->exprcontext = CreateStandaloneExprContext();
 
-	hashtable->exprcontext = CreateExprContext(parent->state);
+	MemoryContextSwitchTo(oldcontext);
 
 	return hashtable;
 }