PostgreSQL Source Code git master
parse_oper.h File Reference
#include "access/htup.h"
#include "nodes/parsenodes.h"
#include "parser/parse_node.h"
Include dependency graph for parse_oper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef HeapTuple Operator
 

Functions

Oid LookupOperName (ParseState *pstate, List *opername, Oid oprleft, Oid oprright, bool noError, int location)
 
Oid LookupOperWithArgs (ObjectWithArgs *oper, bool noError)
 
Operator oper (ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
 
Operator left_oper (ParseState *pstate, List *op, Oid arg, bool noError, int location)
 
Operator compatible_oper (ParseState *pstate, List *op, Oid arg1, Oid arg2, bool noError, int location)
 
const char * op_signature_string (List *op, Oid arg1, Oid arg2)
 
void get_sort_group_operators (Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
 
Oid compatible_oper_opid (List *op, Oid arg1, Oid arg2, bool noError)
 
Oid oprid (Operator op)
 
Oid oprfuncid (Operator op)
 
Exprmake_op (ParseState *pstate, List *opname, Node *ltree, Node *rtree, Node *last_srf, int location)
 
Exprmake_scalar_array_op (ParseState *pstate, List *opname, bool useOr, Node *ltree, Node *rtree, int location)
 

Typedef Documentation

◆ Operator

Definition at line 22 of file parse_oper.h.

Function Documentation

◆ compatible_oper()

Operator compatible_oper ( ParseState pstate,
List op,
Oid  arg1,
Oid  arg2,
bool  noError,
int  location 
)

Definition at line 450 of file parse_oper.c.

452{
453 Operator optup;
454 Form_pg_operator opform;
455
456 /* oper() will find the best available match */
457 optup = oper(pstate, op, arg1, arg2, noError, location);
458 if (optup == (Operator) NULL)
459 return (Operator) NULL; /* must be noError case */
460
461 /* but is it good enough? */
462 opform = (Form_pg_operator) GETSTRUCT(optup);
463 if (IsBinaryCoercible(arg1, opform->oprleft) &&
464 IsBinaryCoercible(arg2, opform->oprright))
465 return optup;
466
467 /* nope... */
468 ReleaseSysCache(optup);
469
470 if (!noError)
472 (errcode(ERRCODE_UNDEFINED_FUNCTION),
473 errmsg("operator requires run-time type coercion: %s",
474 op_signature_string(op, arg1, arg2)),
475 parser_errposition(pstate, location)));
476
477 return (Operator) NULL;
478}
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
#define GETSTRUCT(TUP)
Definition: htup_details.h:653
bool IsBinaryCoercible(Oid srctype, Oid targettype)
int parser_errposition(ParseState *pstate, int location)
Definition: parse_node.c:106
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
Definition: parse_oper.c:370
const char * op_signature_string(List *op, Oid arg1, Oid arg2)
Definition: parse_oper.c:602
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:269

References ereport, errcode(), errmsg(), ERROR, GETSTRUCT, IsBinaryCoercible(), op_signature_string(), oper(), parser_errposition(), and ReleaseSysCache().

Referenced by compatible_oper_opid().

◆ compatible_oper_opid()

Oid compatible_oper_opid ( List op,
Oid  arg1,
Oid  arg2,
bool  noError 
)

Definition at line 487 of file parse_oper.c.

488{
489 Operator optup;
490 Oid result;
491
492 optup = compatible_oper(NULL, op, arg1, arg2, noError, -1);
493 if (optup != NULL)
494 {
495 result = oprid(optup);
496 ReleaseSysCache(optup);
497 return result;
498 }
499 return InvalidOid;
500}
Oid oprid(Operator op)
Definition: parse_oper.c:238
Operator compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2, bool noError, int location)
Definition: parse_oper.c:450
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32

References compatible_oper(), InvalidOid, oprid(), and ReleaseSysCache().

Referenced by addTargetToSortList(), and ComputeIndexAttrs().

◆ get_sort_group_operators()

