1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-11 04:22:52 +03:00

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.
This commit is contained in:
Thomas G. Lockhart
1998-09-16 14:22:22 +00:00
parent 672bc164ce
commit 198bcef025

View File

@@ -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 @@
#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,
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,
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)
} }
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)
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)
} }
else else
{ {
targetOid = func_select_candidate(1, &arg, candidates); targetOid = oper_select_candidate(1, &arg, candidates);
if (targetOid != NULL)
{
tup = SearchSysCacheTuple(OPRNAME, tup = SearchSysCacheTuple(OPRNAME,
PointerGetDatum(op), PointerGetDatum(op),
ObjectIdGetDatum(InvalidOid), ObjectIdGetDatum(InvalidOid),
ObjectIdGetDatum(*targetOid), ObjectIdGetDatum(*targetOid),
CharGetDatum('l')); 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