Commit 198bcef0 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

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.
parent 672bc164
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.17 1998/09/01 04:30:34 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.18 1998/09/16 14:22:22 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,15 +21,13 @@ ...@@ -21,15 +21,13 @@
#include "catalog/pg_operator.h" #include "catalog/pg_operator.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "fmgr.h" #include "fmgr.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h" #include "parser/parse_oper.h"
#include "parser/parse_type.h" #include "parser/parse_type.h"
#include "parser/parse_coerce.h" #include "parser/parse_coerce.h"
#include "storage/bufmgr.h" #include "storage/bufmgr.h"
#include "utils/syscache.h" #include "utils/syscache.h"
Oid * Oid * oper_select_candidate(int nargs, Oid *input_typeids, CandidateList candidates);
oper_select_candidate(int nargs, Oid *input_typeids, CandidateList candidates);
static int binary_oper_get_candidates(char *opname, static int binary_oper_get_candidates(char *opname,
Oid leftTypeId, Oid leftTypeId,
Oid rightTypeId, Oid rightTypeId,
...@@ -38,8 +36,7 @@ static int unary_oper_get_candidates(char *op, ...@@ -38,8 +36,7 @@ static int unary_oper_get_candidates(char *op,
Oid typeId, Oid typeId,
CandidateList *candidates, CandidateList *candidates,
char rightleft); char rightleft);
static void static void op_error(char *op, Oid arg1, Oid arg2);
op_error(char *op, Oid arg1, Oid arg2);
Oid Oid
any_ordering_op(int restype) any_ordering_op(int restype)
...@@ -312,7 +309,7 @@ oper_select_candidate(int nargs, ...@@ -312,7 +309,7 @@ oper_select_candidate(int nargs,
if (ncandidates <= 1) if (ncandidates <= 1)
{ {
if (!can_coerce_type(1, &input_typeids[0], &candidates->args[0]) if (!can_coerce_type(1, &input_typeids[0], &candidates->args[0])
|| !can_coerce_type(1, &input_typeids[1], &candidates->args[1])) || ((nargs > 1) && !can_coerce_type(1, &input_typeids[1], &candidates->args[1])))
{ {
ncandidates = 0; ncandidates = 0;
#ifdef PARSEDEBUG #ifdef PARSEDEBUG
...@@ -718,7 +715,7 @@ right_oper(char *op, Oid arg) ...@@ -718,7 +715,7 @@ right_oper(char *op, Oid arg)
} }
else else
{ {
targetOid = func_select_candidate(1, &arg, candidates); targetOid = oper_select_candidate(1, &arg, candidates);
if (targetOid != NULL) if (targetOid != NULL)
{ {
...@@ -729,12 +726,14 @@ right_oper(char *op, Oid arg) ...@@ -729,12 +726,14 @@ right_oper(char *op, Oid arg)
CharGetDatum('r')); CharGetDatum('r'));
} }
else else
{
tup = NULL; tup = NULL;
}
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
{ {
elog(ERROR, "Unable to convert right operator '%s' from type %s to %s", elog(ERROR, "Unable to convert right operator '%s' from type %s",
op, typeidTypeName(arg), typeidTypeName(*targetOid)); op, typeidTypeName(arg));
return NULL; return NULL;
} }
} }
...@@ -782,17 +781,24 @@ left_oper(char *op, Oid arg) ...@@ -782,17 +781,24 @@ left_oper(char *op, Oid arg)
} }
else else
{ {
targetOid = func_select_candidate(1, &arg, candidates); targetOid = oper_select_candidate(1, &arg, candidates);
tup = SearchSysCacheTuple(OPRNAME, if (targetOid != NULL)
PointerGetDatum(op), {
ObjectIdGetDatum(InvalidOid), tup = SearchSysCacheTuple(OPRNAME,
ObjectIdGetDatum(*targetOid), PointerGetDatum(op),
CharGetDatum('l')); ObjectIdGetDatum(InvalidOid),
ObjectIdGetDatum(*targetOid),
CharGetDatum('l'));
}
else
{
tup = NULL;
}
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
{ {
elog(ERROR, "Unable to convert left operator '%s' from type %s to %s", elog(ERROR, "Unable to convert left operator '%s' from type %s",
op, typeidTypeName(arg), typeidTypeName(*targetOid)); op, typeidTypeName(arg));
return NULL; return NULL;
} }
#ifdef PARSEDEBUG #ifdef PARSEDEBUG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment