*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.38 1999/02/13 23:17:08 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.39 1999/02/23 07:51:53 thomas Exp $
*
*-------------------------------------------------------------------------
*/
}
}
+ if (ncandidates == 1)
+ return candidates->args;
+
/*
* Still too many candidates?
* Try assigning types for the unknown columns.
*/
- if (ncandidates > 1)
+ for (i = 0; i < nargs; i++)
{
- for (i = 0; i < nargs; i++)
+ if (input_typeids[i] == UNKNOWNOID)
{
- if (input_typeids[i] == UNKNOWNOID)
+ slot_category = INVALID_TYPE;
+ slot_type = InvalidOid;
+ for (current_candidate = candidates;
+ current_candidate != NULL;
+ current_candidate = current_candidate->next)
{
- slot_category = INVALID_TYPE;
- slot_type = InvalidOid;
- for (current_candidate = candidates;
- current_candidate != NULL;
- current_candidate = current_candidate->next)
- {
- current_typeids = current_candidate->args;
- current_type = current_typeids[i];
- current_category = TypeCategory(current_typeids[i]);
+ current_typeids = current_candidate->args;
+ current_type = current_typeids[i];
+ current_category = TypeCategory(current_typeids[i]);
- if (slot_category == InvalidOid)
+ if (slot_category == InvalidOid)
+ {
+ slot_category = current_category;
+ slot_type = current_type;
+ }
+ else if ((current_category != slot_category)
+ && IS_BUILTIN_TYPE(current_type))
+ {
+ return NULL;
+ }
+ else if (current_type != slot_type)
+ {
+ if (IsPreferredType(slot_category, current_type))
{
- slot_category = current_category;
slot_type = current_type;
+ candidates = current_candidate;
}
- else if ((current_category != slot_category)
- && IS_BUILTIN_TYPE(current_type))
+ else if (IsPreferredType(slot_category, slot_type))
{
- return NULL;
+ candidates->next = current_candidate->next;
}
- else if (current_type != slot_type)
- {
- if (IsPreferredType(slot_category, current_type))
- {
- slot_type = current_type;
- candidates = current_candidate;
- }
- else
- {
- }
- }
- }
-
- if (slot_type != InvalidOid)
- {
- input_typeids[i] = slot_type;
}
}
- else
+
+ if (slot_type != InvalidOid)
{
+ input_typeids[i] = slot_type;
}
}
-
- ncandidates = 0;
- for (current_candidate = candidates;
- current_candidate != NULL;
- current_candidate = current_candidate->next)
- ncandidates++;
+ else
+ {
+ }
}
+ ncandidates = 0;
+ for (current_candidate = candidates;
+ current_candidate != NULL;
+ current_candidate = current_candidate->next)
+ ncandidates++;
+
if (ncandidates == 1)
return candidates->args;
ftup = SearchSysCacheTuple(PRONAME,
PointerGetDatum(funcname),
Int32GetDatum(nargs),
- PointerGetDatum(*true_typeids),
+ PointerGetDatum(*true_typeids),
0);
Assert(HeapTupleIsValid(ftup));
}
else if (ncandidates > 1)
{
*true_typeids = func_select_candidate(nargs,
- current_input_typeids,
- current_function_typeids);
+ current_input_typeids,
+ current_function_typeids);
/* couldn't decide, so quit */
if (*true_typeids == NULL)
else
{
ftup = SearchSysCacheTuple(PRONAME,
- PointerGetDatum(funcname),
+ PointerGetDatum(funcname),
Int32GetDatum(nargs),
- PointerGetDatum(*true_typeids),
+ PointerGetDatum(*true_typeids),
0);
Assert(HeapTupleIsValid(ftup));
}
{
tp = typeidType(oid_array[0]);
if (typeTypeFlag(tp) == 'c')
- elog(ERROR, "func_get_detail: No such attribute or function '%s'", funcname);
+ elog(ERROR, "No such attribute or function '%s'", funcname);
}
}
else