diff --git a/src/backend/optimizer/plan/analyzejoins.c b/src/backend/optimizer/plan/analyzejoins.c index 34f41d7..1cdb311 100644 --- a/src/backend/optimizer/plan/analyzejoins.c +++ b/src/backend/optimizer/plan/analyzejoins.c @@ -400,9 +400,11 @@ groupinglist_is_unique_on_restrictinfo(Query *query, List *rinfolist, List *grou Assert(groupinglist != NIL); /* - * 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. + * Loop over each groupinglist item to ensure that we have restrictinfo + * item to match. We also need to ensure that the operators used in the + * groupinglist matches that of the one in the restrict info. + * Note that it does not matter if we have more items in the rinfolist than + * we have in the groupinglist. */ foreach(l, groupinglist) { @@ -435,7 +437,8 @@ groupinglist_is_unique_on_restrictinfo(Query *query, List *rinfolist, List *grou { Var *var = (Var *)rexpr; - if (var->varattno == sortTarget->resno) + if (var->varattno == sortTarget->resno && + scl->eqop == rinfo->hashjoinoperator) { matched = true; break; /* match found */