void get_sort_group_operators ( Oid  argtype,
bool  needLT,
bool  needEQ,
bool  needGT,
Oid ltOpr,
Oid eqOpr,
Oid gtOpr,
bool *  isHashable 
)

Definition at line 180 of file parse_oper.c.

184{
185 TypeCacheEntry *typentry;
186 int cache_flags;
187 Oid lt_opr;
188 Oid eq_opr;
189 Oid gt_opr;
190 bool hashable;
191
192 /*
193 * Look up the operators using the type cache.
194 *
195 * Note: the search algorithm used by typcache.c ensures that the results
196 * are consistent, ie all from matching opclasses.
197 */
198 if (isHashable != NULL)
201 else
203
204 typentry = lookup_type_cache(argtype, cache_flags);
205 lt_opr = typentry->lt_opr;
206 eq_opr = typentry->eq_opr;
207 gt_opr = typentry->gt_opr;
208 hashable = OidIsValid(typentry->hash_proc);
209
210 /* Report errors if needed */
211 if ((needLT && !OidIsValid(lt_opr)) ||
212 (needGT && !OidIsValid(gt_opr)))
214 (errcode(ERRCODE_UNDEFINED_FUNCTION),
215 errmsg("could not identify an ordering operator for type %s",
216 format_type_be(argtype)),
217 errhint("Use an explicit ordering operator or modify the query.")));
218 if (needEQ && !OidIsValid(eq_opr))
220 (errcode(ERRCODE_UNDEFINED_FUNCTION),
221 errmsg("could not identify an equality operator for type %s",
222 format_type_be(argtype))));
223
224 /* Return results as needed */
225 if (ltOpr)
226 *ltOpr = lt_opr;
227 if (eqOpr)
228 *eqOpr = eq_opr;
229 if (gtOpr)
230 *gtOpr = gt_opr;
231 if (isHashable)
232 *isHashable = hashable;
233}
#define OidIsValid(objectId)
Definition: c.h:732
int errhint(const char *fmt,...)
Definition: elog.c:1317
char * format_type_be(Oid type_oid)
Definition: format_type.c:343
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:386
#define TYPECACHE_EQ_OPR
Definition: typcache.h:137
#define TYPECACHE_GT_OPR
Definition: typcache.h:139
#define TYPECACHE_LT_OPR
Definition: typcache.h:138
#define TYPECACHE_HASH_PROC
Definition: typcache.h:141

References TypeCacheEntry::eq_opr, ereport, errcode(), errhint(), errmsg(), ERROR, format_type_be(), TypeCacheEntry::gt_opr, TypeCacheEntry::hash_proc, lookup_type_cache(), TypeCacheEntry::lt_opr, OidIsValid, TYPECACHE_EQ_OPR, TYPECACHE_GT_OPR, TYPECACHE_HASH_PROC, and TYPECACHE_LT_OPR.

Referenced by addTargetToGroupList(), addTargetToSortList(), makeSortGroupClauseForSetOp(), and std_typanalyze().

◆ left_oper()

Operator left_oper ( ParseState pstate,
List op,
Oid  arg,
bool  noError,
int  location 
)

Definition at line 518 of file parse_oper.c.

