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);
105 bool could_be_projection;
109 Node *first_arg = NULL;
113 Oid *declared_arg_types;
128 if (
fn &&
fn->agg_filter != NULL)
141 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
142 errmsg_plural(
"cannot pass more than %d argument to a function",
143 "cannot pass more than %d arguments to a function",
165 !is_column && !agg_within_group)
171 actual_arg_types[nargs++] = argtype;
193 foreach(lc, argnames)
195 if (strcmp(na->name, (
char *)
lfirst(lc)) == 0)
197 (
errcode(ERRCODE_SYNTAX_ERROR),
198 errmsg(
"argument name \"%s\" used more than once",
202 argnames =
lappend(argnames, na->name);
208 (
errcode(ERRCODE_SYNTAX_ERROR),
209 errmsg(
"positional argument cannot follow named argument"),
217 Assert(first_arg != NULL);
227 could_be_projection = (nargs == 1 && !proc_call &&
228 agg_order ==
NIL && agg_filter == NULL &&
229 !agg_star && !agg_distinct && over == NULL &&
230 !func_variadic && argnames ==
NIL &&
232 (actual_arg_types[0] == RECORDOID ||
238 if (could_be_projection && is_column)
272 !func_variadic,
true, proc_call,
274 &funcid, &rettype, &retset,
276 &declared_arg_types, &argdefaults);
291 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
292 errmsg(
"%s is not a procedure",
296 errhint(
"To call a function, use SELECT."),
301 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
302 errmsg(
"%s is a procedure",
306 errhint(
"To call a procedure, use CALL."),
319 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
320 errmsg(
"%s(*) specified, but %s is not an aggregate function",
326 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
327 errmsg(
"DISTINCT specified, but %s is not an aggregate function",
330 if (agg_within_group)
332 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
333 errmsg(
"WITHIN GROUP specified, but %s is not an aggregate function",
336 if (agg_order !=
NIL)
338 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
339 errmsg(
"ORDER BY specified, but %s is not an aggregate function",
344 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
345 errmsg(
"FILTER specified, but %s is not an aggregate function",
350 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
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);
376 aggkind = classForm->aggkind;
377 catDirectArgs = classForm->aggnumdirectargs;
381 if (AGGKIND_IS_ORDERED_SET(aggkind))
383 int numAggregatedArgs;
386 if (!agg_within_group)
388 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
389 errmsg(
"WITHIN GROUP is required for ordered-set aggregate %s",
394 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
395 errmsg(
"OVER is not supported for ordered-set aggregate %s",
413 numDirectArgs = nargs - numAggregatedArgs;
414 Assert(numDirectArgs >= 0);
419 if (numDirectArgs != catDirectArgs)
421 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
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.",
430 catDirectArgs, numDirectArgs),
450 if (numDirectArgs != catDirectArgs)
452 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
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.",
461 catDirectArgs, numDirectArgs),
475 if (aggkind == AGGKIND_HYPOTHETICAL)
477 if (nvargs != 2 * numAggregatedArgs)
479 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
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).",
486 nvargs - numAggregatedArgs, numAggregatedArgs),
491 if (nvargs <= numAggregatedArgs)
493 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
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.",
509 if (aggkind == AGGKIND_HYPOTHETICAL)
511 actual_arg_types, declared_arg_types);
516 if (agg_within_group)
518 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
519 errmsg(
"%s is not an ordered-set aggregate, so it cannot have WITHIN GROUP",
526 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
527 errmsg(
"aggregate functions do not accept RESPECT/IGNORE NULLS"),
538 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
539 errmsg(
"window function %s requires an OVER clause",
543 if (agg_within_group)
545 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
546 errmsg(
"window function %s cannot have WITHIN GROUP",
557 actual_arg_types[0], rettype, -1,
574 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
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."),
583 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
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."),
604 if (could_be_projection)
620 if (
list_length(agg_order) > 1 && !agg_within_group)
624 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
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."),
635 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
636 errmsg(
"procedure %s does not exist",
644 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
645 errmsg(
"function %s does not exist",
660 nargsplusdefs = nargs;
661 foreach(l, argdefaults)
668 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
669 errmsg_plural(
"cannot pass more than %d argument to a function",
670 "cannot pass more than %d arguments to a function",
675 actual_arg_types[nargsplusdefs++] =
exprType(expr);
700 func_variadic =
false;
707 if (nvargs > 0 && vatype != ANYOID)
710 int non_var_args = nargs - nvargs;
713 Assert(non_var_args >= 0);
717 newa->elements = vargs;
723 (
errcode(ERRCODE_UNDEFINED_OBJECT),
724 errmsg(
"could not find array type for data type %s",
728 newa->multidims =
false;
736 func_variadic =
true;
743 if (nargs > 0 && vatype == ANYOID && func_variadic)
745 Oid va_arr_typid = actual_arg_types[nargs - 1];
749 (
errcode(ERRCODE_DATATYPE_MISMATCH),
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;
770 funcexpr->
args = fargs;
773 retval = (
Node *) funcexpr;
781 aggref->aggtype = rettype;
788 aggref->aggstar = agg_star;
789 aggref->aggvariadic = func_variadic;
790 aggref->aggkind = aggkind;
791 aggref->aggpresorted =
false;
795 aggref->aggtransno = -1;
802 if (fargs ==
NIL && !agg_star && !agg_within_group)
804 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
805 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
811 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
812 errmsg(
"aggregates cannot return sets"),
826 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
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;
860 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
861 errmsg(
"DISTINCT is not implemented for window functions"),
868 if (wfunc->winagg && fargs ==
NIL && !agg_star)
870 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
871 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
878 if (agg_order !=
NIL)
880 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
881 errmsg(
"aggregate ORDER BY is not implemented for window functions"),
887 if (!wfunc->winagg && agg_filter)
889 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
890 errmsg(
"FILTER is not implemented for non-aggregate window functions"),
898 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
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."),
906 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
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.");
1043 int ncandidates = 0;
1047 for (current_candidate = raw_candidates;
1048 current_candidate != NULL;
1049 current_candidate = next_candidate)
1051 next_candidate = current_candidate->
next;
1055 current_candidate->
next = *candidates;
1056 *candidates = current_candidate;
1128 Oid *current_typeids;
1138 bool current_is_preferred;
1140 bool resolved_unknowns;
1145 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
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++)
1167 if (input_typeids[
i] != UNKNOWNOID)
1172 input_base_typeids[
i] = UNKNOWNOID;
1183 last_candidate = NULL;
1184 for (current_candidate = candidates;
1185 current_candidate != NULL;
1186 current_candidate = current_candidate->
next)
1188 current_typeids = current_candidate->
args;
1190 for (
i = 0;
i < nargs;
i++)
1192 if (input_base_typeids[
i] != UNKNOWNOID &&
1193 current_typeids[
i] == input_base_typeids[
i])
1198 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1200 nbestMatch = nmatch;
1201 candidates = current_candidate;
1202 last_candidate = current_candidate;
1206 else if (nmatch == nbestMatch)
1208 last_candidate->
next = current_candidate;
1209 last_candidate = current_candidate;
1216 last_candidate->
next = NULL;
1218 if (ncandidates == 1)
1228 for (
i = 0;
i < nargs;
i++)
1232 last_candidate = NULL;
1233 for (current_candidate = candidates;
1234 current_candidate != NULL;
1235 current_candidate = current_candidate->
next)
1237 current_typeids = current_candidate->
args;
1239 for (
i = 0;
i < nargs;
i++)
1241 if (input_base_typeids[
i] != UNKNOWNOID)
1243 if (current_typeids[
i] == input_base_typeids[
i] ||
1249 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1251 nbestMatch = nmatch;
1252 candidates = current_candidate;
1253 last_candidate = current_candidate;
1256 else if (nmatch == nbestMatch)
1258 last_candidate->
next = current_candidate;
1259 last_candidate = current_candidate;
1265 last_candidate->
next = NULL;
1267 if (ncandidates == 1)
1298 resolved_unknowns =
false;
1299 for (
i = 0;
i < nargs;
i++)
1303 if (input_base_typeids[
i] != UNKNOWNOID)
1305 resolved_unknowns =
true;
1306 slot_category[
i] = TYPCATEGORY_INVALID;
1307 slot_has_preferred_type[
i] =
false;
1308 have_conflict =
false;
1309 for (current_candidate = candidates;
1310 current_candidate != NULL;
1311 current_candidate = current_candidate->
next)
1313 current_typeids = current_candidate->
args;
1314 current_type = current_typeids[
i];
1317 ¤t_is_preferred);
1318 if (slot_category[
i] == TYPCATEGORY_INVALID)
1321 slot_category[
i] = current_category;
1322 slot_has_preferred_type[
i] = current_is_preferred;
1324 else if (current_category == slot_category[
i])
1327 slot_has_preferred_type[
i] |= current_is_preferred;
1332 if (current_category == TYPCATEGORY_STRING)
1335 slot_category[
i] = current_category;
1336 slot_has_preferred_type[
i] = current_is_preferred;
1343 have_conflict =
true;
1347 if (have_conflict && slot_category[
i] != TYPCATEGORY_STRING)
1350 resolved_unknowns =
false;
1355 if (resolved_unknowns)
1359 first_candidate = candidates;
1360 last_candidate = NULL;
1361 for (current_candidate = candidates;
1362 current_candidate != NULL;
1363 current_candidate = current_candidate->
next)
1367 current_typeids = current_candidate->
args;
1368 for (
i = 0;
i < nargs;
i++)
1370 if (input_base_typeids[
i] != UNKNOWNOID)
1372 current_type = current_typeids[
i];
1375 ¤t_is_preferred);
1376 if (current_category != slot_category[
i])
1381 if (slot_has_preferred_type[
i] && !current_is_preferred)
1390 last_candidate = current_candidate;
1397 last_candidate->
next = current_candidate->
next;
1399 first_candidate = current_candidate->
next;
1406 candidates = first_candidate;
1408 last_candidate->
next = NULL;
1411 if (ncandidates == 1)
1425 if (nunknowns < nargs)
1427 Oid known_type = UNKNOWNOID;
1429 for (
i = 0;
i < nargs;
i++)
1431 if (input_base_typeids[
i] == UNKNOWNOID)
1433 if (known_type == UNKNOWNOID)
1434 known_type = input_base_typeids[
i];
1435 else if (known_type != input_base_typeids[
i])
1438 known_type = UNKNOWNOID;
1443 if (known_type != UNKNOWNOID)
1446 for (
i = 0;
i < nargs;
i++)
1447 input_base_typeids[
i] = known_type;
1449 last_candidate = NULL;
1450 for (current_candidate = candidates;
1451 current_candidate != NULL;
1452 current_candidate = current_candidate->
next)
1454 current_typeids = current_candidate->
args;
1458 if (++ncandidates > 1)
1460 last_candidate = current_candidate;
1463 if (ncandidates == 1)
1466 last_candidate->
next = NULL;
1467 return last_candidate;
1518 bool expand_variadic,
1519 bool expand_defaults,
1520 bool include_out_arguments,
1539 *true_typeids = NULL;
1545 expand_variadic, expand_defaults,
1546 include_out_arguments,
false,
1553 for (best_candidate = raw_candidates;
1554 best_candidate != NULL;
1555 best_candidate = best_candidate->
next)
1559 memcmp(argtypes, best_candidate->
args, nargs *
sizeof(
Oid)) == 0)
1563 if (best_candidate == NULL)
1604 if (nargs == 1 && fargs !=
NIL && fargnames ==
NIL)
1610 Oid sourceType = argtypes[0];
1614 if (sourceType == UNKNOWNOID &&
IsA(arg1,
Const))
1633 if ((sourceType == RECORDOID ||
1650 *rettype = targetType;
1654 *true_typeids = argtypes;
1663 if (raw_candidates != NULL)
1671 ¤t_candidates);
1674 if (ncandidates == 1)
1675 best_candidate = current_candidates;
1680 else if (ncandidates > 1)
1684 current_candidates);
1690 if (!best_candidate)
1715 if (fargnames !=
NIL && !expand_variadic && nargs > 0 &&
1716 best_candidate->
argnumbers[nargs - 1] != nargs - 1)
1722 *funcid = best_candidate->
oid;
1723 *nvargs = best_candidate->
nvargs;
1724 *true_typeids = best_candidate->
args;
1749 elog(
ERROR,
"cache lookup failed for function %u",
1750 best_candidate->
oid);
1752 *rettype = pform->prorettype;
1753 *retset = pform->proretset;
1754 *vatype = pform->provariadic;
1756 if (argdefaults && best_candidate->
ndargs > 0)
1758 Datum proargdefaults;
1763 if (best_candidate->
ndargs > pform->pronargdefaults)
1764 elog(
ERROR,
"not enough default arguments");
1767 Anum_pg_proc_proargdefaults);
1789 defargnumbers = NULL;
1791 for (
i = 0;
i < best_candidate->
ndargs;
i++)
1796 foreach(lc, defaults)
1804 *argdefaults = newdefaults;
1817 *argdefaults = defaults;
1821 switch (pform->prokind)
1823 case PROKIND_AGGREGATE:
1826 case PROKIND_FUNCTION:
1829 case PROKIND_PROCEDURE:
1832 case PROKIND_WINDOW:
1836 elog(
ERROR,
"unrecognized prokind: %c", pform->prokind);
1866 int numAggregatedArgs,
1867 Oid *actual_arg_types,
1868 Oid *declared_arg_types)
1871 numNonHypotheticalArgs;
1874 numDirectArgs =
list_length(fargs) - numAggregatedArgs;
1875 numNonHypotheticalArgs = numDirectArgs - numAggregatedArgs;
1877 if (numNonHypotheticalArgs < 0)
1878 elog(
ERROR,
"incorrect number of arguments to hypothetical-set aggregate");
1881 for (hargpos = numNonHypotheticalArgs; hargpos < numDirectArgs; hargpos++)
1883 int aargpos = numDirectArgs + (hargpos - numNonHypotheticalArgs);
1890 if (declared_arg_types[hargpos] != declared_arg_types[aargpos])
1891 elog(
ERROR,
"hypothetical-set aggregate has inconsistent declared argument types");
1894 if (declared_arg_types[hargpos] != ANYOID)
1916 actual_arg_types[hargpos],
1917 commontype, commontypmod,
1921 actual_arg_types[hargpos] = commontype;
1924 actual_arg_types[aargpos],
1925 commontype, commontypmod,
1929 actual_arg_types[aargpos] = commontype;
1950 Oid *actual_arg_types,
1951 Oid *declared_arg_types)
1956 foreach(current_fargs, fargs)
1959 if (actual_arg_types[
i] != declared_arg_types[
i])
1973 actual_arg_types[
i],
1974 declared_arg_types[
i], -1,
1984 actual_arg_types[
i],
1985 declared_arg_types[
i], -1,
1989 lfirst(current_fargs) = node;
2014 NULL,
false,
false);
2051 if (
IsA(first_arg,
Var) &&
2057 ((
Var *) first_arg)->varno,
2058 ((
Var *) first_arg)->varlevelsup);
2061 ((
Var *) first_arg)->varlevelsup,
2072 if (
IsA(first_arg,
Var) &&
2073 ((
Var *) first_arg)->vartype == RECORDOID)
2080 for (
i = 0;
i < tupdesc->
natts;
i++)
2090 fselect->
arg = (
Expr *) first_arg;
2092 fselect->resulttype = att->atttypid;
2093 fselect->resulttypmod = att->atttypmod;
2095 fselect->resultcollid = att->attcollation;
2096 return (
Node *) fselect;
2117 List *argnames,
const Oid *argtypes)
2131 for (
i = 0;
i < nargs;
i++)
2135 if (
i >= numposargs)
2138 lc =
lnext(argnames, lc);
2154 List *argnames,
const Oid *argtypes)
2157 nargs, argnames, argtypes);
2173 int nargs,
const Oid *argtypes,
2174 bool include_out_arguments,
bool missing_ok,
2182 Assert(argtypes != NULL || nargs == 0);
2189 include_out_arguments, missing_ok,
2193 for (; clist != NULL; clist = clist->
next)
2200 memcmp(argtypes, clist->
args, nargs *
sizeof(
Oid)) != 0)
2240 result = clist->
oid;
2282 switch (lookupError)
2291 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2292 errmsg(
"could not find a function named \"%s\"",
2296 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2297 errmsg(
"function %s does not exist",
2305 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2306 errmsg(
"function name \"%s\" is not unique",
2308 errhint(
"Specify the argument list to select the function unambiguously.")));
2351 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2352 errmsg_plural(
"procedures cannot have more than %d argument",
2353 "procedures cannot have more than %d arguments",
2358 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2359 errmsg_plural(
"functions cannot have more than %d argument",
2360 "functions cannot have more than %d arguments",
2370 foreach(args_item, func->
objargs)
2396 func->
objname, nargs, argoids,
2412 bool have_param_mode =
false;
2428 have_param_mode =
true;
2433 if (!have_param_mode)
2482 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2483 errmsg(
"%s is not a function",
2492 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2493 errmsg(
"%s is not a procedure",
2502 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2503 errmsg(
"function %s is not an aggregate",
2518 switch (lookupError)
2530 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2531 errmsg(
"could not find a procedure named \"%s\"",
2535 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2536 errmsg(
"procedure %s does not exist",
2544 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2545 errmsg(
"could not find an aggregate named \"%s\"",
2547 else if (argcount == 0)
2549 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2550 errmsg(
"aggregate %s(*) does not exist",
2554 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2555 errmsg(
"aggregate %s does not exist",
2564 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2565 errmsg(
"could not find a function named \"%s\"",
2569 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2570 errmsg(
"function %s does not exist",
2582 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2583 errmsg(
"function name \"%s\" is not unique",
2586 errhint(
"Specify the argument list to select the function unambiguously.") : 0));
2590 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2591 errmsg(
"procedure name \"%s\" is not unique",
2594 errhint(
"Specify the argument list to select the procedure unambiguously.") : 0));
2598 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2599 errmsg(
"aggregate name \"%s\" is not unique",
2602 errhint(
"Specify the argument list to select the aggregate unambiguously.") : 0));
2606 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
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");
2677 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
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");
2797 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2802 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
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 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)