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 */
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 (int nargs ,Oid * input_typeids ,CandidateList candidates );
30+ Oid * oper_select_candidate (int nargs ,Oid * input_typeids ,CandidateList candidates );
3331static int binary_oper_get_candidates (char * opname ,
3432Oid leftTypeId ,
3533Oid rightTypeId ,
@@ -38,8 +36,7 @@ static int unary_oper_get_candidates(char *op,
3836Oid typeId ,
3937CandidateList * candidates ,
4038char rightleft );
41- static void
42- op_error (char * op ,Oid arg1 ,Oid arg2 );
39+ static void op_error (char * op ,Oid arg1 ,Oid arg2 );
4340
4441Oid
4542any_ordering_op (int restype )
@@ -312,7 +309,7 @@ oper_select_candidate(int nargs,
312309if (ncandidates <=1 )
313310{
314311if (!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{
317314ncandidates = 0 ;
318315#ifdef PARSEDEBUG
@@ -718,7 +715,7 @@ right_oper(char *op, Oid arg)
718715}
719716else
720717{
721- targetOid = func_select_candidate (1 ,& arg ,candidates );
718+ targetOid = oper_select_candidate (1 ,& arg ,candidates );
722719
723720if (targetOid != NULL )
724721{
@@ -729,12 +726,14 @@ right_oper(char *op, Oid arg)
729726CharGetDatum ('r' ));
730727}
731728else
729+ {
732730tup = NULL ;
731+ }
733732
734733if (!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 ));
738737return NULL ;
739738}
740739}
@@ -782,17 +781,24 @@ left_oper(char *op, Oid arg)
782781}
783782else
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
792798if (!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 ));
796802return NULL ;
797803}
798804#ifdef PARSEDEBUG