diff options
Diffstat (limited to 'src/backend/parser/parse_func.c')
-rw-r--r-- | src/backend/parser/parse_func.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 1f63f6bc669..610fceac639 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.66 2000/01/10 17:14:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.67 2000/01/24 19:34:14 petere Exp $ * *------------------------------------------------------------------------- */ @@ -176,8 +176,26 @@ agg_select_candidate(Oid typeid, CandidateList candidates) current_category; /* - * Look for candidates which allow coersion and have a preferred type. - * Keep all candidates if none match. + * First look for exact matches or binary compatible matches. + * (Of course exact matches shouldn't even get here, but anyway.) + */ + for (current_candidate = candidates; + current_candidate != NULL; + current_candidate = current_candidate->next) + { + current_typeid = current_candidate->args[0]; + + if (current_typeid == typeid + || IS_BINARY_COMPATIBLE(current_typeid, typeid)) + { + /* we're home free */ + return current_typeid; + } + } + +/* + * If no luck that way, look for candidates which allow coersion + * and have a preferred type. Keep all candidates if none match. */ category = TypeCategory(typeid); ncandidates = 0; @@ -189,7 +207,7 @@ agg_select_candidate(Oid typeid, CandidateList candidates) current_typeid = current_candidate->args[0]; current_category = TypeCategory(current_typeid); - if ((current_category == category) + if (current_category == category && IsPreferredType(current_category, current_typeid) && can_coerce_type(1, &typeid, ¤t_typeid)) { |