{
TypeCacheEntry *typentry;
Expr *clause = restrictinfo->clause;
- Node *leftarg;
+ Oid lefttype;
+ Oid righttype;
if (restrictinfo->pseudoconstant)
return;
if (list_length(((OpExpr *) clause)->args) != 2)
return;
- leftarg = linitial(((OpExpr *) clause)->args);
+ lefttype = exprType(linitial(((OpExpr *) clause)->args));
+ righttype = exprType(lsecond(((OpExpr *) clause)->args));
+
+ /*
+ * Really there should be a field for both the left and right hash
+ * equality operator, however, in v14, there's only a single field in
+ * RestrictInfo to record the operator in, so we must insist that the left
+ * and right types match.
+ */
+ if (lefttype != righttype)
+ return;
- typentry = lookup_type_cache(exprType(leftarg), TYPECACHE_HASH_PROC |
- TYPECACHE_EQ_OPR);
+ typentry = lookup_type_cache(lefttype, TYPECACHE_HASH_PROC |
+ TYPECACHE_EQ_OPR);
if (!OidIsValid(typentry->hash_proc) || !OidIsValid(typentry->eq_opr))
return;