519{
520 Oid operOid;
522 bool key_ok;
524 HeapTuple tup = NULL;
525
526 /*
527 * Try to find the mapping in the lookaside cache.
528 */
529 key_ok = make_oper_cache_key(pstate, &key, op, InvalidOid, arg, location);
530
531 if (key_ok)
532 {
533 operOid = find_oper_cache_entry(&key);
534 if (OidIsValid(operOid))
535 {
536 tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
537 if (HeapTupleIsValid(tup))
538 return (Operator) tup;
539 }
540 }
541
542 /*
543 * First try for an "exact" match.
544 */
545 operOid = OpernameGetOprid(op, InvalidOid, arg);
546 if (!OidIsValid(operOid))
547 {
548 /*
549 * Otherwise, search for the most suitable candidate.
550 */
551 FuncCandidateList clist;
552
553 /* Get prefix operators of given name */
554 clist = OpernameGetCandidates(op, 'l', false);
555
556 /* No operators found? Then fail... */
557 if (clist != NULL)
558 {
559 /*
560 * The returned list has args in the form (0, oprright). Move the
561 * useful data into args[0] to keep oper_select_candidate simple.
562 * XXX we are assuming here that we may scribble on the list!
563 */
564 FuncCandidateList clisti;
565
566 for (clisti = clist; clisti != NULL; clisti = clisti->next)
567 {
568 clisti->args[0] = clisti->args[1];
569 }
570
571 /*
572 * We must run oper_select_candidate even if only one candidate,
573 * otherwise we may falsely return a non-type-compatible operator.
574 */
575 fdresult = oper_select_candidate(1, &arg, clist, &operOid);
576 }
577 }
578
579 if (OidIsValid(operOid))
580 tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
581
582 if (HeapTupleIsValid(tup))
583 {
584 if (key_ok)
585 make_oper_cache_entry(&key, operOid);
586 }
587 else if (!noError)
588 op_error(pstate, op, InvalidOid, arg, fdresult, location);
589
590 return (Operator) tup;
591}
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1785
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1888
FuncDetailCode
Definition: parse_func.h:23
@ FUNCDETAIL_NOTFOUND
Definition: parse_func.h:24
static void make_oper_cache_entry(OprCacheKey *key, Oid opr_oid)
Definition: parse_oper.c:1020
static FuncDetailCode oper_select_candidate(int nargs, Oid *input_typeids, FuncCandidateList candidates, Oid *operOid)
Definition: parse_oper.c:312
static bool make_oper_cache_key(ParseState *pstate, OprCacheKey *key, List *opname, Oid ltypeId, Oid rtypeId, int location)
Definition: parse_oper.c:937
static void op_error(ParseState *pstate, List *op, Oid arg1, Oid arg2, FuncDetailCode fdresult, int location)
Definition: parse_oper.c:622
static Oid find_oper_cache_entry(OprCacheKey *key)
Definition: parse_oper.c:981
void * arg
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:257
struct _FuncCandidateList * next
Definition: namespace.h:31
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:39
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:221

References arg, _FuncCandidateList::args, find_oper_cache_entry(), FUNCDETAIL_NOTFOUND, HeapTupleIsValid, InvalidOid, sort-test::key, make_oper_cache_entry(), make_oper_cache_key(), _FuncCandidateList::next, ObjectIdGetDatum(), OidIsValid, op_error(), oper_select_candidate(), OpernameGetCandidates(), OpernameGetOprid(), and SearchSysCache1().

Referenced by generate_operator_name(), and make_op().

◆ LookupOperName()

Oid LookupOperName ( ParseState pstate,
List opername,
Oid  oprleft,
Oid  oprright,
bool  noError,
int  location 
)

Definition at line 99 of file parse_oper.c.

101{
102 Oid result;
103
104 result = OpernameGetOprid(opername, oprleft, oprright);
105 if (OidIsValid(result))
106 return result;
107
108 /* we don't use op_error here because only an exact match is wanted */
109 if (!noError)
110 {
111 if (!OidIsValid(oprright))
113 (errcode(ERRCODE_SYNTAX_ERROR),
114 errmsg("postfix operators are not supported"),
115 parser_errposition(pstate, location)));
116
118 (errcode(ERRCODE_UNDEFINED_FUNCTION),
119 errmsg("operator does not exist: %s",
120 op_signature_string(opername, oprleft, oprright)),
121 parser_errposition(pstate, location)));
122 }
123
124 return InvalidOid;
125}

References ereport, errcode(), errmsg(), ERROR, InvalidOid, OidIsValid, op_signature_string(), OpernameGetOprid(), and parser_errposition().

Referenced by AggregateCreate(), DefineOpClass(), LookupOperWithArgs(), and OperatorLookup().

