From 155e0b998a19e4250bb7522a3115eda2294310c1 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Mon, 6 Nov 2000 15:42:30 +0000 Subject: [PATCH] Allow type resolution for UNKNOWN arguments to functions to fall back to any available string type. Previously, all candidate choices must have fallen within the same "type category" for PostgreSQL to be willing to choose any of them. Need to apply the same fixup to operator type resolution. --- src/backend/parser/parse_func.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index b4324b0b6a3..9805e8df93c 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.91 2000/09/29 18:21:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.92 2000/11/06 15:42:30 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -921,6 +921,10 @@ func_select_candidate(int nargs, * eliminate some candidates because they are non-preferred at the * first slot, we won't notice that they didn't have the same type * category for a later slot. + * XXX Hmm. How else would you do this? These candidates are here because + * they all have the same number of matches on arguments with explicit + * types, so from here on left-to-right resolution is as good as any. + * Need a counterexample to see otherwise... */ for (i = 0; i < nargs; i++) { @@ -944,8 +948,21 @@ func_select_candidate(int nargs, } else if (current_category != slot_category) { - /* punt if more than one category for this slot */ - return NULL; + /* started out as unknown type, so give preference to string type, if available */ + if (current_category == STRING_TYPE) + { + /* forget all previous candidates */ + candidates = current_candidate; + last_candidate = current_candidate; + } + else if (slot_category == STRING_TYPE) + { + /* forget this candidate */ + if (last_candidate) + last_candidate->next = current_candidate->next; + else + candidates = current_candidate->next; + } } else if (current_type != slot_type) { @@ -982,6 +999,7 @@ func_select_candidate(int nargs, return NULL; /* no remaining candidates */ if (candidates->next != NULL) return NULL; /* more than one remaining candidate */ + return candidates->args; } /* func_select_candidate() */