49 #define MAX_CACHED_PATH_LEN 16
103 bool noError,
int location)
124 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
125 errmsg(
"operator does not exist: %s",
144 bool noError,
int location)
154 if (oprright ==
NULL)
186 bool needLT,
bool needEQ,
bool needGT,
203 if (isHashable !=
NULL)
210 lt_opr = typentry->
lt_opr;
211 eq_opr = typentry->
eq_opr;
212 gt_opr = typentry->
gt_opr;
219 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
220 errmsg(
"could not identify an ordering operator for type %s",
222 errhint(
"Use an explicit ordering operator or modify the query.")));
225 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
226 errmsg(
"could not identify an equality operator for type %s",
237 *isHashable = hashable;
254 return pgopform->oprcode;
270 bool was_unknown =
false;
293 if (basetype != arg1)
329 candidates, &candidates);
332 if (ncandidates == 0)
337 if (ncandidates == 1)
339 *operOid = candidates->
oid;
351 *operOid = candidates->
oid;
376 bool noError,
int location)
427 inputOids[0] = ltypeId;
428 inputOids[1] = rtypeId;
442 op_error(pstate, opname,
'b', ltypeId, rtypeId, fdresult, location);
456 bool noError,
int location)
462 optup =
oper(pstate, op, arg1, arg2, noError, location);
477 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
478 errmsg(
"operator requires run-time type coercion: %s",
500 result =
oprid(optup);
650 for (clisti = clist; clisti !=
NULL; clisti = clisti->
next)
713 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
714 errmsg(
"operator is not unique: %s",
716 errhint(
"Could not choose a best candidate operator. "
717 "You might need to add explicit type casts."),
721 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
722 errmsg(
"operator does not exist: %s",
724 errhint(
"No operator matches the given name and argument type(s). "
725 "You might need to add explicit type casts."),
747 Oid actual_arg_types[2];
748 Oid declared_arg_types[2];
760 tup =
right_oper(pstate, opname, ltypeId,
false, location);
762 else if (ltree ==
NULL)
767 tup =
left_oper(pstate, opname, rtypeId,
false, location);
774 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
782 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
783 errmsg(
"operator is only a shell: %s",
795 actual_arg_types[0] = ltypeId;
796 declared_arg_types[0] = opform->oprleft;
799 else if (ltree ==
NULL)
803 actual_arg_types[0] = rtypeId;
804 declared_arg_types[0] = opform->oprright;
811 actual_arg_types[0] = ltypeId;
812 actual_arg_types[1] = rtypeId;
813 declared_arg_types[0] = opform->oprleft;
814 declared_arg_types[1] = opform->oprright;
844 return (
Expr *) result;
863 Oid actual_arg_types[2];
864 Oid declared_arg_types[2];
884 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
885 errmsg(
"op ANY/ALL (array) requires array on right side"),
890 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
896 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
897 errmsg(
"operator is only a shell: %s",
905 actual_arg_types[0] = ltypeId;
906 actual_arg_types[1] = rtypeId;
907 declared_arg_types[0] = opform->oprleft;
908 declared_arg_types[1] = opform->oprright;
926 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
927 errmsg(
"op ANY/ALL (array) requires operator to yield boolean"),
931 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
932 errmsg(
"op ANY/ALL (array) requires operator not to return a set"),
944 res_atypeId = atypeId;
951 (
errcode(ERRCODE_UNDEFINED_OBJECT),
952 errmsg(
"could not find array type for data type %s",
956 actual_arg_types[1] = atypeId;
957 declared_arg_types[1] = res_atypeId;
966 result->
useOr = useOr;
973 return (
Expr *) result;
1019 Oid ltypeId,
Oid rtypeId,
int location)
1066 if (OprCacheHash ==
NULL)
1071 MemSet(&ctl, 0,
sizeof(ctl));
1074 OprCacheHash =
hash_create(
"Operator lookup cache", 256,
1090 if (oprentry ==
NULL)
1131 (
void *) &hentry->
key,
#define list_make2(x1, x2)
Oid LookupOperNameTypeNames(ParseState *pstate, List *opername, TypeName *oprleft, TypeName *oprright, bool noError, int location)
static void InvalidateOprCacheCallBack(Datum arg, int cacheid, uint32 hashvalue)
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
int errhint(const char *fmt,...)
Expr * make_scalar_array_op(ParseState *pstate, List *opname, bool useOr, Node *ltree, Node *rtree, int location)
int func_match_argtypes(int nargs, Oid *input_typeids, FuncCandidateList raw_candidates, FuncCandidateList *candidates)
Oid get_array_type(Oid typid)
int errcode(int sqlerrcode)
#define MemSet(start, val, len)
Expr * make_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree, int location)
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Oid LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright, bool noError, int location)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
void make_fn_arguments(ParseState *pstate, List *fargs, Oid *actual_arg_types, Oid *declared_arg_types)
Oid oprfuncid(Operator op)
static const char * op_signature_string(List *op, char oprkind, Oid arg1, Oid arg2)
#define OidIsValid(objectId)
int fetch_search_path_array(Oid *sarray, int sarray_len)
#define SearchSysCache1(cacheId, key1)
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Oid args[FLEXIBLE_ARRAY_MEMBER]
void cancel_parser_errposition_callback(ParseCallbackState *pcbstate)
void appendStringInfo(StringInfo str, const char *fmt,...)
#define ObjectIdGetDatum(X)
#define IsPolymorphicType(typid)
Oid enforce_generic_type_consistency(Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
Operator left_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
Operator right_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
void appendStringInfoString(StringInfo str, const char *s)
Oid search_path[MAX_CACHED_PATH_LEN]
struct OprCacheKey OprCacheKey
#define RegProcedureIsValid(p)
static Oid find_oper_cache_entry(OprCacheKey *key)
static Oid binary_oper_exact(List *opname, Oid arg1, Oid arg2)
struct OprCacheEntry OprCacheEntry
struct _FuncCandidateList * next
#define ereport(elevel, rest)
Operator compatible_oper(ParseState *pstate, List *op, Oid arg1, Oid arg2, bool noError, int location)
void setup_parser_errposition_callback(ParseCallbackState *pcbstate, ParseState *pstate, int location)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
char oprname[NAMEDATALEN]
void initStringInfo(StringInfo str)
char * NameListToString(List *names)
bool get_func_retset(Oid funcid)
void CacheRegisterSyscacheCallback(int cacheid, SyscacheCallbackFunction func, Datum arg)
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
static void op_error(ParseState *pstate, List *op, char oprkind, Oid arg1, Oid arg2, FuncDetailCode fdresult, int location)
void ReleaseSysCache(HeapTuple tuple)
static void make_oper_cache_entry(OprCacheKey *key, Oid opr_oid)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define HeapTupleIsValid(tuple)
#define Assert(condition)
void get_sort_group_operators(Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
static bool make_oper_cache_key(ParseState *pstate, OprCacheKey *key, List *opname, Oid ltypeId, Oid rtypeId, int location)
Oid exprType(const Node *expr)
int parser_errposition(ParseState *pstate, int location)
void * hash_seq_search(HASH_SEQ_STATUS *status)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
FormData_pg_operator* Form_pg_operator
static FuncDetailCode oper_select_candidate(int nargs, Oid *input_typeids, FuncCandidateList candidates, Oid *operOid)
Oid get_base_element_type(Oid typid)
FuncCandidateList func_select_candidate(int nargs, Oid *input_typeids, FuncCandidateList candidates)
int errmsg(const char *fmt,...)
Oid compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError)
#define MAX_CACHED_PATH_LEN
#define HeapTupleGetOid(tuple)
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
static void static void status(const char *fmt,...) pg_attribute_printf(1
Oid getBaseType(Oid typid)
#define TYPECACHE_HASH_PROC
static HTAB * OprCacheHash
Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)