Skip to content

Commit a829cbb

Browse files
committed
Give left_oper() and right_oper() noError parameters like oper() (the
binary case) already has. Needed for upcoming ruleutils change.
1 parent 61446e0 commit a829cbb

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/backend/parser/parse_node.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.63 2002/04/25 02:56:55 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.64 2002/05/01 19:26:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -109,7 +109,7 @@ make_op(List *opname, Node *ltree, Node *rtree)
109109
/* right operator? */
110110
if (rtree == NULL)
111111
{
112-
tup = right_oper(opname, ltypeId);
112+
tup = right_oper(opname, ltypeId, false);
113113
opform = (Form_pg_operator) GETSTRUCT(tup);
114114
left = make_operand(ltree, ltypeId, opform->oprleft);
115115
right = NULL;
@@ -118,7 +118,7 @@ make_op(List *opname, Node *ltree, Node *rtree)
118118
/* left operator? */
119119
else if (ltree == NULL)
120120
{
121-
tup = left_oper(opname, rtypeId);
121+
tup = left_oper(opname, rtypeId, false);
122122
opform = (Form_pg_operator) GETSTRUCT(tup);
123123
right = make_operand(rtree, rtypeId, opform->oprright);
124124
left = NULL;

src/backend/parser/parse_oper.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.55 2002/04/16 23:08:11 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.56 2002/05/01 19:26:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -751,19 +751,21 @@ compatible_oper_funcid(List *op, Oid arg1, Oid arg2, bool noError)
751751
}
752752

753753

754-
/* Given unary right operator (operator on right), return oper struct
754+
/* right_oper() -- search for a unary right operator (operator on right)
755+
* Given operator name and type of arg, return oper struct.
755756
*
756757
* IMPORTANT: the returned operator (if any) is only promised to be
757758
* coercion-compatible with the input datatype. Do not use this if
758759
* you need an exact- or binary-compatible match.
759760
*
760-
* Always raises error on failure.
761+
* If no matching operator found, return NULL if noError is true,
762+
* raise an error if it is false.
761763
*
762764
* NOTE: on success, the returned object is a syscache entry. The caller
763765
* must ReleaseSysCache() the entry when done with it.
764766
*/
765767
Operator
766-
right_oper(List *op, Oid arg)
768+
right_oper(List *op, Oid arg, bool noError)
767769
{
768770
FuncCandidateList clist;
769771
Oid operOid = InvalidOid;
@@ -804,26 +806,28 @@ right_oper(List *op, Oid arg)
804806
0, 0, 0);
805807
}
806808

807-
if (!HeapTupleIsValid(tup))
809+
if (!HeapTupleIsValid(tup) && !noError)
808810
unary_op_error(op, arg, FALSE);
809811

810812
return (Operator) tup;
811-
} /* right_oper() */
813+
}
812814

813815

814-
/* Given unary left operator (operator on left), return oper struct
816+
/* left_oper() -- search for a unary left operator (operator on left)
817+
* Given operator name and type of arg, return oper struct.
815818
*
816819
* IMPORTANT: the returned operator (if any) is only promised to be
817820
* coercion-compatible with the input datatype. Do not use this if
818821
* you need an exact- or binary-compatible match.
819822
*
820-
* Always raises error on failure.
823+
* If no matching operator found, return NULL if noError is true,
824+
* raise an error if it is false.
821825
*
822826
* NOTE: on success, the returned object is a syscache entry. The caller
823827
* must ReleaseSysCache() the entry when done with it.
824828
*/
825829
Operator
826-
left_oper(List *op, Oid arg)
830+
left_oper(List *op, Oid arg, bool noError)
827831
{
828832
FuncCandidateList clist;
829833
Oid operOid = InvalidOid;
@@ -869,11 +873,11 @@ left_oper(List *op, Oid arg)
869873
0, 0, 0);
870874
}
871875

872-
if (!HeapTupleIsValid(tup))
876+
if (!HeapTupleIsValid(tup) && !noError)
873877
unary_op_error(op, arg, TRUE);
874878

875879
return (Operator) tup;
876-
} /* left_oper() */
880+
}
877881

878882

879883
/* op_error()

src/include/parser/parse_oper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: parse_oper.h,v 1.19 2002/04/16 23:08:12 tgl Exp $
10+
* $Id: parse_oper.h,v 1.20 2002/05/01 19:26:08 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -27,8 +27,8 @@ extern Oid LookupOperNameTypeNames(List *opername, TypeName *oprleft,
2727
/* Routines to find operators matching a name and given input types */
2828
/* NB: the selected operator may require coercion of the input types! */
2929
extern Operator oper(List *op, Oid arg1, Oid arg2, bool noError);
30-
extern Operator right_oper(List *op, Oid arg);
31-
extern Operator left_oper(List *op, Oid arg);
30+
extern Operator right_oper(List *op, Oid arg, bool noError);
31+
extern Operator left_oper(List *op, Oid arg, bool noError);
3232

3333
/* Routines to find operators that DO NOT require coercion --- ie, their */
3434
/* input types are either exactly as given, or binary-compatible */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy