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 1 Jun 2003 15:50:25 -0000 *************** *** 1187,1192 **** --- 1195,1222 ---- 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 + * 2) target is ANYARRAY and source is 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 (targettype == ANYARRAYOID) + if (get_element_type(srctype) != InvalidOid) + return true; + + /* if all else fails... */ + return false; + } /* * find_coercion_pathway 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 15:54:41 -0000 *************** *** 412,417 **** --- 412,422 ---- IsBinaryCoercible(arg2, opform->oprright)) return optup; + /* last check -- polymorphic types? */ + if (IsPolymorphicCoercible(arg1 , opform->oprleft) && + IsPolymorphicCoercible(arg2, opform->oprright)) + return optup; + /* nope... */ ReleaseSysCache(optup); 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 1 Jun 2003 15:41:23 -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);