/* right operator? */
if (rtree == NULL)
{
- tup = right_oper(opname, ltypeId);
+ tup = right_oper(opname, ltypeId, false);
opform = (Form_pg_operator) GETSTRUCT(tup);
left = make_operand(ltree, ltypeId, opform->oprleft);
right = NULL;
/* left operator? */
else if (ltree == NULL)
{
- tup = left_oper(opname, rtypeId);
+ tup = left_oper(opname, rtypeId, false);
opform = (Form_pg_operator) GETSTRUCT(tup);
right = make_operand(rtree, rtypeId, opform->oprright);
left = NULL;
}
-/* 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
* coercion-compatible with the input datatype. Do not use this if
* 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
* must ReleaseSysCache() the entry when done with it.
*/
Operator
-right_oper(List *op, Oid arg)
+right_oper(List *op, Oid arg, bool noError)
{
FuncCandidateList clist;
Oid operOid = InvalidOid;
0, 0, 0);
}
- if (!HeapTupleIsValid(tup))
+ if (!HeapTupleIsValid(tup) && !noError)
unary_op_error(op, arg, FALSE);
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
* coercion-compatible with the input datatype. Do not use this if
* 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
* must ReleaseSysCache() the entry when done with it.
*/
Operator
-left_oper(List *op, Oid arg)
+left_oper(List *op, Oid arg, bool noError)
{
FuncCandidateList clist;
Oid operOid = InvalidOid;
0, 0, 0);
}
- if (!HeapTupleIsValid(tup))
+ if (!HeapTupleIsValid(tup) && !noError)
unary_op_error(op, arg, TRUE);
return (Operator) tup;
-} /* left_oper() */
+}
/* op_error()
/* Routines to find operators matching a name and given 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 right_oper(List *op, Oid arg);
-extern Operator left_oper(List *op, Oid arg);
+extern Operator right_oper(List *op, Oid arg, bool noError);
+extern Operator left_oper(List *op, Oid arg, bool noError);
/* Routines to find operators that DO NOT require coercion --- ie, their */
/* input types are either exactly as given, or binary-compatible */