◆ LookupOperWithArgs()

Oid LookupOperWithArgs ( ObjectWithArgs oper,
bool  noError 
)

Definition at line 133 of file parse_oper.c.

134{
135 TypeName *oprleft,
136 *oprright;
137 Oid leftoid,
138 rightoid;
139
140 Assert(list_length(oper->objargs) == 2);
141 oprleft = linitial_node(TypeName, oper->objargs);
142 oprright = lsecond_node(TypeName, oper->objargs);
143
144 if (oprleft == NULL)
145 leftoid = InvalidOid;
146 else
147 leftoid = LookupTypeNameOid(NULL, oprleft, noError);
148
149 if (oprright == NULL)
150 rightoid = InvalidOid;
151 else
152 rightoid = LookupTypeNameOid(NULL, oprright, noError);
153
154 return LookupOperName(NULL, oper->objname, leftoid, rightoid,
155 noError, -1);
156}
#define Assert(condition)
Definition: c.h:815
Oid LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright, bool noError, int location)
Definition: parse_oper.c:99
Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
Definition: parse_type.c:232
static int list_length(const List *l)
Definition: pg_list.h:152
#define linitial_node(type, l)
Definition: pg_list.h:181
#define lsecond_node(type, l)
Definition: pg_list.h:186

References Assert, InvalidOid, linitial_node, list_length(), LookupOperName(), LookupTypeNameOid(), lsecond_node, and oper().

Referenced by AlterOperator(), AlterOpFamilyAdd(), DefineOpClass(), and get_object_address().

◆ make_op()

Expr * make_op ( ParseState pstate,
List opname,
Node ltree,
Node rtree,
Node last_srf,
int  location 
)

Definition at line 660 of file parse_oper.c.

