Index: src/backend/parser/parse_oper.c =================================================================== RCS file: /opt/src/cvs/pgsql-server/src/backend/parser/parse_oper.c,v retrieving revision 1.64 diff -c -r1.64 parse_oper.c *** src/backend/parser/parse_oper.c 26 May 2003 00:11:27 -0000 1.64 --- src/backend/parser/parse_oper.c 1 Jun 2003 00:01:30 -0000 *************** *** 412,417 **** --- 412,421 ---- IsBinaryCoercible(arg2, opform->oprright)) return optup; + /* last check -- polymorphic types? */ + if (IsPolymorphicCoercible(arg1 , arg2)) + return optup; + /* nope... */ ReleaseSysCache(optup); Index: src/backend/parser/parse_coerce.c =================================================================== RCS file: /opt/src/cvs/pgsql-server/src/backend/parser/parse_coerce.c,v retrieving revision 2.97 diff -c -r2.97 parse_coerce.c *** src/backend/parser/parse_coerce.c 26 May 2003 00:11:27 -0000 2.97 --- src/backend/parser/parse_coerce.c 31 May 2003 23:59:07 -0000 *************** *** 1187,1192 **** --- 1187,1230 ---- return result; } + /* IsPolymorphicCoercible() + * Check if srctype and targettype are a polymorphic compatible pair. + * + * We consider two types polymorphic-coercible if: + * 1) both are the same (we should never have been called this way, but what + * the heck) + * 2) one is ANYARRAY and the other is an array type + * 3) one is ANYELEMENT and the other is not an array type + + */ + bool + IsPolymorphicCoercible(Oid srctype, Oid targettype) + { + /* Case 1: fast path if same type */ + if (srctype == targettype) + return true; + + /* Case 2: check for matching arrays */ + if (srctype == ANYARRAYOID) + if (get_element_type(targettype) != InvalidOid) + return true; + + if (targettype == ANYARRAYOID) + if (get_element_type(srctype) != InvalidOid) + return true; + + /* Case 3: check for matching elements */ + if (srctype == ANYELEMENTOID) + if (get_element_type(targettype) == InvalidOid) + return true; + + if (targettype == ANYELEMENTOID) + if (get_element_type(srctype) == InvalidOid) + return true; + + /* if all else fails... */ + return false; + } /* * find_coercion_pathway Index: src/include/parser/parse_coerce.h =================================================================== RCS file: /opt/src/cvs/pgsql-server/src/include/parser/parse_coerce.h,v retrieving revision 1.51 diff -c -r1.51 parse_coerce.h *** src/include/parser/parse_coerce.h 29 Apr 2003 22:13:11 -0000 1.51 --- src/include/parser/parse_coerce.h 31 May 2003 23:51:19 -0000 *************** *** 36,41 **** --- 36,42 ---- extern bool IsBinaryCoercible(Oid srctype, Oid targettype); + extern bool IsPolymorphicCoercible(Oid srctype, Oid targettype); extern bool IsPreferredType(CATEGORY category, Oid type); extern CATEGORY TypeCategory(Oid type);