48 List *fargs,
int numAggregatedArgs,
49 Oid *actual_arg_types,
Oid *declared_arg_types);
52 Node *first_arg,
int location);
54 int nargs,
const Oid *argtypes,
55 bool include_out_arguments,
bool missing_ok,
95 bool is_column = (
fn == NULL);
97 Expr *agg_filter = NULL;
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);
104 bool could_be_projection;
108 Node *first_arg = NULL;
112 Oid *declared_arg_types;
127 if (
fn &&
fn->agg_filter != NULL)
140 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
141 errmsg_plural(
"cannot pass more than %d argument to a function",
142 "cannot pass more than %d arguments to a function",
164 !is_column && !agg_within_group)
170 actual_arg_types[nargs++] = argtype;
192 foreach(lc, argnames)
194 if (strcmp(na->name, (
char *)
lfirst(lc)) == 0)
196 (
errcode(ERRCODE_SYNTAX_ERROR),
197 errmsg(
"argument name \"%s\" used more than once",
201 argnames =
lappend(argnames, na->name);
207 (
errcode(ERRCODE_SYNTAX_ERROR),
208 errmsg(
"positional argument cannot follow named argument"),
216 Assert(first_arg != NULL);
226 could_be_projection = (nargs == 1 && !proc_call &&
227 agg_order ==
NIL && agg_filter == NULL &&
228 !agg_star && !agg_distinct && over == NULL &&
229 !func_variadic && argnames ==
NIL &&
231 (actual_arg_types[0] == RECORDOID ||
237 if (could_be_projection && is_column)
271 !func_variadic,
true, proc_call,
273 &funcid, &rettype, &retset,
275 &declared_arg_types, &argdefaults);
290 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
291 errmsg(
"%s is not a procedure",
295 errhint(
"To call a function, use SELECT."),
300 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
301 errmsg(
"%s is a procedure",
305 errhint(
"To call a procedure, use CALL."),
318 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
319 errmsg(
"%s(*) specified, but %s is not an aggregate function",
325 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
326 errmsg(
"DISTINCT specified, but %s is not an aggregate function",
329 if (agg_within_group)
331 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
332 errmsg(
"WITHIN GROUP specified, but %s is not an aggregate function",
335 if (agg_order !=
NIL)
337 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
338 errmsg(
"ORDER BY specified, but %s is not an aggregate function",
343 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
344 errmsg(
"FILTER specified, but %s is not an aggregate function",
349 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
350 errmsg(
"OVER specified, but %s is not a window function nor an aggregate function",
373 elog(
ERROR,
"cache lookup failed for aggregate %u", funcid);
375 aggkind = classForm->aggkind;
376 catDirectArgs = classForm->aggnumdirectargs;
380 if (AGGKIND_IS_ORDERED_SET(aggkind))
382 int numAggregatedArgs;
385 if (!agg_within_group)
387 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
388 errmsg(
"WITHIN GROUP is required for ordered-set aggregate %s",
393 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
394 errmsg(
"OVER is not supported for ordered-set aggregate %s",
412 numDirectArgs = nargs - numAggregatedArgs;
413 Assert(numDirectArgs >= 0);
418 if (numDirectArgs != catDirectArgs)
420 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
421 errmsg(
"function %s does not exist",
425 errhint_plural(
"There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
426 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
429 catDirectArgs, numDirectArgs),
449 if (numDirectArgs != catDirectArgs)
451 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
452 errmsg(
"function %s does not exist",
456 errhint_plural(
"There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
457 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
460 catDirectArgs, numDirectArgs),
474 if (aggkind == AGGKIND_HYPOTHETICAL)
476 if (nvargs != 2 * numAggregatedArgs)
478 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
479 errmsg(
"function %s does not exist",
483 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).",
485 nvargs - numAggregatedArgs, numAggregatedArgs),
490 if (nvargs <= numAggregatedArgs)
492 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
493 errmsg(
"function %s does not exist",
497 errhint_plural(
"There is an ordered-set aggregate %s, but it requires at least %d direct argument.",
498 "There is an ordered-set aggregate %s, but it requires at least %d direct arguments.",
508 if (aggkind == AGGKIND_HYPOTHETICAL)
510 actual_arg_types, declared_arg_types);
515 if (agg_within_group)
517 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
518 errmsg(
"%s is not an ordered-set aggregate, so it cannot have WITHIN GROUP",
530 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
531 errmsg(
"window function %s requires an OVER clause",
535 if (agg_within_group)
537 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
538 errmsg(
"window function %s cannot have WITHIN GROUP",
549 actual_arg_types[0], rettype, -1,
566 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
567 errmsg(
"procedure %s is not unique",
570 errdetail(
"Could not choose a best candidate procedure."),
571 errhint(
"You might need to add explicit type casts."),
575 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
576 errmsg(
"function %s is not unique",
579 errdetail(
"Could not choose a best candidate function."),
580 errhint(
"You might need to add explicit type casts."),
596 if (could_be_projection)
612 if (
list_length(agg_order) > 1 && !agg_within_group)
616 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
617 errmsg(
"function %s does not exist",
620 errdetail(
"No aggregate function matches the given name and argument types."),
621 errhint(
"Perhaps you misplaced ORDER BY; ORDER BY must appear "
622 "after all regular arguments of the aggregate."),
627 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
628 errmsg(
"procedure %s does not exist",
636 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
637 errmsg(
"function %s does not exist",
652 nargsplusdefs = nargs;
653 foreach(l, argdefaults)
660 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
661 errmsg_plural(
"cannot pass more than %d argument to a function",
662 "cannot pass more than %d arguments to a function",
667 actual_arg_types[nargsplusdefs++] =
exprType(expr);
692 func_variadic =
false;
699 if (nvargs > 0 && vatype != ANYOID)
702 int non_var_args = nargs - nvargs;
705 Assert(non_var_args >= 0);
709 newa->elements = vargs;
715 (
errcode(ERRCODE_UNDEFINED_OBJECT),
716 errmsg(
"could not find array type for data type %s",
720 newa->multidims =
false;
728 func_variadic =
true;
735 if (nargs > 0 && vatype == ANYOID && func_variadic)
737 Oid va_arr_typid = actual_arg_types[nargs - 1];
741 (
errcode(ERRCODE_DATATYPE_MISMATCH),
742 errmsg(
"VARIADIC argument must be an array"),
756 funcexpr->
funcid = funcid;
757 funcexpr->funcresulttype = rettype;
758 funcexpr->funcretset = retset;
759 funcexpr->funcvariadic = func_variadic;
760 funcexpr->funcformat = funcformat;
762 funcexpr->
args = fargs;
765 retval = (
Node *) funcexpr;
773 aggref->aggtype = rettype;
780 aggref->aggstar = agg_star;
781 aggref->aggvariadic = func_variadic;
782 aggref->aggkind = aggkind;
783 aggref->aggpresorted =
false;
787 aggref->aggtransno = -1;
794 if (fargs ==
NIL && !agg_star && !agg_within_group)
796 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
797 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
803 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
804 errmsg(
"aggregates cannot return sets"),
818 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
819 errmsg(
"aggregates cannot use named arguments"),
825 retval = (
Node *) aggref;
833 Assert(!agg_within_group);
836 wfunc->wintype = rettype;
840 wfunc->winstar = agg_star;
843 wfunc->runCondition =
NIL;
851 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
852 errmsg(
"DISTINCT is not implemented for window functions"),
859 if (wfunc->winagg && fargs ==
NIL && !agg_star)
861 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
862 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
869 if (agg_order !=
NIL)
871 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
872 errmsg(
"aggregate ORDER BY is not implemented for window functions"),
878 if (!wfunc->winagg && agg_filter)
880 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
881 errmsg(
"FILTER is not implemented for non-aggregate window functions"),
889 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
890 errmsg(
"window function calls cannot contain set-returning function calls"),
891 errhint(
"You might be able to move the set-returning function into a LATERAL FROM item."),
897 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
898 errmsg(
"window functions cannot return sets"),
904 retval = (
Node *) wfunc;
941 return errdetail(
"There is no procedure of that name.");
943 return errdetail(
"There is no function of that name.");
948 return errdetail(
"A procedure of that name exists, but it is not in the search_path.");
950 return errdetail(
"A function of that name exists, but it is not in the search_path.");
962 return errdetail(
"No procedure of that name accepts the given number of arguments.");
964 return errdetail(
"No function of that name accepts the given number of arguments.");
974 return errdetail(
"No procedure of that name accepts the given argument names.");
976 return errdetail(
"No function of that name accepts the given argument names.");
989 return errdetail(
"In the closest available match, "
990 "an argument was specified both positionally and by name.");
993 return errdetail(
"In the closest available match, "
994 "not all required arguments were supplied.");
997 return errhint(
"This call would be correct if the variadic array were labeled VARIADIC and placed last.");
1000 return errhint(
"The VARIADIC parameter must be placed last, even when using argument names.");
1006 (void)
errdetail(
"No procedure of that name accepts the given argument types.");
1008 (
void)
errdetail(
"No function of that name accepts the given argument types.");
1009 return errhint(
"You might need to add explicit type casts.");
1034 int ncandidates = 0;
1038 for (current_candidate = raw_candidates;
1039 current_candidate != NULL;
1040 current_candidate = next_candidate)
1042 next_candidate = current_candidate->
next;
1046 current_candidate->
next = *candidates;
1047 *candidates = current_candidate;
1119 Oid *current_typeids;
1129 bool current_is_preferred;
1131 bool resolved_unknowns;
1136 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
1137 errmsg_plural(
"cannot pass more than %d argument to a function",
1138 "cannot pass more than %d arguments to a function",
1156 for (
i = 0;
i < nargs;
i++)
1158 if (input_typeids[
i] != UNKNOWNOID)
1163 input_base_typeids[
i] = UNKNOWNOID;
1174 last_candidate = NULL;
1175 for (current_candidate = candidates;
1176 current_candidate != NULL;
1177 current_candidate = current_candidate->
next)
1179 current_typeids = current_candidate->
args;
1181 for (
i = 0;
i < nargs;
i++)
1183 if (input_base_typeids[
i] != UNKNOWNOID &&
1184 current_typeids[
i] == input_base_typeids[
i])
1189 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1191 nbestMatch = nmatch;
1192 candidates = current_candidate;
1193 last_candidate = current_candidate;
1197 else if (nmatch == nbestMatch)
1199 last_candidate->
next = current_candidate;
1200 last_candidate = current_candidate;
1207 last_candidate->
next = NULL;
1209 if (ncandidates == 1)
1219 for (
i = 0;
i < nargs;
i++)
1223 last_candidate = NULL;
1224 for (current_candidate = candidates;
1225 current_candidate != NULL;
1226 current_candidate = current_candidate->
next)
1228 current_typeids = current_candidate->
args;
1230 for (
i = 0;
i < nargs;
i++)
1232 if (input_base_typeids[
i] != UNKNOWNOID)
1234 if (current_typeids[
i] == input_base_typeids[
i] ||
1240 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1242 nbestMatch = nmatch;
1243 candidates = current_candidate;
1244 last_candidate = current_candidate;
1247 else if (nmatch == nbestMatch)
1249 last_candidate->
next = current_candidate;
1250 last_candidate = current_candidate;
1256 last_candidate->
next = NULL;
1258 if (ncandidates == 1)
1289 resolved_unknowns =
false;
1290 for (
i = 0;
i < nargs;
i++)
1294 if (input_base_typeids[
i] != UNKNOWNOID)
1296 resolved_unknowns =
true;
1297 slot_category[
i] = TYPCATEGORY_INVALID;
1298 slot_has_preferred_type[
i] =
false;
1299 have_conflict =
false;
1300 for (current_candidate = candidates;
1301 current_candidate != NULL;
1302 current_candidate = current_candidate->
next)
1304 current_typeids = current_candidate->
args;
1305 current_type = current_typeids[
i];
1308 ¤t_is_preferred);
1309 if (slot_category[
i] == TYPCATEGORY_INVALID)
1312 slot_category[
i] = current_category;
1313 slot_has_preferred_type[
i] = current_is_preferred;
1315 else if (current_category == slot_category[
i])
1318 slot_has_preferred_type[
i] |= current_is_preferred;
1323 if (current_category == TYPCATEGORY_STRING)
1326 slot_category[
i] = current_category;
1327 slot_has_preferred_type[
i] = current_is_preferred;
1334 have_conflict =
true;
1338 if (have_conflict && slot_category[
i] != TYPCATEGORY_STRING)
1341 resolved_unknowns =
false;
1346 if (resolved_unknowns)
1350 first_candidate = candidates;
1351 last_candidate = NULL;
1352 for (current_candidate = candidates;
1353 current_candidate != NULL;
1354 current_candidate = current_candidate->
next)
1358 current_typeids = current_candidate->
args;
1359 for (
i = 0;
i < nargs;
i++)
1361 if (input_base_typeids[
i] != UNKNOWNOID)
1363 current_type = current_typeids[
i];
1366 ¤t_is_preferred);
1367 if (current_category != slot_category[
i])
1372 if (slot_has_preferred_type[
i] && !current_is_preferred)
1381 last_candidate = current_candidate;
1388 last_candidate->
next = current_candidate->
next;
1390 first_candidate = current_candidate->
next;
1397 candidates = first_candidate;
1399 last_candidate->
next = NULL;
1402 if (ncandidates == 1)
1416 if (nunknowns < nargs)
1418 Oid known_type = UNKNOWNOID;
1420 for (
i = 0;
i < nargs;
i++)
1422 if (input_base_typeids[
i] == UNKNOWNOID)
1424 if (known_type == UNKNOWNOID)
1425 known_type = input_base_typeids[
i];
1426 else if (known_type != input_base_typeids[
i])
1429 known_type = UNKNOWNOID;
1434 if (known_type != UNKNOWNOID)
1437 for (
i = 0;
i < nargs;
i++)
1438 input_base_typeids[
i] = known_type;
1440 last_candidate = NULL;
1441 for (current_candidate = candidates;
1442 current_candidate != NULL;
1443 current_candidate = current_candidate->
next)
1445 current_typeids = current_candidate->
args;
1449 if (++ncandidates > 1)
1451 last_candidate = current_candidate;
1454 if (ncandidates == 1)
1457 last_candidate->
next = NULL;
1458 return last_candidate;
1509 bool expand_variadic,
1510 bool expand_defaults,
1511 bool include_out_arguments,
1530 *true_typeids = NULL;
1536 expand_variadic, expand_defaults,
1537 include_out_arguments,
false,
1544 for (best_candidate = raw_candidates;
1545 best_candidate != NULL;
1546 best_candidate = best_candidate->
next)
1550 memcmp(argtypes, best_candidate->
args, nargs *
sizeof(
Oid)) == 0)
1554 if (best_candidate == NULL)
1595 if (nargs == 1 && fargs !=
NIL && fargnames ==
NIL)
1601 Oid sourceType = argtypes[0];
1605 if (sourceType == UNKNOWNOID &&
IsA(arg1,
Const))
1624 if ((sourceType == RECORDOID ||
1641 *rettype = targetType;
1645 *true_typeids = argtypes;
1654 if (raw_candidates != NULL)
1662 ¤t_candidates);
1665 if (ncandidates == 1)
1666 best_candidate = current_candidates;
1671 else if (ncandidates > 1)
1675 current_candidates);
1681 if (!best_candidate)
1706 if (fargnames !=
NIL && !expand_variadic && nargs > 0 &&
1707 best_candidate->
argnumbers[nargs - 1] != nargs - 1)
1713 *funcid = best_candidate->
oid;
1714 *nvargs = best_candidate->
nvargs;
1715 *true_typeids = best_candidate->
args;
1740 elog(
ERROR,
"cache lookup failed for function %u",
1741 best_candidate->
oid);
1743 *rettype = pform->prorettype;
1744 *retset = pform->proretset;
1745 *vatype = pform->provariadic;
1747 if (argdefaults && best_candidate->
ndargs > 0)
1749 Datum proargdefaults;
1754 if (best_candidate->
ndargs > pform->pronargdefaults)
1755 elog(
ERROR,
"not enough default arguments");
1758 Anum_pg_proc_proargdefaults);
1780 defargnumbers = NULL;
1782 for (
i = 0;
i < best_candidate->
ndargs;
i++)
1787 foreach(lc, defaults)
1795 *argdefaults = newdefaults;
1808 *argdefaults = defaults;
1812 switch (pform->prokind)
1814 case PROKIND_AGGREGATE:
1817 case PROKIND_FUNCTION:
1820 case PROKIND_PROCEDURE:
1823 case PROKIND_WINDOW:
1827 elog(
ERROR,
"unrecognized prokind: %c", pform->prokind);
1857 int numAggregatedArgs,
1858 Oid *actual_arg_types,
1859 Oid *declared_arg_types)
1862 numNonHypotheticalArgs;
1865 numDirectArgs =
list_length(fargs) - numAggregatedArgs;
1866 numNonHypotheticalArgs = numDirectArgs - numAggregatedArgs;
1868 if (numNonHypotheticalArgs < 0)
1869 elog(
ERROR,
"incorrect number of arguments to hypothetical-set aggregate");
1872 for (hargpos = numNonHypotheticalArgs; hargpos < numDirectArgs; hargpos++)
1874 int aargpos = numDirectArgs + (hargpos - numNonHypotheticalArgs);
1881 if (declared_arg_types[hargpos] != declared_arg_types[aargpos])
1882 elog(
ERROR,
"hypothetical-set aggregate has inconsistent declared argument types");
1885 if (declared_arg_types[hargpos] != ANYOID)
1907 actual_arg_types[hargpos],
1908 commontype, commontypmod,
1912 actual_arg_types[hargpos] = commontype;
1915 actual_arg_types[aargpos],
1916 commontype, commontypmod,
1920 actual_arg_types[aargpos] = commontype;
1941 Oid *actual_arg_types,
1942 Oid *declared_arg_types)
1947 foreach(current_fargs, fargs)
1950 if (actual_arg_types[
i] != declared_arg_types[
i])
1964 actual_arg_types[
i],
1965 declared_arg_types[
i], -1,
1975 actual_arg_types[
i],
1976 declared_arg_types[
i], -1,
1980 lfirst(current_fargs) = node;
2005 NULL,
false,
false);
2042 if (
IsA(first_arg,
Var) &&
2048 ((
Var *) first_arg)->varno,
2049 ((
Var *) first_arg)->varlevelsup);
2052 ((
Var *) first_arg)->varlevelsup,
2063 if (
IsA(first_arg,
Var) &&
2064 ((
Var *) first_arg)->vartype == RECORDOID)
2071 for (
i = 0;
i < tupdesc->
natts;
i++)
2081 fselect->
arg = (
Expr *) first_arg;
2083 fselect->resulttype = att->atttypid;
2084 fselect->resulttypmod = att->atttypmod;
2086 fselect->resultcollid = att->attcollation;
2087 return (
Node *) fselect;
2108 List *argnames,
const Oid *argtypes)
2122 for (
i = 0;
i < nargs;
i++)
2126 if (
i >= numposargs)
2129 lc =
lnext(argnames, lc);
2145 List *argnames,
const Oid *argtypes)
2148 nargs, argnames, argtypes);
2164 int nargs,
const Oid *argtypes,
2165 bool include_out_arguments,
bool missing_ok,
2173 Assert(argtypes != NULL || nargs == 0);
2180 include_out_arguments, missing_ok,
2184 for (; clist != NULL; clist = clist->
next)
2191 memcmp(argtypes, clist->
args, nargs *
sizeof(
Oid)) != 0)
2231 result = clist->
oid;
2273 switch (lookupError)
2282 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2283 errmsg(
"could not find a function named \"%s\"",
2287 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2288 errmsg(
"function %s does not exist",
2296 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2297 errmsg(
"function name \"%s\" is not unique",
2299 errhint(
"Specify the argument list to select the function unambiguously.")));
2342 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2343 errmsg_plural(
"procedures cannot have more than %d argument",
2344 "procedures cannot have more than %d arguments",
2349 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2350 errmsg_plural(
"functions cannot have more than %d argument",
2351 "functions cannot have more than %d arguments",
2361 foreach(args_item, func->
objargs)
2387 func->
objname, nargs, argoids,
2403 bool have_param_mode =
false;
2419 have_param_mode =
true;
2424 if (!have_param_mode)
2473 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2474 errmsg(
"%s is not a function",
2483 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2484 errmsg(
"%s is not a procedure",
2493 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2494 errmsg(
"function %s is not an aggregate",
2509 switch (lookupError)
2521 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2522 errmsg(
"could not find a procedure named \"%s\"",
2526 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2527 errmsg(
"procedure %s does not exist",
2535 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2536 errmsg(
"could not find an aggregate named \"%s\"",
2538 else if (argcount == 0)
2540 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2541 errmsg(
"aggregate %s(*) does not exist",
2545 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2546 errmsg(
"aggregate %s does not exist",
2555 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2556 errmsg(
"could not find a function named \"%s\"",
2560 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2561 errmsg(
"function %s does not exist",
2573 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2574 errmsg(
"function name \"%s\" is not unique",
2577 errhint(
"Specify the argument list to select the function unambiguously.") : 0));
2581 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2582 errmsg(
"procedure name \"%s\" is not unique",
2585 errhint(
"Specify the argument list to select the procedure unambiguously.") : 0));
2589 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2590 errmsg(
"aggregate name \"%s\" is not unique",
2593 errhint(
"Specify the argument list to select the aggregate unambiguously.") : 0));
2597 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2598 errmsg(
"routine name \"%s\" is not unique",
2601 errhint(
"Specify the argument list to select the routine unambiguously.") : 0));
2656 err =
_(
"set-returning functions are not allowed in JOIN conditions");
2668 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2669 errmsg(
"set-returning functions must appear at top level of FROM"),
2677 err =
_(
"set-returning functions are not allowed in policy expressions");
2693 err =
_(
"set-returning functions are not allowed in window definitions");
2731 err =
_(
"set-returning functions are not allowed in MERGE WHEN conditions");
2735 err =
_(
"set-returning functions are not allowed in check constraints");
2739 err =
_(
"set-returning functions are not allowed in DEFAULT expressions");
2742 err =
_(
"set-returning functions are not allowed in index expressions");
2745 err =
_(
"set-returning functions are not allowed in index predicates");
2748 err =
_(
"set-returning functions are not allowed in statistics expressions");
2751 err =
_(
"set-returning functions are not allowed in transform expressions");
2754 err =
_(
"set-returning functions are not allowed in EXECUTE parameters");
2757 err =
_(
"set-returning functions are not allowed in trigger WHEN conditions");
2760 err =
_(
"set-returning functions are not allowed in partition bound");
2763 err =
_(
"set-returning functions are not allowed in partition key expressions");
2766 err =
_(
"set-returning functions are not allowed in CALL arguments");
2769 err =
_(
"set-returning functions are not allowed in COPY FROM WHERE conditions");
2772 err =
_(
"set-returning functions are not allowed in column generation expressions");
2788 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2793 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2795 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 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)
Assert(PointerIsAligned(start, uint64))
#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
Oid args[FLEXIBLE_ARRAY_MEMBER]
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)