662{
663 Oid ltypeId,
664 rtypeId;
665 Operator tup;
666 Form_pg_operator opform;
667 Oid actual_arg_types[2];
668 Oid declared_arg_types[2];
669 int nargs;
670 List *args;
671 Oid rettype;
672 OpExpr *result;
673
674 /* Check it's not a postfix operator */
675 if (rtree == NULL)
677 (errcode(ERRCODE_SYNTAX_ERROR),
678 errmsg("postfix operators are not supported")));
679
680 /* Select the operator */
681 if (ltree == NULL)
682 {
683 /* prefix operator */
684 rtypeId = exprType(rtree);
685 ltypeId = InvalidOid;
686 tup = left_oper(pstate, opname, rtypeId, false, location);
687 }
688 else
689 {
690 /* otherwise, binary operator */
691 ltypeId = exprType(ltree);
692 rtypeId = exprType(rtree);
693 tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
694 }
695
696 opform = (Form_pg_operator) GETSTRUCT(tup);
697
698 /* Check it's not a shell */
699 if (!RegProcedureIsValid(opform->oprcode))
701 (errcode(ERRCODE_UNDEFINED_FUNCTION),
702 errmsg("operator is only a shell: %s",
703 op_signature_string(opname,
704 opform->oprleft,
705 opform->oprright)),
706 parser_errposition(pstate, location)));
707
708 /* Do typecasting and build the expression tree */
709 if (ltree == NULL)
710 {
711 /* prefix operator */
712 args = list_make1(rtree);
713 actual_arg_types[0] = rtypeId;
714 declared_arg_types[0] = opform->oprright;
715 nargs = 1;
716 }
717 else
718 {
719 /* otherwise, binary operator */
720 args = list_make2(ltree, rtree);
721 actual_arg_types[0] = ltypeId;
722 actual_arg_types[1] = rtypeId;
723 declared_arg_types[0] = opform->oprleft;
724 declared_arg_types[1] = opform->oprright;
725 nargs = 2;
726 }
727
728 /*
729 * enforce consistency with polymorphic argument and return types,
730 * possibly adjusting return type or declared_arg_types (which will be
731 * used as the cast destination by make_fn_arguments)
732 */
733 rettype = enforce_generic_type_consistency(actual_arg_types,
734 declared_arg_types,
735 nargs,
736 opform->oprresult,
737 false);
738
739 /* perform the necessary typecasting of arguments */
740 make_fn_arguments(pstate, args, actual_arg_types, declared_arg_types);
741
742 /* and build the expression node */
743 result = makeNode(OpExpr);
744 result->opno = oprid(tup);
745 result->opfuncid = opform->oprcode;
746 result->opresulttype = rettype;
747 result->opretset = get_func_retset(opform->oprcode);
748 /* opcollid and inputcollid will be set by parse_collate.c */
749 result->args = args;
750 result->location = location;
751
752 /* if it returns a set, check that's OK */
753 if (result->opretset)
754 {
755 check_srf_call_placement(pstate, last_srf, location);
756 /* ... and remember it for error checks at higher levels */
757 pstate->p_last_srf = (Node *) result;
758 }
759
760 ReleaseSysCache(tup);
761
762 return (Expr *) result;
763}
#define RegProcedureIsValid(p)
Definition: c.h:734
bool get_func_retset(Oid funcid)
Definition: lsyscache.c:1742
Oid exprType(const Node *expr)
Definition: nodeFuncs.c:42
#define makeNode(_type_)
Definition: nodes.h:155
Oid enforce_generic_type_consistency(const Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
void make_fn_arguments(ParseState *pstate, List *fargs, Oid *actual_arg_types, Oid *declared_arg_types)
Definition: parse_func.c:1825
void check_srf_call_placement(ParseState *pstate, Node *last_srf, int location)
Definition: parse_func.c:2511
Operator left_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
Definition: parse_oper.c:518
#define list_make1(x1)
Definition: pg_list.h:212
#define list_make2(x1, x2)
Definition: pg_list.h:214
Definition: pg_list.h:54
Definition: nodes.h:129
Oid opno
Definition: primnodes.h:834
List * args
Definition: primnodes.h:852
ParseLoc location
Definition: primnodes.h:855
Node * p_last_srf
Definition: parse_node.h:248
Definition: ltree.h:43

References generate_unaccent_rules::args, OpExpr::args, check_srf_call_placement(), enforce_generic_type_consistency(), ereport, errcode(), errmsg(), ERROR, exprType(), get_func_retset(), GETSTRUCT, InvalidOid, left_oper(), list_make1, list_make2, OpExpr::location, make_fn_arguments(), makeNode, op_signature_string(), oper(), OpExpr::opno, oprid(), ParseState::p_last_srf, parser_errposition(), RegProcedureIsValid, and ReleaseSysCache().

Referenced by make_distinct_op(), make_row_comparison_op(), transformAExprIn(), transformAExprNullIf(), and transformAExprOp().

◆ make_scalar_array_op()

Expr * make_scalar_array_op ( ParseState pstate,
List opname,
bool  useOr,
Node ltree,
Node rtree,
int  location 
)

Definition at line 770 of file parse_oper.c.

774{
775 Oid ltypeId,
776 rtypeId,
777 atypeId,
778 res_atypeId;
779 Operator tup;
780 Form_pg_operator opform;
781 Oid actual_arg_types[2];
782 Oid declared_arg_types[2];
783 List *args;
784 Oid rettype;
785 ScalarArrayOpExpr *result;
786
787 ltypeId = exprType(ltree);
788 atypeId = exprType(rtree);
789
790 /*
791 * The right-hand input of the operator will be the element type of the
792 * array. However, if we currently have just an untyped literal on the
793 * right, stay with that and hope we can resolve the operator.
794 */
795 if (atypeId == UNKNOWNOID)
796 rtypeId = UNKNOWNOID;
797 else
798 {
799 rtypeId = get_base_element_type(atypeId);
800 if (!OidIsValid(rtypeId))
802 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
803 errmsg("op ANY/ALL (array) requires array on right side"),
804 parser_errposition(pstate, location)));
805 }
806
807 /* Now resolve the operator */
808 tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
809 opform = (Form_pg_operator) GETSTRUCT(tup);
810
811 /* Check it's not a shell */
812 if (!RegProcedureIsValid(opform->oprcode))
814 (errcode(ERRCODE_UNDEFINED_FUNCTION),
815 errmsg("operator is only a shell: %s",
816 op_signature_string(opname,
817 opform->oprleft,
818 opform->oprright)),
819 parser_errposition(pstate, location)));
820
821 args = list_make2(ltree, rtree);
822 actual_arg_types[0] = ltypeId;
823 actual_arg_types[1] = rtypeId;
824 declared_arg_types[0] = opform->oprleft;
825 declared_arg_types[1] = opform->oprright;
826
827 /*
828 * enforce consistency with polymorphic argument and return types,
829 * possibly adjusting return type or declared_arg_types (which will be
830 * used as the cast destination by make_fn_arguments)
831 */
832 rettype = enforce_generic_type_consistency(actual_arg_types,
833 declared_arg_types,
834 2,
835 opform->oprresult,
836 false);
837
838 /*
839 * Check that operator result is boolean
840 */
841 if (rettype != BOOLOID)
843 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
844 errmsg("op ANY/ALL (array) requires operator to yield boolean"),
845 parser_errposition(pstate, location)));
846 if (get_func_retset(opform->oprcode))
848 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
849 errmsg("op ANY/ALL (array) requires operator not to return a set"),
850 parser_errposition(pstate, location)));
851
852 /*
853 * Now switch back to the array type on the right, arranging for any
854 * needed cast to be applied. Beware of polymorphic operators here;
855 * enforce_generic_type_consistency may or may not have replaced a
856 * polymorphic type with a real one.
857 */
858 if (IsPolymorphicType(declared_arg_types[1]))
859 {
860 /* assume the actual array type is OK */
861 res_atypeId = atypeId;
862 }
863 else
864 {
865 res_atypeId = get_array_type(declared_arg_types[1]);
866 if (!OidIsValid(res_atypeId))
868 (errcode(ERRCODE_UNDEFINED_OBJECT),
869 errmsg("could not find array type for data type %s",
870 format_type_be(declared_arg_types[1])),
871 parser_errposition(pstate, location)));
872 }
873 actual_arg_types[1] = atypeId;
874 declared_arg_types[1] = res_atypeId;
875
876 /* perform the necessary typecasting of arguments */
877 make_fn_arguments(pstate, args, actual_arg_types, declared_arg_types);
878
879 /* and build the expression node */
880 result = makeNode(ScalarArrayOpExpr);
881 result->opno = oprid(tup);
882 result->opfuncid = opform->oprcode;
883 result->hashfuncid = InvalidOid;
884 result->negfuncid = InvalidOid;
885 result->useOr = useOr;
886 /* inputcollid will be set by parse_collate.c */
887 result->args = args;
888 result->location = location;
889
890 ReleaseSysCache(tup);
891
892 return (Expr *) result;
893}
Oid get_base_element_type(Oid typid)
Definition: lsyscache.c:2832
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2787
ParseLoc location
Definition: primnodes.h:935

