Commit a829cbb8 authored by Tom Lane's avatar Tom Lane

Give left_oper() and right_oper() noError parameters like oper() (the

binary case) already has.  Needed for upcoming ruleutils change.
parent 61446e09
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.63 2002/04/25 02:56:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.64 2002/05/01 19:26:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -109,7 +109,7 @@ make_op(List *opname, Node *ltree, Node *rtree) ...@@ -109,7 +109,7 @@ make_op(List *opname, Node *ltree, Node *rtree)
/* right operator? */ /* right operator? */
if (rtree == NULL) if (rtree == NULL)
{ {
tup = right_oper(opname, ltypeId); tup = right_oper(opname, ltypeId, false);
opform = (Form_pg_operator) GETSTRUCT(tup); opform = (Form_pg_operator) GETSTRUCT(tup);
left = make_operand(ltree, ltypeId, opform->oprleft); left = make_operand(ltree, ltypeId, opform->oprleft);
right = NULL; right = NULL;
...@@ -118,7 +118,7 @@ make_op(List *opname, Node *ltree, Node *rtree) ...@@ -118,7 +118,7 @@ make_op(List *opname, Node *ltree, Node *rtree)
/* left operator? */ /* left operator? */
else if (ltree == NULL) else if (ltree == NULL)
{ {
tup = left_oper(opname, rtypeId); tup = left_oper(opname, rtypeId, false);
opform = (Form_pg_operator) GETSTRUCT(tup); opform = (Form_pg_operator) GETSTRUCT(tup);
right = make_operand(rtree, rtypeId, opform->oprright); right = make_operand(rtree, rtypeId, opform->oprright);
left = NULL; left = NULL;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.55 2002/04/16 23:08:11 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.56 2002/05/01 19:26:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -751,19 +751,21 @@ compatible_oper_funcid(List *op, Oid arg1, Oid arg2, bool noError) ...@@ -751,19 +751,21 @@ compatible_oper_funcid(List *op, Oid arg1, Oid arg2, bool noError)
} }
/* Given unary right operator (operator on right), return oper struct /* right_oper() -- search for a unary right operator (operator on right)
* Given operator name and type of arg, return oper struct.
* *
* IMPORTANT: the returned operator (if any) is only promised to be * IMPORTANT: the returned operator (if any) is only promised to be
* coercion-compatible with the input datatype. Do not use this if * coercion-compatible with the input datatype. Do not use this if
* you need an exact- or binary-compatible match. * you need an exact- or binary-compatible match.
* *
* Always raises error on failure. * If no matching operator found, return NULL if noError is true,
* raise an error if it is false.
* *
* NOTE: on success, the returned object is a syscache entry. The caller * NOTE: on success, the returned object is a syscache entry. The caller
* must ReleaseSysCache() the entry when done with it. * must ReleaseSysCache() the entry when done with it.
*/ */
Operator Operator
right_oper(List *op, Oid arg) right_oper(List *op, Oid arg, bool noError)
{ {
FuncCandidateList clist; FuncCandidateList clist;
Oid operOid = InvalidOid; Oid operOid = InvalidOid;
...@@ -804,26 +806,28 @@ right_oper(List *op, Oid arg) ...@@ -804,26 +806,28 @@ right_oper(List *op, Oid arg)
0, 0, 0); 0, 0, 0);
} }
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup) && !noError)
unary_op_error(op, arg, FALSE); unary_op_error(op, arg, FALSE);
return (Operator) tup; return (Operator) tup;
} /* right_oper() */ }
/* Given unary left operator (operator on left), return oper struct /* left_oper() -- search for a unary left operator (operator on left)
* Given operator name and type of arg, return oper struct.
* *
* IMPORTANT: the returned operator (if any) is only promised to be * IMPORTANT: the returned operator (if any) is only promised to be
* coercion-compatible with the input datatype. Do not use this if * coercion-compatible with the input datatype. Do not use this if
* you need an exact- or binary-compatible match. * you need an exact- or binary-compatible match.
* *
* Always raises error on failure. * If no matching operator found, return NULL if noError is true,
* raise an error if it is false.
* *
* NOTE: on success, the returned object is a syscache entry. The caller * NOTE: on success, the returned object is a syscache entry. The caller
* must ReleaseSysCache() the entry when done with it. * must ReleaseSysCache() the entry when done with it.
*/ */
Operator Operator
left_oper(List *op, Oid arg) left_oper(List *op, Oid arg, bool noError)
{ {
FuncCandidateList clist; FuncCandidateList clist;
Oid operOid = InvalidOid; Oid operOid = InvalidOid;
...@@ -869,11 +873,11 @@ left_oper(List *op, Oid arg) ...@@ -869,11 +873,11 @@ left_oper(List *op, Oid arg)
0, 0, 0); 0, 0, 0);
} }
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup) && !noError)
unary_op_error(op, arg, TRUE); unary_op_error(op, arg, TRUE);
return (Operator) tup; return (Operator) tup;
} /* left_oper() */ }
/* op_error() /* op_error()
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: parse_oper.h,v 1.19 2002/04/16 23:08:12 tgl Exp $ * $Id: parse_oper.h,v 1.20 2002/05/01 19:26:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -27,8 +27,8 @@ extern Oid LookupOperNameTypeNames(List *opername, TypeName *oprleft, ...@@ -27,8 +27,8 @@ extern Oid LookupOperNameTypeNames(List *opername, TypeName *oprleft,
/* Routines to find operators matching a name and given input types */ /* Routines to find operators matching a name and given input types */
/* NB: the selected operator may require coercion of the input types! */ /* NB: the selected operator may require coercion of the input types! */
extern Operator oper(List *op, Oid arg1, Oid arg2, bool noError); extern Operator oper(List *op, Oid arg1, Oid arg2, bool noError);
extern Operator right_oper(List *op, Oid arg); extern Operator right_oper(List *op, Oid arg, bool noError);
extern Operator left_oper(List *op, Oid arg); extern Operator left_oper(List *op, Oid arg, bool noError);
/* Routines to find operators that DO NOT require coercion --- ie, their */ /* Routines to find operators that DO NOT require coercion --- ie, their */
/* input types are either exactly as given, or binary-compatible */ /* input types are either exactly as given, or binary-compatible */
......
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