49 #define MAX_CACHED_PATH_LEN 16
100 bool noError,
int location)
113 (
errcode(ERRCODE_SYNTAX_ERROR),
114 errmsg(
"postfix operators are not supported"),
118 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
119 errmsg(
"operator does not exist: %s",
149 if (oprright == NULL)
181 bool needLT,
bool needEQ,
bool needGT,
198 if (isHashable != NULL)
205 lt_opr = typentry->
lt_opr;
206 eq_opr = typentry->
eq_opr;
207 gt_opr = typentry->
gt_opr;
214 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
215 errmsg(
"could not identify an ordering operator for type %s",
217 errhint(
"Use an explicit ordering operator or modify the query.")));
220 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
221 errmsg(
"could not identify an equality operator for type %s",
232 *isHashable = hashable;
249 return pgopform->oprcode;
265 bool was_unknown =
false;
268 if ((arg1 == UNKNOWNOID) && (arg2 !=
InvalidOid))
273 else if ((arg2 == UNKNOWNOID) && (arg1 !=
InvalidOid))
288 if (basetype != arg1)
324 candidates, &candidates);
327 if (ncandidates == 0)
332 if (ncandidates == 1)
334 *operOid = candidates->
oid;
346 *operOid = candidates->
oid;
371 bool noError,
int location)
422 inputOids[0] = ltypeId;
423 inputOids[1] = rtypeId;
437 op_error(pstate, opname, ltypeId, rtypeId, fdresult, location);
451 bool noError,
int location)
457 optup =
oper(pstate, op, arg1, arg2, noError, location);
472 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
473 errmsg(
"operator requires run-time type coercion: %s",
495 result =
oprid(optup);
566 for (clisti = clist; clisti != NULL; clisti = clisti->
next)
628 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
629 errmsg(
"operator is not unique: %s",
631 errhint(
"Could not choose a best candidate operator. "
632 "You might need to add explicit type casts."),
636 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
637 errmsg(
"operator does not exist: %s",
640 errhint(
"No operator matches the given name and argument type. "
641 "You might need to add an explicit type cast.") :
642 errhint(
"No operator matches the given name and argument types. "
643 "You might need to add explicit type casts."),
661 Node *last_srf,
int location)
667 Oid actual_arg_types[2];
668 Oid declared_arg_types[2];
677 (
errcode(ERRCODE_SYNTAX_ERROR),
678 errmsg(
"postfix operators are not supported")));
686 tup =
left_oper(pstate, opname, rtypeId,
false, location);
693 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
701 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
702 errmsg(
"operator is only a shell: %s",
713 actual_arg_types[0] = rtypeId;
714 declared_arg_types[0] = opform->oprright;
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;
745 result->opfuncid = opform->oprcode;
746 result->opresulttype = rettype;
753 if (result->opretset)
762 return (
Expr *) result;
781 Oid actual_arg_types[2];
782 Oid declared_arg_types[2];
795 if (atypeId == UNKNOWNOID)
796 rtypeId = UNKNOWNOID;
802 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
803 errmsg(
"op ANY/ALL (array) requires array on right side"),
808 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
814 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
815 errmsg(
"operator is only a shell: %s",
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;
841 if (rettype != BOOLOID)
843 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
844 errmsg(
"op ANY/ALL (array) requires operator to yield boolean"),
848 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
849 errmsg(
"op ANY/ALL (array) requires operator not to return a set"),
858 if (IsPolymorphicType(declared_arg_types[1]))
861 res_atypeId = atypeId;
868 (
errcode(ERRCODE_UNDEFINED_OBJECT),
869 errmsg(
"could not find array type for data type %s",
873 actual_arg_types[1] = atypeId;
874 declared_arg_types[1] = res_atypeId;
882 result->opfuncid = opform->oprcode;
885 result->
useOr = useOr;
892 return (
Expr *) result;
938 Oid ltypeId,
Oid rtypeId,
int location)
951 key->left_arg = ltypeId;
952 key->right_arg = rtypeId;
1008 if (oprentry == NULL)
#define RegProcedureIsValid(p)
#define Assert(condition)
#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, long 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 errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define HeapTupleIsValid(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)
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
void DeconstructQualifiedName(const List *names, char **nspname_p, char **objname_p)
char * NameListToString(const List *names)
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
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
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)
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
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
struct OprCacheEntry OprCacheEntry
const char * op_signature_string(List *op, Oid arg1, Oid arg2)
static Oid binary_oper_exact(List *opname, Oid arg1, Oid arg2)
static void op_error(ParseState *pstate, List *op, Oid arg1, Oid arg2, FuncDetailCode fdresult, int location)
static Oid find_oper_cache_entry(OprCacheKey *key)
Expr * make_scalar_array_op(ParseState *pstate, List *opname, bool useOr, Node *ltree, Node *rtree, int location)
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