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

Commit198bcef

Browse files
author
Thomas G. Lockhart
committed
Use oper_select_candidate() for unary operators
rather than func_select_candidate().Fix oper_select_candidate() to work with a single operator argument.Repair left operator checking for null return from candidate list.
1 parent672bc16 commit198bcef

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

‎src/backend/parser/parse_oper.c

Lines changed: 24 additions & 18 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_oper.c,v 1.17 1998/09/01 04:30:34 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.18 1998/09/16 14:22:22 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,15 +21,13 @@
2121
#include"catalog/pg_operator.h"
2222
#include"catalog/pg_type.h"
2323
#include"fmgr.h"
24-
#include"parser/parse_func.h"
2524
#include"parser/parse_oper.h"
2625
#include"parser/parse_type.h"
2726
#include"parser/parse_coerce.h"
2827
#include"storage/bufmgr.h"
2928
#include"utils/syscache.h"
3029

31-
Oid*
32-
oper_select_candidate(intnargs,Oid*input_typeids,CandidateListcandidates);
30+
Oid*oper_select_candidate(intnargs,Oid*input_typeids,CandidateListcandidates);
3331
staticintbinary_oper_get_candidates(char*opname,
3432
OidleftTypeId,
3533
OidrightTypeId,
@@ -38,8 +36,7 @@ static int unary_oper_get_candidates(char *op,
3836
OidtypeId,
3937
CandidateList*candidates,
4038
charrightleft);
41-
staticvoid
42-
op_error(char*op,Oidarg1,Oidarg2);
39+
staticvoidop_error(char*op,Oidarg1,Oidarg2);
4340

4441
Oid
4542
any_ordering_op(intrestype)
@@ -312,7 +309,7 @@ oper_select_candidate(int nargs,
312309
if (ncandidates <=1)
313310
{
314311
if (!can_coerce_type(1,&input_typeids[0],&candidates->args[0])
315-
|| !can_coerce_type(1,&input_typeids[1],&candidates->args[1]))
312+
||((nargs>1)&&!can_coerce_type(1,&input_typeids[1],&candidates->args[1])))
316313
{
317314
ncandidates=0;
318315
#ifdefPARSEDEBUG
@@ -718,7 +715,7 @@ right_oper(char *op, Oid arg)
718715
}
719716
else
720717
{
721-
targetOid=func_select_candidate(1,&arg,candidates);
718+
targetOid=oper_select_candidate(1,&arg,candidates);
722719

723720
if (targetOid!=NULL)
724721
{
@@ -729,12 +726,14 @@ right_oper(char *op, Oid arg)
729726
CharGetDatum('r'));
730727
}
731728
else
729+
{
732730
tup=NULL;
731+
}
733732

734733
if (!HeapTupleIsValid(tup))
735734
{
736-
elog(ERROR,"Unable to convert right operator '%s' from type %s to %s",
737-
op,typeidTypeName(arg),typeidTypeName(*targetOid));
735+
elog(ERROR,"Unable to convert right operator '%s' from type %s",
736+
op,typeidTypeName(arg));
738737
returnNULL;
739738
}
740739
}
@@ -782,17 +781,24 @@ left_oper(char *op, Oid arg)
782781
}
783782
else
784783
{
785-
targetOid=func_select_candidate(1,&arg,candidates);
786-
tup=SearchSysCacheTuple(OPRNAME,
787-
PointerGetDatum(op),
788-
ObjectIdGetDatum(InvalidOid),
789-
ObjectIdGetDatum(*targetOid),
790-
CharGetDatum('l'));
784+
targetOid=oper_select_candidate(1,&arg,candidates);
785+
if (targetOid!=NULL)
786+
{
787+
tup=SearchSysCacheTuple(OPRNAME,
788+
PointerGetDatum(op),
789+
ObjectIdGetDatum(InvalidOid),
790+
ObjectIdGetDatum(*targetOid),
791+
CharGetDatum('l'));
792+
}
793+
else
794+
{
795+
tup=NULL;
796+
}
791797

792798
if (!HeapTupleIsValid(tup))
793799
{
794-
elog(ERROR,"Unable to convert left operator '%s' from type %s to %s",
795-
op,typeidTypeName(arg),typeidTypeName(*targetOid));
800+
elog(ERROR,"Unable to convert left operator '%s' from type %s",
801+
op,typeidTypeName(arg));
796802
returnNULL;
797803
}
798804
#ifdefPARSEDEBUG

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp