49 #define MAX_CACHED_PATH_LEN 16
102 bool noError,
int location)
122 (
errcode(ERRCODE_SYNTAX_ERROR),
123 errmsg(
"postfix operators are not supported"),
129 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
130 errmsg(
"operator does not exist: %s",
161 if (oprright == NULL)
193 bool needLT,
bool needEQ,
bool needGT,
210 if (isHashable != NULL)
217 lt_opr = typentry->
lt_opr;
218 eq_opr = typentry->
eq_opr;
219 gt_opr = typentry->
gt_opr;
226 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
227 errmsg(
"could not identify an ordering operator for type %s",
229 errhint(
"Use an explicit ordering operator or modify the query.")));
232 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
233 errmsg(
"could not identify an equality operator for type %s",
244 *isHashable = hashable;
261 return pgopform->oprcode;
277 bool was_unknown =
false;
280 if ((arg1 == UNKNOWNOID) && (arg2 !=
InvalidOid))
285 else if ((arg2 == UNKNOWNOID) && (arg1 !=
InvalidOid))
300 if (basetype != arg1)
336 candidates, &candidates);
339 if (ncandidates == 0)
344 if (ncandidates == 1)
346 *operOid = candidates->
oid;
358 *operOid = candidates->
oid;
383 bool noError,
int location)
434 inputOids[0] = ltypeId;
435 inputOids[1] = rtypeId;
449 op_error(pstate, opname,
'b', ltypeId, rtypeId, fdresult, location);
463 bool noError,
int location)
469 optup =
oper(pstate, op, arg1, arg2, noError, location);
484 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
485 errmsg(
"operator requires run-time type coercion: %s",
507 result =
oprid(optup);
578 for (clisti = clist; clisti != NULL; clisti = clisti->
next)
640 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
641 errmsg(
"operator is not unique: %s",
643 errhint(
"Could not choose a best candidate operator. "
644 "You might need to add explicit type casts."),
648 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
649 errmsg(
"operator does not exist: %s",
652 errhint(
"No operator matches the given name and argument type. "
653 "You might need to add an explicit type cast.") :
654 errhint(
"No operator matches the given name and argument types. "
655 "You might need to add explicit type casts."),
673 Node *last_srf,
int location)
679 Oid actual_arg_types[2];
680 Oid declared_arg_types[2];
689 (
errcode(ERRCODE_SYNTAX_ERROR),
690 errmsg(
"postfix operators are not supported")));
698 tup =
left_oper(pstate, opname, rtypeId,
false, location);
705 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
713 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
714 errmsg(
"operator is only a shell: %s",
726 actual_arg_types[0] = rtypeId;
727 declared_arg_types[0] = opform->oprright;
734 actual_arg_types[0] = ltypeId;
735 actual_arg_types[1] = rtypeId;
736 declared_arg_types[0] = opform->oprleft;
737 declared_arg_types[1] = opform->oprright;
758 result->opfuncid = opform->oprcode;
759 result->opresulttype = rettype;
766 if (result->opretset)
775 return (
Expr *) result;
794 Oid actual_arg_types[2];
795 Oid declared_arg_types[2];
808 if (atypeId == UNKNOWNOID)
809 rtypeId = UNKNOWNOID;
815 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
816 errmsg(
"op ANY/ALL (array) requires array on right side"),
821 tup =
oper(pstate, opname, ltypeId, rtypeId,
false, location);
827 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
828 errmsg(
"operator is only a shell: %s",
836 actual_arg_types[0] = ltypeId;
837 actual_arg_types[1] = rtypeId;
838 declared_arg_types[0] = opform->oprleft;
839 declared_arg_types[1] = opform->oprright;
855 if (rettype != BOOLOID)
857 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
858 errmsg(
"op ANY/ALL (array) requires operator to yield boolean"),
862 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
863 errmsg(
"op ANY/ALL (array) requires operator not to return a set"),
872 if (IsPolymorphicType(declared_arg_types[1]))
875 res_atypeId = atypeId;
882 (
errcode(ERRCODE_UNDEFINED_OBJECT),
883 errmsg(
"could not find array type for data type %s",
887 actual_arg_types[1] = atypeId;
888 declared_arg_types[1] = res_atypeId;
896 result->opfuncid = opform->oprcode;
899 result->
useOr = useOr;
906 return (
Expr *) result;
952 Oid ltypeId,
Oid rtypeId,
int location)
965 key->left_arg = ltypeId;
966 key->right_arg = rtypeId;
1022 if (oprentry == NULL)
#define RegProcedureIsValid(p)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
elog(ERROR, "%s: %s", p2, msg)
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)
Assert(fmt[strlen(fmt) - 1] !='\n')
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)
static void op_error(ParseState *pstate, List *op, char oprkind, Oid arg1, Oid arg2, FuncDetailCode fdresult, int location)
#define MAX_CACHED_PATH_LEN
static const char * op_signature_string(List *op, char oprkind, Oid arg1, Oid arg2)
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
static Oid binary_oper_exact(List *opname, Oid arg1, Oid arg2)
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