Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 155e0b9

Browse files
author
Thomas G. Lockhart
committed
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.
1 parent 493635b commit 155e0b9

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/backend/parser/parse_func.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.91 2000/09/29 18:21:36 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.92 2000/11/06 15:42:30 thomas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -921,6 +921,10 @@ func_select_candidate(int nargs,
921921
* eliminate some candidates because they are non-preferred at the
922922
* first slot, we won't notice that they didn't have the same type
923923
* category for a later slot.
924+
* XXX Hmm. How else would you do this? These candidates are here because
925+
* they all have the same number of matches on arguments with explicit
926+
* types, so from here on left-to-right resolution is as good as any.
927+
* Need a counterexample to see otherwise...
924928
*/
925929
for (i = 0; i < nargs; i++)
926930
{
@@ -944,8 +948,21 @@ func_select_candidate(int nargs,
944948
}
945949
else if (current_category != slot_category)
946950
{
947-
/* punt if more than one category for this slot */
948-
return NULL;
951+
/* started out as unknown type, so give preference to string type, if available */
952+
if (current_category == STRING_TYPE)
953+
{
954+
/* forget all previous candidates */
955+
candidates = current_candidate;
956+
last_candidate = current_candidate;
957+
}
958+
else if (slot_category == STRING_TYPE)
959+
{
960+
/* forget this candidate */
961+
if (last_candidate)
962+
last_candidate->next = current_candidate->next;
963+
else
964+
candidates = current_candidate->next;
965+
}
949966
}
950967
else if (current_type != slot_type)
951968
{
@@ -982,6 +999,7 @@ func_select_candidate(int nargs,
982999
return NULL; /* no remaining candidates */
9831000
if (candidates->next != NULL)
9841001
return NULL; /* more than one remaining candidate */
1002+
9851003
return candidates->args;
9861004
} /* func_select_candidate() */
9871005

0 commit comments

Comments
 (0)