diff --git a/src/backend/optimizer/plan/analyzejoins.c b/src/backend/optimizer/plan/analyzejoins.c
index ea4a9e0..34f41d7 100644
--- a/src/backend/optimizer/plan/analyzejoins.c
+++ b/src/backend/optimizer/plan/analyzejoins.c
@@ -34,7 +34,7 @@
 
 /* local functions */
 static bool join_is_removable(PlannerInfo *root, SpecialJoinInfo *sjinfo);
-static bool	sortlist_is_unique_on_restrictinfo(Query *query,
+static bool	groupinglist_is_unique_on_restrictinfo(Query *query,
 					  List *clause_list, List *sortlist);
 static void remove_rel_from_query(PlannerInfo *root, int relid,
 					  Relids joinrelids);
@@ -363,7 +363,7 @@ join_is_removable(PlannerInfo *root, SpecialJoinInfo *sjinfo)
 		 * have matching items in the join condition.
 		 */
 		if (subquery->groupClause != NIL &&
-			sortlist_is_unique_on_restrictinfo(subquery, clause_list, subquery->groupClause))
+			groupinglist_is_unique_on_restrictinfo(subquery, clause_list, subquery->groupClause))
 			return true;
 
 		/*
@@ -371,7 +371,7 @@ join_is_removable(PlannerInfo *root, SpecialJoinInfo *sjinfo)
 		 * items in the join condition.
 		 */
 		if (subquery->distinctClause != NIL &&
-			sortlist_is_unique_on_restrictinfo(subquery, clause_list, subquery->distinctClause))
+			groupinglist_is_unique_on_restrictinfo(subquery, clause_list, subquery->distinctClause))
 			return true;
 	}
 
@@ -383,28 +383,28 @@ join_is_removable(PlannerInfo *root, SpecialJoinInfo *sjinfo)
 }
 
 /*
- * sortlist_is_unique_on_restrictinfo
+ * groupinglist_is_unique_on_restrictinfo
  *
- * Checks to see if all items in sortlist also exist in clause_list.
- * The function will return true if clause_list is the same as or a superset
- * of sortlist. If the sortlist has Vars that don't exist in the clause_list
- * then the query can't be guaranteed unique on the clause_list columns.
+ * Checks to see if all items in groupinglist also exist in rinfolist.
+ * The function will return true if rinfolist is the same as or a superset
+ * of groupinglist. If the groupinglist has Vars that don't exist in the rinfolist
+ * then the query can't be guaranteed unique on the rinfolist columns.
  *
- * Note: The calling function must ensure that sortlist is not NIL.
+ * Note: The calling function must ensure that groupinglist is not NIL.
  */
 static bool
-sortlist_is_unique_on_restrictinfo(Query *query, List *clause_list, List *sortlist)
+groupinglist_is_unique_on_restrictinfo(Query *query, List *rinfolist, List *groupinglist)
 {
 	ListCell *l;
 
-	Assert(sortlist != NIL);
+	Assert(groupinglist != NIL);
 
 	/*
-	 * Loop over each sortlist item to ensure that we have an item in the
-	 * clause_list that matches it. Note that it does not matter if we have
-	 * more items in the clause_list than we have in the sortlist.
+	 * Loop over each groupinglist item to ensure that we have an item in the
+	 * rinfolist that matches it. Note that it does not matter if we have
+	 * more items in the rinfolist than we have in the groupinglist.
 	 */
-	foreach(l, sortlist)
+	foreach(l, groupinglist)
 	{
 		ListCell		*ri;
 		SortGroupClause *scl = (SortGroupClause *) lfirst(l);
@@ -421,7 +421,7 @@ sortlist_is_unique_on_restrictinfo(Query *query, List *clause_list, List *sortli
 		if (IsA(sortTarget->expr, Const))
 			continue;
 
-		foreach(ri, clause_list)
+		foreach(ri, rinfolist)
 		{
 			RestrictInfo *rinfo = (RestrictInfo *) lfirst(ri);
 			Node	   *rexpr;