References generate_unaccent_rules::args, ScalarArrayOpExpr::args, enforce_generic_type_consistency(), ereport, errcode(), errmsg(), ERROR, exprType(), format_type_be(), get_array_type(), get_base_element_type(), get_func_retset(), GETSTRUCT, InvalidOid, list_make2, ScalarArrayOpExpr::location, make_fn_arguments(), makeNode, OidIsValid, op_signature_string(), oper(), ScalarArrayOpExpr::opno, oprid(), parser_errposition(), RegProcedureIsValid, ReleaseSysCache(), and ScalarArrayOpExpr::useOr.

Referenced by transformAExprIn(), transformAExprOpAll(), and transformAExprOpAny().

◆ op_signature_string()

const char * op_signature_string ( List op,
Oid  arg1,
Oid  arg2 
)

Definition at line 602 of file parse_oper.c.

603{
604 StringInfoData argbuf;
605
606 initStringInfo(&argbuf);
607
608 if (OidIsValid(arg1))
609 appendStringInfo(&argbuf, "%s ", format_type_be(arg1));
610
612
613 appendStringInfo(&argbuf, " %s", format_type_be(arg2));
614
615 return argbuf.data; /* return palloc'd string buffer */
616}
char * NameListToString(const List *names)
Definition: namespace.c:3594
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97

References appendStringInfo(), appendStringInfoString(), StringInfoData::data, format_type_be(), initStringInfo(), NameListToString(), and OidIsValid.

Referenced by compatible_oper(), LookupOperName(), make_op(), make_scalar_array_op(), op_error(), and ValidateOperatorReference().

◆ oper()

Operator oper ( ParseState pstate,
List opname,
Oid  ltypeId,
Oid  rtypeId,
bool  noError,
int  location 
)

Definition at line 370 of file parse_oper.c.

372{
373 Oid operOid;
375 bool key_ok;
377 HeapTuple tup = NULL;
378
379 /*
380 * Try to find the mapping in the lookaside cache.
381 */
382 key_ok = make_oper_cache_key(pstate, &key, opname, ltypeId, rtypeId, location);
383
384 if (key_ok)
385 {
386 operOid = find_oper_cache_entry(&key);
387 if (OidIsValid(operOid))
388 {
389 tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
390 if (HeapTupleIsValid(tup))
391 return (Operator) tup;
392 }
393 }
394
395 /*
396 * First try for an "exact" match.
397 */
398 operOid = binary_oper_exact(opname, ltypeId, rtypeId);
399 if (!OidIsValid(operOid))
400 {
401 /*
402 * Otherwise, search for the most suitable candidate.
403 */
404 FuncCandidateList clist;
405
406 /* Get binary operators of given name */
407 clist = OpernameGetCandidates(opname, 'b', false);
408
409 /* No operators found? Then fail... */
410 if (clist != NULL)
411 {
412 /*
413 * Unspecified type for one of the arguments? then use the other
414 * (XXX this is probably dead code?)
415 */
416 Oid inputOids[2];
417
418 if (rtypeId == InvalidOid)
419 rtypeId = ltypeId;
420 else if (ltypeId == InvalidOid)
421 ltypeId = rtypeId;
422 inputOids[0] = ltypeId;
423 inputOids[1] = rtypeId;
424 fdresult = oper_select_candidate(2, inputOids, clist, &operOid);
425 }
426 }
427
428 if (OidIsValid(operOid))
429 tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
430
431 if (HeapTupleIsValid(tup))
432 {
433 if (key_ok)
434 make_oper_cache_entry(&key, operOid);
435 }
436 else if (!noError)
437 op_error(pstate, opname, ltypeId, rtypeId, fdresult, location);
438
439 return (Operator) tup;
440}
static Oid binary_oper_exact(List *opname, Oid arg1, Oid arg2)
Definition: parse_oper.c:262

References binary_oper_exact(), find_oper_cache_entry(), FUNCDETAIL_NOTFOUND, HeapTupleIsValid, InvalidOid, sort-test::key, make_oper_cache_entry(), make_oper_cache_key(), ObjectIdGetDatum(), OidIsValid, op_error(), oper_select_candidate(), OpernameGetCandidates(), and SearchSysCache1().

Referenced by compatible_oper(), Do_MultiXactIdWait(), generate_operator_name(), LookupOperWithArgs(), make_op(), make_scalar_array_op(), makeOperatorDependencies(), multi_sort_add_dimension(), MultiXactIdWait(), pushOperator(), tsquery_opr_selec(), tsqueryrecv(), and XactLockTableWait().

◆ oprfuncid()

Oid oprfuncid ( Operator  op)

Definition at line 245 of file parse_oper.c.

246{
248
249 return pgopform->oprcode;
250}

References GETSTRUCT.

◆ oprid()