54 int nargs,
const Oid *argtypes,
99 bool agg_within_group = (
fn ?
fn->agg_within_group :
false);
100 bool agg_star = (
fn ?
fn->agg_star :
false);
101 bool agg_distinct = (
fn ?
fn->agg_distinct :
false);
102 bool func_variadic = (
fn ?
fn->func_variadic :
false);
142 errmsg_plural(
"cannot pass more than %d argument to a function",
143 "cannot pass more than %d arguments to a function",
193 foreach(
lc, argnames)
198 errmsg(
"argument name \"%s\" used more than once",
209 errmsg(
"positional argument cannot follow named argument"),
228 agg_order ==
NIL && agg_filter ==
NULL &&
229 !agg_star && !agg_distinct && over ==
NULL &&
230 !func_variadic && argnames ==
NIL &&
274 &funcid, &rettype, &retset,
292 errmsg(
"%s is not a procedure",
296 errhint(
"To call a function, use SELECT."),
302 errmsg(
"%s is a procedure",
306 errhint(
"To call a procedure, use CALL."),
320 errmsg(
"%s(*) specified, but %s is not an aggregate function",
327 errmsg(
"DISTINCT specified, but %s is not an aggregate function",
330 if (agg_within_group)
333 errmsg(
"WITHIN GROUP specified, but %s is not an aggregate function",
336 if (agg_order !=
NIL)
339 errmsg(
"ORDER BY specified, but %s is not an aggregate function",
345 errmsg(
"FILTER specified, but %s is not an aggregate function",
351 errmsg(
"OVER specified, but %s is not a window function nor an aggregate function",
374 elog(
ERROR,
"cache lookup failed for aggregate %u", funcid);
386 if (!agg_within_group)
389 errmsg(
"WITHIN GROUP is required for ordered-set aggregate %s",
395 errmsg(
"OVER is not supported for ordered-set aggregate %s",
422 errmsg(
"function %s does not exist",
426 errhint_plural(
"There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
427 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
453 errmsg(
"function %s does not exist",
457 errhint_plural(
"There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
458 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
480 errmsg(
"function %s does not exist",
484 errhint(
"To use the hypothetical-set aggregate %s, the number of hypothetical direct arguments (here %d) must match the number of ordering columns (here %d).",
494 errmsg(
"function %s does not exist",
498 errhint_plural(
"There is an ordered-set aggregate %s, but it requires at least %d direct argument.",
499 "There is an ordered-set aggregate %s, but it requires at least %d direct arguments.",
516 if (agg_within_group)
519 errmsg(
"%s is not an ordered-set aggregate, so it cannot have WITHIN GROUP",
527 errmsg(
"aggregate functions do not accept RESPECT/IGNORE NULLS"),
539 errmsg(
"window function %s requires an OVER clause",
543 if (agg_within_group)
546 errmsg(
"window function %s cannot have WITHIN GROUP",
575 errmsg(
"procedure %s is not unique",
578 errdetail(
"Could not choose a best candidate procedure."),
579 errhint(
"You might need to add explicit type casts."),
584 errmsg(
"function %s is not unique",
587 errdetail(
"Could not choose a best candidate function."),
588 errhint(
"You might need to add explicit type casts."),
620 if (
list_length(agg_order) > 1 && !agg_within_group)
625 errmsg(
"function %s does not exist",
628 errdetail(
"No aggregate function matches the given name and argument types."),
629 errhint(
"Perhaps you misplaced ORDER BY; ORDER BY must appear "
630 "after all regular arguments of the aggregate."),
636 errmsg(
"procedure %s does not exist",
645 errmsg(
"function %s does not exist",
669 errmsg_plural(
"cannot pass more than %d argument to a function",
670 "cannot pass more than %d arguments to a function",
700 func_variadic =
false;
724 errmsg(
"could not find array type for data type %s",
728 newa->multidims =
false;
736 func_variadic =
true;
750 errmsg(
"VARIADIC argument must be an array"),
764 funcexpr->
funcid = funcid;
765 funcexpr->funcresulttype = rettype;
766 funcexpr->funcretset = retset;
767 funcexpr->funcvariadic = func_variadic;
768 funcexpr->funcformat = funcformat;
773 retval = (
Node *) funcexpr;
781 aggref->aggtype = rettype;
788 aggref->aggstar = agg_star;
789 aggref->aggvariadic = func_variadic;
791 aggref->aggpresorted =
false;
795 aggref->aggtransno = -1;
802 if (
fargs ==
NIL && !agg_star && !agg_within_group)
805 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
812 errmsg(
"aggregates cannot return sets"),
827 errmsg(
"aggregates cannot use named arguments"),
833 retval = (
Node *) aggref;
841 Assert(!agg_within_group);
844 wfunc->wintype = rettype;
848 wfunc->winstar = agg_star;
852 wfunc->runCondition =
NIL;
861 errmsg(
"DISTINCT is not implemented for window functions"),
868 if (wfunc->winagg &&
fargs ==
NIL && !agg_star)
871 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
878 if (agg_order !=
NIL)
881 errmsg(
"aggregate ORDER BY is not implemented for window functions"),
887 if (!wfunc->winagg && agg_filter)
890 errmsg(
"FILTER is not implemented for non-aggregate window functions"),
899 errmsg(
"window function calls cannot contain set-returning function calls"),
900 errhint(
"You might be able to move the set-returning function into a LATERAL FROM item."),
907 errmsg(
"window functions cannot return sets"),
913 retval = (
Node *) wfunc;
950 return errdetail(
"There is no procedure of that name.");
952 return errdetail(
"There is no function of that name.");
957 return errdetail(
"A procedure of that name exists, but it is not in the search_path.");
959 return errdetail(
"A function of that name exists, but it is not in the search_path.");
971 return errdetail(
"No procedure of that name accepts the given number of arguments.");
973 return errdetail(
"No function of that name accepts the given number of arguments.");
983 return errdetail(
"No procedure of that name accepts the given argument names.");
985 return errdetail(
"No function of that name accepts the given argument names.");
998 return errdetail(
"In the closest available match, "
999 "an argument was specified both positionally and by name.");
1002 return errdetail(
"In the closest available match, "
1003 "not all required arguments were supplied.");
1006 return errhint(
"This call would be correct if the variadic array were labeled VARIADIC and placed last.");
1009 return errhint(
"The VARIADIC parameter must be placed last, even when using argument names.");
1015 (
void)
errdetail(
"No procedure of that name accepts the given argument types.");
1017 (
void)
errdetail(
"No function of that name accepts the given argument types.");
1018 return errhint(
"You might need to add explicit type casts.");
1146 errmsg_plural(
"cannot pass more than %d argument to a function",
1147 "cannot pass more than %d arguments to a function",
1165 for (
i = 0;
i < nargs;
i++)
1190 for (
i = 0;
i < nargs;
i++)
1228 for (
i = 0;
i < nargs;
i++)
1239 for (
i = 0;
i < nargs;
i++)
1299 for (
i = 0;
i < nargs;
i++)
1368 for (
i = 0;
i < nargs;
i++)
1429 for (
i = 0;
i < nargs;
i++)
1446 for (
i = 0;
i < nargs;
i++)
1749 elog(
ERROR,
"cache lookup failed for function %u",
1752 *rettype =
pform->prorettype;
1753 *retset =
pform->proretset;
1764 elog(
ERROR,
"not enough default arguments");
1796 foreach(
lc, defaults)
1821 switch (
pform->prokind)
1878 elog(
ERROR,
"incorrect number of arguments to hypothetical-set aggregate");
1891 elog(
ERROR,
"hypothetical-set aggregate has inconsistent declared argument types");
2014 NULL,
false,
false);
2080 for (
i = 0;
i < tupdesc->
natts;
i++)
2117 List *argnames,
const Oid *argtypes)
2131 for (
i = 0;
i < nargs;
i++)
2154 List *argnames,
const Oid *argtypes)
2157 nargs, argnames, argtypes);
2173 int nargs,
const Oid *argtypes,
2240 result =
clist->oid;
2292 errmsg(
"could not find a function named \"%s\"",
2297 errmsg(
"function %s does not exist",
2306 errmsg(
"function name \"%s\" is not unique",
2308 errhint(
"Specify the argument list to select the function unambiguously.")));
2352 errmsg_plural(
"procedures cannot have more than %d argument",
2353 "procedures cannot have more than %d arguments",
2359 errmsg_plural(
"functions cannot have more than %d argument",
2360 "functions cannot have more than %d arguments",
2483 errmsg(
"%s is not a function",
2493 errmsg(
"%s is not a procedure",
2503 errmsg(
"function %s is not an aggregate",
2531 errmsg(
"could not find a procedure named \"%s\"",
2536 errmsg(
"procedure %s does not exist",
2545 errmsg(
"could not find an aggregate named \"%s\"",
2550 errmsg(
"aggregate %s(*) does not exist",
2555 errmsg(
"aggregate %s does not exist",
2565 errmsg(
"could not find a function named \"%s\"",
2570 errmsg(
"function %s does not exist",
2583 errmsg(
"function name \"%s\" is not unique",
2586 errhint(
"Specify the argument list to select the function unambiguously.") : 0));
2591 errmsg(
"procedure name \"%s\" is not unique",
2594 errhint(
"Specify the argument list to select the procedure unambiguously.") : 0));
2599 errmsg(
"aggregate name \"%s\" is not unique",
2602 errhint(
"Specify the argument list to select the aggregate unambiguously.") : 0));
2607 errmsg(
"routine name \"%s\" is not unique",
2610 errhint(
"Specify the argument list to select the routine unambiguously.") : 0));
2665 err =
_(
"set-returning functions are not allowed in JOIN conditions");
2678 errmsg(
"set-returning functions must appear at top level of FROM"),
2686 err =
_(
"set-returning functions are not allowed in policy expressions");
2702 err =
_(
"set-returning functions are not allowed in window definitions");
2740 err =
_(
"set-returning functions are not allowed in MERGE WHEN conditions");
2744 err =
_(
"set-returning functions are not allowed in check constraints");
2748 err =
_(
"set-returning functions are not allowed in DEFAULT expressions");
2751 err =
_(
"set-returning functions are not allowed in index expressions");
2754 err =
_(
"set-returning functions are not allowed in index predicates");
2757 err =
_(
"set-returning functions are not allowed in statistics expressions");
2760 err =
_(
"set-returning functions are not allowed in transform expressions");
2763 err =
_(
"set-returning functions are not allowed in EXECUTE parameters");
2766 err =
_(
"set-returning functions are not allowed in trigger WHEN conditions");
2769 err =
_(
"set-returning functions are not allowed in partition bound");
2772 err =
_(
"set-returning functions are not allowed in partition key expressions");
2775 err =
_(
"set-returning functions are not allowed in CALL arguments");
2778 err =
_(
"set-returning functions are not allowed in COPY FROM WHERE conditions");
2781 err =
_(
"set-returning functions are not allowed in column generation expressions");
2804 errmsg(
"set-returning functions are not allowed in %s",
#define InvalidAttrNumber
void bms_free(Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
int errhint_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
#define ereport(elevel,...)
void err(int eval, const char *fmt,...)
TupleDesc get_expr_result_tupdesc(Node *expr, bool noError)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
List * lappend(List *list, void *datum)
List * list_copy_tail(const List *oldlist, int nskip)
List * list_delete_first_n(List *list, int n)
List * list_truncate(List *list, int new_size)
char get_func_prokind(Oid funcid)
Oid get_base_element_type(Oid typid)
Oid getBaseType(Oid typid)
Oid get_array_type(Oid typid)
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
TypeName * makeTypeNameFromNameList(List *names)
void pfree(void *pointer)
char * NameListToString(const List *names)
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok, int *fgc_flags)
#define FGC_ARGNAMES_VALID
#define FGC_ARGNAMES_MATCH
#define FGC_ARGCOUNT_MATCH
#define FGC_ARGNAMES_NONDUP
#define FGC_VARIADIC_FAIL
Oid exprType(const Node *expr)
int exprLocation(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
void transformWindowFuncCall(ParseState *pstate, WindowFunc *wfunc, WindowDef *windef)
void transformAggregateCall(ParseState *pstate, Aggref *agg, List *args, List *aggorder, bool agg_distinct)
Node * transformWhereClause(ParseState *pstate, Node *clause, ParseExprKind exprKind, const char *constructName)
TYPCATEGORY TypeCategory(Oid type)
Oid enforce_generic_type_consistency(const Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type)
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
bool IsPreferredType(TYPCATEGORY category, Oid type)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext)
@ COERCION_PATH_COERCEVIAIO
@ COERCION_PATH_RELABELTYPE
const char * ParseExprKindName(ParseExprKind exprKind)
FuncDetailCode func_get_detail(List *funcname, List *fargs, List *fargnames, int nargs, Oid *argtypes, bool expand_variadic, bool expand_defaults, bool include_out_arguments, int *fgc_flags, Oid *funcid, Oid *rettype, bool *retset, int *nvargs, Oid *vatype, Oid **true_typeids, List **argdefaults)
const char * funcname_signature_string(const char *funcname, int nargs, List *argnames, const Oid *argtypes)
static Node * ParseComplexProjection(ParseState *pstate, const char *funcname, Node *first_arg, int location)
void make_fn_arguments(ParseState *pstate, List *fargs, Oid *actual_arg_types, Oid *declared_arg_types)
static Oid LookupFuncNameInternal(ObjectType objtype, List *funcname, int nargs, const Oid *argtypes, bool include_out_arguments, bool missing_ok, FuncLookupError *lookupError)
FuncCandidateList func_select_candidate(int nargs, Oid *input_typeids, FuncCandidateList candidates)
static void unify_hypothetical_args(ParseState *pstate, List *fargs, int numAggregatedArgs, Oid *actual_arg_types, Oid *declared_arg_types)
Node * ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, Node *last_srf, FuncCall *fn, bool proc_call, int location)
const char * func_signature_string(List *funcname, int nargs, List *argnames, const Oid *argtypes)
void check_srf_call_placement(ParseState *pstate, Node *last_srf, int location)
static Oid FuncNameAsType(List *funcname)
static int func_lookup_failure_details(int fgc_flags, List *argnames, bool proc_call)
Oid LookupFuncWithArgs(ObjectType objtype, ObjectWithArgs *func, bool missing_ok)
int func_match_argtypes(int nargs, Oid *input_typeids, FuncCandidateList raw_candidates, FuncCandidateList *candidates)
Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok)
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)
@ EXPR_KIND_EXECUTE_PARAMETER
@ EXPR_KIND_COLUMN_DEFAULT
@ EXPR_KIND_STATS_EXPRESSION
@ EXPR_KIND_INDEX_EXPRESSION
@ EXPR_KIND_MERGE_RETURNING
@ EXPR_KIND_PARTITION_BOUND
@ EXPR_KIND_FUNCTION_DEFAULT
@ EXPR_KIND_WINDOW_FRAME_RANGE
@ EXPR_KIND_FROM_SUBSELECT
@ EXPR_KIND_WINDOW_FRAME_GROUPS
@ EXPR_KIND_PARTITION_EXPRESSION
@ EXPR_KIND_INDEX_PREDICATE
@ EXPR_KIND_INSERT_TARGET
@ EXPR_KIND_ALTER_COL_TRANSFORM
@ EXPR_KIND_UPDATE_TARGET
@ EXPR_KIND_SELECT_TARGET
@ EXPR_KIND_GENERATED_COLUMN
@ EXPR_KIND_CALL_ARGUMENT
@ EXPR_KIND_FROM_FUNCTION
@ EXPR_KIND_UPDATE_SOURCE
@ EXPR_KIND_CHECK_CONSTRAINT
@ EXPR_KIND_WINDOW_PARTITION
@ EXPR_KIND_WINDOW_FRAME_ROWS
@ EXPR_KIND_VALUES_SINGLE
ParseNamespaceItem * GetNSItemByRangeTablePosn(ParseState *pstate, int varno, int sublevels_up)
Node * scanNSItemForColumn(ParseState *pstate, ParseNamespaceItem *nsitem, int sublevels_up, const char *colname, int location)
TupleDesc expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
Oid typeTypeRelid(Type typ)
Type LookupTypeNameExtended(ParseState *pstate, const TypeName *typeName, int32 *typmod_p, bool temp_ok, bool missing_ok)
Oid LookupTypeNameOid(ParseState *pstate, const TypeName *typeName, bool missing_ok)
#define ISCOMPLEX(typeid)
FormData_pg_aggregate * Form_pg_aggregate
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define foreach_delete_current(lst, var_or_cell)
static ListCell * list_nth_cell(const List *list, int n)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
FormData_pg_proc * Form_pg_proc
FormData_pg_type * Form_pg_type
static Datum ObjectIdGetDatum(Oid X)
void * stringToNode(const char *str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
FunctionParameterMode mode
ParseExprKind p_expr_kind
struct _FuncCandidateList * next
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
static void * fn(void *arg)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)