Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit681c587

Browse files
author
Thomas G. Lockhart
committed
Do a better job of selecting candidates among functions
when no exact match.Clean up elog error messages.
1 parentb4def32 commit681c587

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

‎src/backend/parser/parse_func.c

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.38 1999/02/13 23:17:08 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.39 1999/02/23 07:51:53 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -828,66 +828,67 @@ func_select_candidate(int nargs,
828828
}
829829
}
830830

831+
if (ncandidates==1)
832+
returncandidates->args;
833+
831834
/*
832835
* Still too many candidates?
833836
* Try assigning types for the unknown columns.
834837
*/
835-
if (ncandidates>1)
838+
for (i=0;i<nargs;i++)
836839
{
837-
for (i=0;i<nargs;i++)
840+
if (input_typeids[i]==UNKNOWNOID)
838841
{
839-
if (input_typeids[i]==UNKNOWNOID)
842+
slot_category=INVALID_TYPE;
843+
slot_type=InvalidOid;
844+
for (current_candidate=candidates;
845+
current_candidate!=NULL;
846+
current_candidate=current_candidate->next)
840847
{
841-
slot_category=INVALID_TYPE;
842-
slot_type=InvalidOid;
843-
for (current_candidate=candidates;
844-
current_candidate!=NULL;
845-
current_candidate=current_candidate->next)
846-
{
847-
current_typeids=current_candidate->args;
848-
current_type=current_typeids[i];
849-
current_category=TypeCategory(current_typeids[i]);
848+
current_typeids=current_candidate->args;
849+
current_type=current_typeids[i];
850+
current_category=TypeCategory(current_typeids[i]);
850851

851-
if (slot_category==InvalidOid)
852+
if (slot_category==InvalidOid)
853+
{
854+
slot_category=current_category;
855+
slot_type=current_type;
856+
}
857+
elseif ((current_category!=slot_category)
858+
&&IS_BUILTIN_TYPE(current_type))
859+
{
860+
returnNULL;
861+
}
862+
elseif (current_type!=slot_type)
863+
{
864+
if (IsPreferredType(slot_category,current_type))
852865
{
853-
slot_category=current_category;
854866
slot_type=current_type;
867+
candidates=current_candidate;
855868
}
856-
elseif ((current_category!=slot_category)
857-
&&IS_BUILTIN_TYPE(current_type))
869+
elseif (IsPreferredType(slot_category,slot_type))
858870
{
859-
returnNULL;
871+
candidates->next=current_candidate->next;
860872
}
861-
elseif (current_type!=slot_type)
862-
{
863-
if (IsPreferredType(slot_category,current_type))
864-
{
865-
slot_type=current_type;
866-
candidates=current_candidate;
867-
}
868-
else
869-
{
870-
}
871-
}
872-
}
873-
874-
if (slot_type!=InvalidOid)
875-
{
876-
input_typeids[i]=slot_type;
877873
}
878874
}
879-
else
875+
876+
if (slot_type!=InvalidOid)
880877
{
878+
input_typeids[i]=slot_type;
881879
}
882880
}
883-
884-
ncandidates=0;
885-
for (current_candidate=candidates;
886-
current_candidate!=NULL;
887-
current_candidate=current_candidate->next)
888-
ncandidates++;
881+
else
882+
{
883+
}
889884
}
890885

886+
ncandidates=0;
887+
for (current_candidate=candidates;
888+
current_candidate!=NULL;
889+
current_candidate=current_candidate->next)
890+
ncandidates++;
891+
891892
if (ncandidates==1)
892893
returncandidates->args;
893894

@@ -964,7 +965,7 @@ func_get_detail(char *funcname,
964965
ftup=SearchSysCacheTuple(PRONAME,
965966
PointerGetDatum(funcname),
966967
Int32GetDatum(nargs),
967-
PointerGetDatum(*true_typeids),
968+
PointerGetDatum(*true_typeids),
968969
0);
969970
Assert(HeapTupleIsValid(ftup));
970971
}
@@ -976,8 +977,8 @@ func_get_detail(char *funcname,
976977
elseif (ncandidates>1)
977978
{
978979
*true_typeids=func_select_candidate(nargs,
979-
current_input_typeids,
980-
current_function_typeids);
980+
current_input_typeids,
981+
current_function_typeids);
981982

982983
/* couldn't decide, so quit */
983984
if (*true_typeids==NULL)
@@ -991,9 +992,9 @@ func_get_detail(char *funcname,
991992
else
992993
{
993994
ftup=SearchSysCacheTuple(PRONAME,
994-
PointerGetDatum(funcname),
995+
PointerGetDatum(funcname),
995996
Int32GetDatum(nargs),
996-
PointerGetDatum(*true_typeids),
997+
PointerGetDatum(*true_typeids),
997998
0);
998999
Assert(HeapTupleIsValid(ftup));
9991000
}
@@ -1012,7 +1013,7 @@ func_get_detail(char *funcname,
10121013
{
10131014
tp=typeidType(oid_array[0]);
10141015
if (typeTypeFlag(tp)=='c')
1015-
elog(ERROR,"func_get_detail:No such attribute or function '%s'",funcname);
1016+
elog(ERROR,"No such attribute or function '%s'",funcname);
10161017
}
10171018
}
10181019
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp