49#define MAX_CACHED_PATH_LEN 16
101 bool noError,
int location)
114 (
errcode(ERRCODE_SYNTAX_ERROR),
115 errmsg(
"postfix operators are not supported"),
119 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
120 errmsg(
"operator does not exist: %s",
150 if (oprright == NULL)
182 bool needLT,
bool needEQ,
bool needGT,
199 if (isHashable != NULL)
206 lt_opr = typentry->
lt_opr;
207 eq_opr = typentry->
eq_opr;
208 gt_opr = typentry->
gt_opr;
215 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
216 errmsg(
"could not identify an ordering operator for type %s",
218 errhint(
"Use an explicit ordering operator or modify the query.")));
221 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
222 errmsg(
"could not identify an equality operator for type %s",
233 *isHashable = hashable;
250 return pgopform->oprcode;
266 bool was_unknown =
false;
269 if ((arg1 == UNKNOWNOID) && (arg2 !=
InvalidOid))
274 else if ((arg2 == UNKNOWNOID) && (arg1 !=
InvalidOid))
289 if (basetype != arg1)
325 candidates, &candidates);
328 if (ncandidates == 0)
333 if (ncandidates == 1)
335 *operOid = candidates->
oid;
347 *operOid = candidates->
oid;
372 bool noError,
int location)
424 inputOids[0] = ltypeId;
425 inputOids[1] = rtypeId;
439 op_error(pstate, opname, ltypeId, rtypeId,
440 fdresult, fgc_flags, location);
454 bool noError,
int location)
460 optup =
oper(pstate, op, arg1, arg2, noError, location);
475 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
476 errmsg(
"operator requires run-time type coercion: %s",
498 result =
oprid(optup);
570 for (clisti = clist; clisti != NULL; clisti = clisti->
next)
593 fdresult, fgc_flags, location);
633 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
634 errmsg(
"operator is not unique: %s",
636 errdetail(
"Could not choose a best candidate operator."),
637 errhint(
"You might need to add explicit type casts."),
641 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
642 errmsg(
"operator does not exist: %s",
670 return errdetail(
"There is no operator of that name.");
672 return errdetail(
"An operator of that name exists, but it is not in the search_path.");
680 (void)
errdetail(
"No operator of that name accepts the given argument type.");
681 return errhint(
"You might need to add an explicit type cast.");
685 (void)
errdetail(
"No operator of that name accepts the given argument types.");
686 return errhint(
"You might need to add explicit type casts.");
704 Node *last_srf,
int location)
710 Oid actual_arg_types[2];
711 Oid declared_arg_types[2];
720 (
errcode(ERRCODE_SYNTAX_ERROR),
721 errmsg(
"postfix operators are not supported")));
729 tup =
left_oper(pstate, opname, rtypeId,
false, location);
736 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
744 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
745 errmsg(
"operator is only a shell: %s",
756 actual_arg_types[0] = rtypeId;
757 declared_arg_types[0] = opform->oprright;
764 actual_arg_types[0] = ltypeId;
765 actual_arg_types[1] = rtypeId;
766 declared_arg_types[0] = opform->oprleft;
767 declared_arg_types[1] = opform->oprright;
788 result->opfuncid = opform->oprcode;
789 result->opresulttype = rettype;
796 if (result->opretset)
805 return (
Expr *) result;
824 Oid actual_arg_types[2];
825 Oid declared_arg_types[2];
838 if (atypeId == UNKNOWNOID)
839 rtypeId = UNKNOWNOID;
845 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
846 errmsg(
"op ANY/ALL (array) requires array on right side"),
851 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
857 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
858 errmsg(
"operator is only a shell: %s",
865 actual_arg_types[0] = ltypeId;
866 actual_arg_types[1] = rtypeId;
867 declared_arg_types[0] = opform->oprleft;
868 declared_arg_types[1] = opform->oprright;
884 if (rettype != BOOLOID)
886 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
887 errmsg(
"op ANY/ALL (array) requires operator to yield boolean"),
891 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
892 errmsg(
"op ANY/ALL (array) requires operator not to return a set"),
901 if (IsPolymorphicType(declared_arg_types[1]))
904 res_atypeId = atypeId;
911 (
errcode(ERRCODE_UNDEFINED_OBJECT),
912 errmsg(
"could not find array type for data type %s",
916 actual_arg_types[1] = atypeId;
917 declared_arg_types[1] = res_atypeId;
925 result->opfuncid = opform->oprcode;
928 result->
useOr = useOr;
935 return (
Expr *) result;
981 Oid ltypeId,
Oid rtypeId,
int location)
994 key->left_arg = ltypeId;
995 key->right_arg = rtypeId;
1051 if (oprentry == NULL)
#define RegProcedureIsValid(p)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Assert(PointerIsAligned(start, uint64))
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CacheRegisterSyscacheCallback(int cacheid, SyscacheCallbackFunction func, Datum arg)
bool get_func_retset(Oid funcid)
Oid get_base_element_type(Oid typid)
Oid getBaseType(Oid typid)
Oid get_array_type(Oid typid)
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
char * NameListToString(const List *names)
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
void DeconstructQualifiedName(const List *names, char **nspname_p, char **objname_p)
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok, int *fgc_flags)
int fetch_search_path_array(Oid *sarray, int sarray_len)
Oid exprType(const Node *expr)
Oid enforce_generic_type_consistency(const Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
void make_fn_arguments(ParseState *pstate, List *fargs, Oid *actual_arg_types, Oid *declared_arg_types)
FuncCandidateList func_select_candidate(int nargs, Oid *input_typeids, FuncCandidateList candidates)
void check_srf_call_placement(ParseState *pstate, Node *last_srf, int location)
int func_match_argtypes(int nargs, Oid *input_typeids, FuncCandidateList raw_candidates, FuncCandidateList *candidates)
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
int parser_errposition(ParseState *pstate, int location)
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
static void InvalidateOprCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
static void make_oper_cache_entry(OprCacheKey *key, Oid opr_oid)
static FuncDetailCode oper_select_candidate(int nargs, Oid *input_typeids, FuncCandidateList candidates, Oid *operOid)
Operator left_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
void get_sort_group_operators(Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
#define MAX_CACHED_PATH_LEN
static int oper_lookup_failure_details(int fgc_flags, bool is_unary_op)
Expr * make_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree, Node *last_srf, int location)
Oid LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright, bool noError, int location)
Expr * make_scalar_array_op(ParseState *pstate, List *opname, bool useOr, Node *ltree, Node *rtree, int location)
Oid oprfuncid(Operator op)
static bool make_oper_cache_key(ParseState *pstate, OprCacheKey *key, List *opname, Oid ltypeId, Oid rtypeId, int location)
static HTAB * OprCacheHash
static void op_error(ParseState *pstate, List *op, Oid arg1, Oid arg2, FuncDetailCode fdresult, int fgc_flags, int location)
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
struct OprCacheEntry OprCacheEntry
static Oid binary_oper_exact(List *opname, Oid arg1, Oid arg2)
static Oid find_oper_cache_entry(OprCacheKey *key)
const char * op_signature_string(List *op, Oid arg1, Oid arg2)
Oid compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError)
Operator compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2, bool noError, int location)
Oid LookupOperWithArgs(ObjectWithArgs *oper, bool noError)
struct OprCacheKey OprCacheKey
Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
static int list_length(const List *l)
#define linitial_node(type, l)
#define lsecond_node(type, l)
#define list_make2(x1, x2)
FormData_pg_operator * Form_pg_operator
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum ObjectIdGetDatum(Oid X)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
Oid search_path[MAX_CACHED_PATH_LEN]
char oprname[NAMEDATALEN]
struct _FuncCandidateList * next
Oid args[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_HASH_PROC