46 List *fargs,
int numAggregatedArgs,
47 Oid *actual_arg_types,
Oid *declared_arg_types);
50 Node *first_arg,
int location);
52 int nargs,
const Oid *argtypes,
53 bool include_out_arguments,
bool missing_ok,
93 bool is_column = (
fn == NULL);
95 Expr *agg_filter = NULL;
97 bool agg_within_group = (
fn ?
fn->agg_within_group :
false);
98 bool agg_star = (
fn ?
fn->agg_star :
false);
99 bool agg_distinct = (
fn ?
fn->agg_distinct :
false);
100 bool func_variadic = (
fn ?
fn->func_variadic :
false);
102 bool could_be_projection;
106 Node *first_arg = NULL;
110 Oid *declared_arg_types;
124 if (
fn &&
fn->agg_filter != NULL)
137 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
138 errmsg_plural(
"cannot pass more than %d argument to a function",
139 "cannot pass more than %d arguments to a function",
161 !is_column && !agg_within_group)
167 actual_arg_types[nargs++] = argtype;
189 foreach(lc, argnames)
191 if (strcmp(na->name, (
char *)
lfirst(lc)) == 0)
193 (
errcode(ERRCODE_SYNTAX_ERROR),
194 errmsg(
"argument name \"%s\" used more than once",
198 argnames =
lappend(argnames, na->name);
204 (
errcode(ERRCODE_SYNTAX_ERROR),
205 errmsg(
"positional argument cannot follow named argument"),
213 Assert(first_arg != NULL);
223 could_be_projection = (nargs == 1 && !proc_call &&
224 agg_order ==
NIL && agg_filter == NULL &&
225 !agg_star && !agg_distinct && over == NULL &&
226 !func_variadic && argnames ==
NIL &&
228 (actual_arg_types[0] == RECORDOID ||
234 if (could_be_projection && is_column)
268 !func_variadic,
true, proc_call,
269 &funcid, &rettype, &retset,
271 &declared_arg_types, &argdefaults);
286 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
287 errmsg(
"%s is not a procedure",
291 errhint(
"To call a function, use SELECT."),
296 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
297 errmsg(
"%s is a procedure",
301 errhint(
"To call a procedure, use CALL."),
314 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
315 errmsg(
"%s(*) specified, but %s is not an aggregate function",
321 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
322 errmsg(
"DISTINCT specified, but %s is not an aggregate function",
325 if (agg_within_group)
327 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
328 errmsg(
"WITHIN GROUP specified, but %s is not an aggregate function",
331 if (agg_order !=
NIL)
333 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
334 errmsg(
"ORDER BY specified, but %s is not an aggregate function",
339 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
340 errmsg(
"FILTER specified, but %s is not an aggregate function",
345 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
346 errmsg(
"OVER specified, but %s is not a window function nor an aggregate function",
369 elog(
ERROR,
"cache lookup failed for aggregate %u", funcid);
371 aggkind = classForm->aggkind;
372 catDirectArgs = classForm->aggnumdirectargs;
376 if (AGGKIND_IS_ORDERED_SET(aggkind))
378 int numAggregatedArgs;
381 if (!agg_within_group)
383 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
384 errmsg(
"WITHIN GROUP is required for ordered-set aggregate %s",
389 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
390 errmsg(
"OVER is not supported for ordered-set aggregate %s",
408 numDirectArgs = nargs - numAggregatedArgs;
409 Assert(numDirectArgs >= 0);
414 if (numDirectArgs != catDirectArgs)
416 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
417 errmsg(
"function %s does not exist",
421 errhint_plural(
"There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
422 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
425 catDirectArgs, numDirectArgs),
445 if (numDirectArgs != catDirectArgs)
447 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
448 errmsg(
"function %s does not exist",
452 errhint_plural(
"There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
453 "There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
456 catDirectArgs, numDirectArgs),
470 if (aggkind == AGGKIND_HYPOTHETICAL)
472 if (nvargs != 2 * numAggregatedArgs)
474 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
475 errmsg(
"function %s does not exist",
479 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).",
481 nvargs - numAggregatedArgs, numAggregatedArgs),
486 if (nvargs <= numAggregatedArgs)
488 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
489 errmsg(
"function %s does not exist",
493 errhint_plural(
"There is an ordered-set aggregate %s, but it requires at least %d direct argument.",
494 "There is an ordered-set aggregate %s, but it requires at least %d direct arguments.",
504 if (aggkind == AGGKIND_HYPOTHETICAL)
506 actual_arg_types, declared_arg_types);
511 if (agg_within_group)
513 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
514 errmsg(
"%s is not an ordered-set aggregate, so it cannot have WITHIN GROUP",
526 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
527 errmsg(
"window function %s requires an OVER clause",
531 if (agg_within_group)
533 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
534 errmsg(
"window function %s cannot have WITHIN GROUP",
545 actual_arg_types[0], rettype, -1,
562 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
563 errmsg(
"procedure %s is not unique",
566 errhint(
"Could not choose a best candidate procedure. "
567 "You might need to add explicit type casts."),
571 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
572 errmsg(
"function %s is not unique",
575 errhint(
"Could not choose a best candidate function. "
576 "You might need to add explicit type casts."),
592 if (could_be_projection)
606 if (
list_length(agg_order) > 1 && !agg_within_group)
610 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
611 errmsg(
"function %s does not exist",
614 errhint(
"No aggregate function matches the given name and argument types. "
615 "Perhaps you misplaced ORDER BY; ORDER BY must appear "
616 "after all regular arguments of the aggregate."),
621 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
622 errmsg(
"procedure %s does not exist",
625 errhint(
"No procedure matches the given name and argument types. "
626 "You might need to add explicit type casts."),
630 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
631 errmsg(
"function %s does not exist",
634 errhint(
"No function matches the given name and argument types. "
635 "You might need to add explicit type casts."),
646 nargsplusdefs = nargs;
647 foreach(l, argdefaults)
654 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
655 errmsg_plural(
"cannot pass more than %d argument to a function",
656 "cannot pass more than %d arguments to a function",
661 actual_arg_types[nargsplusdefs++] =
exprType(expr);
686 func_variadic =
false;
693 if (nvargs > 0 && vatype != ANYOID)
696 int non_var_args = nargs - nvargs;
699 Assert(non_var_args >= 0);
709 (
errcode(ERRCODE_UNDEFINED_OBJECT),
710 errmsg(
"could not find array type for data type %s",
714 newa->multidims =
false;
722 func_variadic =
true;
729 if (nargs > 0 && vatype == ANYOID && func_variadic)
731 Oid va_arr_typid = actual_arg_types[nargs - 1];
735 (
errcode(ERRCODE_DATATYPE_MISMATCH),
736 errmsg(
"VARIADIC argument must be an array"),
750 funcexpr->
funcid = funcid;
751 funcexpr->funcresulttype = rettype;
752 funcexpr->funcretset = retset;
753 funcexpr->funcvariadic = func_variadic;
754 funcexpr->funcformat = funcformat;
756 funcexpr->
args = fargs;
759 retval = (
Node *) funcexpr;
767 aggref->aggtype = rettype;
774 aggref->aggstar = agg_star;
775 aggref->aggvariadic = func_variadic;
776 aggref->aggkind = aggkind;
777 aggref->aggpresorted =
false;
781 aggref->aggtransno = -1;
788 if (fargs ==
NIL && !agg_star && !agg_within_group)
790 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
791 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
797 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
798 errmsg(
"aggregates cannot return sets"),
812 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
813 errmsg(
"aggregates cannot use named arguments"),
819 retval = (
Node *) aggref;
827 Assert(!agg_within_group);
830 wfunc->wintype = rettype;
834 wfunc->winstar = agg_star;
844 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
845 errmsg(
"DISTINCT is not implemented for window functions"),
852 if (wfunc->winagg && fargs ==
NIL && !agg_star)
854 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
855 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
862 if (agg_order !=
NIL)
864 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
865 errmsg(
"aggregate ORDER BY is not implemented for window functions"),
871 if (!wfunc->winagg && agg_filter)
873 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
874 errmsg(
"FILTER is not implemented for non-aggregate window functions"),
882 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
883 errmsg(
"window function calls cannot contain set-returning function calls"),
884 errhint(
"You might be able to move the set-returning function into a LATERAL FROM item."),
890 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
891 errmsg(
"window functions cannot return sets"),
897 retval = (
Node *) wfunc;
933 for (current_candidate = raw_candidates;
934 current_candidate != NULL;
935 current_candidate = next_candidate)
937 next_candidate = current_candidate->
next;
941 current_candidate->
next = *candidates;
942 *candidates = current_candidate;
1014 Oid *current_typeids;
1024 bool current_is_preferred;
1026 bool resolved_unknowns;
1031 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
1032 errmsg_plural(
"cannot pass more than %d argument to a function",
1033 "cannot pass more than %d arguments to a function",
1051 for (
i = 0;
i < nargs;
i++)
1053 if (input_typeids[
i] != UNKNOWNOID)
1058 input_base_typeids[
i] = UNKNOWNOID;
1069 last_candidate = NULL;
1070 for (current_candidate = candidates;
1071 current_candidate != NULL;
1072 current_candidate = current_candidate->
next)
1074 current_typeids = current_candidate->
args;
1076 for (
i = 0;
i < nargs;
i++)
1078 if (input_base_typeids[
i] != UNKNOWNOID &&
1079 current_typeids[
i] == input_base_typeids[
i])
1084 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1086 nbestMatch = nmatch;
1087 candidates = current_candidate;
1088 last_candidate = current_candidate;
1092 else if (nmatch == nbestMatch)
1094 last_candidate->
next = current_candidate;
1095 last_candidate = current_candidate;
1102 last_candidate->
next = NULL;
1104 if (ncandidates == 1)
1114 for (
i = 0;
i < nargs;
i++)
1118 last_candidate = NULL;
1119 for (current_candidate = candidates;
1120 current_candidate != NULL;
1121 current_candidate = current_candidate->
next)
1123 current_typeids = current_candidate->
args;
1125 for (
i = 0;
i < nargs;
i++)
1127 if (input_base_typeids[
i] != UNKNOWNOID)
1129 if (current_typeids[
i] == input_base_typeids[
i] ||
1135 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1137 nbestMatch = nmatch;
1138 candidates = current_candidate;
1139 last_candidate = current_candidate;
1142 else if (nmatch == nbestMatch)
1144 last_candidate->
next = current_candidate;
1145 last_candidate = current_candidate;
1151 last_candidate->
next = NULL;
1153 if (ncandidates == 1)
1184 resolved_unknowns =
false;
1185 for (
i = 0;
i < nargs;
i++)
1189 if (input_base_typeids[
i] != UNKNOWNOID)
1191 resolved_unknowns =
true;
1192 slot_category[
i] = TYPCATEGORY_INVALID;
1193 slot_has_preferred_type[
i] =
false;
1194 have_conflict =
false;
1195 for (current_candidate = candidates;
1196 current_candidate != NULL;
1197 current_candidate = current_candidate->
next)
1199 current_typeids = current_candidate->
args;
1200 current_type = current_typeids[
i];
1203 ¤t_is_preferred);
1204 if (slot_category[
i] == TYPCATEGORY_INVALID)
1207 slot_category[
i] = current_category;
1208 slot_has_preferred_type[
i] = current_is_preferred;
1210 else if (current_category == slot_category[
i])
1213 slot_has_preferred_type[
i] |= current_is_preferred;
1218 if (current_category == TYPCATEGORY_STRING)
1221 slot_category[
i] = current_category;
1222 slot_has_preferred_type[
i] = current_is_preferred;
1229 have_conflict =
true;
1233 if (have_conflict && slot_category[
i] != TYPCATEGORY_STRING)
1236 resolved_unknowns =
false;
1241 if (resolved_unknowns)
1245 first_candidate = candidates;
1246 last_candidate = NULL;
1247 for (current_candidate = candidates;
1248 current_candidate != NULL;
1249 current_candidate = current_candidate->
next)
1253 current_typeids = current_candidate->
args;
1254 for (
i = 0;
i < nargs;
i++)
1256 if (input_base_typeids[
i] != UNKNOWNOID)
1258 current_type = current_typeids[
i];
1261 ¤t_is_preferred);
1262 if (current_category != slot_category[
i])
1267 if (slot_has_preferred_type[
i] && !current_is_preferred)
1276 last_candidate = current_candidate;
1283 last_candidate->
next = current_candidate->
next;
1285 first_candidate = current_candidate->
next;
1292 candidates = first_candidate;
1294 last_candidate->
next = NULL;
1297 if (ncandidates == 1)
1311 if (nunknowns < nargs)
1313 Oid known_type = UNKNOWNOID;
1315 for (
i = 0;
i < nargs;
i++)
1317 if (input_base_typeids[
i] == UNKNOWNOID)
1319 if (known_type == UNKNOWNOID)
1320 known_type = input_base_typeids[
i];
1321 else if (known_type != input_base_typeids[
i])
1324 known_type = UNKNOWNOID;
1329 if (known_type != UNKNOWNOID)
1332 for (
i = 0;
i < nargs;
i++)
1333 input_base_typeids[
i] = known_type;
1335 last_candidate = NULL;
1336 for (current_candidate = candidates;
1337 current_candidate != NULL;
1338 current_candidate = current_candidate->
next)
1340 current_typeids = current_candidate->
args;
1344 if (++ncandidates > 1)
1346 last_candidate = current_candidate;
1349 if (ncandidates == 1)
1352 last_candidate->
next = NULL;
1353 return last_candidate;
1399 bool expand_variadic,
1400 bool expand_defaults,
1401 bool include_out_arguments,
1419 *true_typeids = NULL;
1425 expand_variadic, expand_defaults,
1426 include_out_arguments,
false);
1432 for (best_candidate = raw_candidates;
1433 best_candidate != NULL;
1434 best_candidate = best_candidate->
next)
1438 memcmp(argtypes, best_candidate->
args, nargs *
sizeof(
Oid)) == 0)
1442 if (best_candidate == NULL)
1483 if (nargs == 1 && fargs !=
NIL && fargnames ==
NIL)
1489 Oid sourceType = argtypes[0];
1493 if (sourceType == UNKNOWNOID &&
IsA(arg1,
Const))
1512 if ((sourceType == RECORDOID ||
1529 *rettype = targetType;
1533 *true_typeids = argtypes;
1542 if (raw_candidates != NULL)
1550 ¤t_candidates);
1553 if (ncandidates == 1)
1554 best_candidate = current_candidates;
1559 else if (ncandidates > 1)
1563 current_candidates);
1569 if (!best_candidate)
1594 if (fargnames !=
NIL && !expand_variadic && nargs > 0 &&
1595 best_candidate->
argnumbers[nargs - 1] != nargs - 1)
1598 *funcid = best_candidate->
oid;
1599 *nvargs = best_candidate->
nvargs;
1600 *true_typeids = best_candidate->
args;
1625 elog(
ERROR,
"cache lookup failed for function %u",
1626 best_candidate->
oid);
1628 *rettype = pform->prorettype;
1629 *retset = pform->proretset;
1630 *vatype = pform->provariadic;
1632 if (argdefaults && best_candidate->
ndargs > 0)
1634 Datum proargdefaults;
1639 if (best_candidate->
ndargs > pform->pronargdefaults)
1640 elog(
ERROR,
"not enough default arguments");
1643 Anum_pg_proc_proargdefaults);
1665 defargnumbers = NULL;
1667 for (
i = 0;
i < best_candidate->
ndargs;
i++)
1672 foreach(lc, defaults)
1680 *argdefaults = newdefaults;
1693 *argdefaults = defaults;
1697 switch (pform->prokind)
1699 case PROKIND_AGGREGATE:
1702 case PROKIND_FUNCTION:
1705 case PROKIND_PROCEDURE:
1708 case PROKIND_WINDOW:
1712 elog(
ERROR,
"unrecognized prokind: %c", pform->prokind);
1742 int numAggregatedArgs,
1743 Oid *actual_arg_types,
1744 Oid *declared_arg_types)
1747 numNonHypotheticalArgs;
1750 numDirectArgs =
list_length(fargs) - numAggregatedArgs;
1751 numNonHypotheticalArgs = numDirectArgs - numAggregatedArgs;
1753 if (numNonHypotheticalArgs < 0)
1754 elog(
ERROR,
"incorrect number of arguments to hypothetical-set aggregate");
1757 for (hargpos = numNonHypotheticalArgs; hargpos < numDirectArgs; hargpos++)
1759 int aargpos = numDirectArgs + (hargpos - numNonHypotheticalArgs);
1766 if (declared_arg_types[hargpos] != declared_arg_types[aargpos])
1767 elog(
ERROR,
"hypothetical-set aggregate has inconsistent declared argument types");
1770 if (declared_arg_types[hargpos] != ANYOID)
1792 actual_arg_types[hargpos],
1793 commontype, commontypmod,
1797 actual_arg_types[hargpos] = commontype;
1800 actual_arg_types[aargpos],
1801 commontype, commontypmod,
1805 actual_arg_types[aargpos] = commontype;
1826 Oid *actual_arg_types,
1827 Oid *declared_arg_types)
1832 foreach(current_fargs, fargs)
1835 if (actual_arg_types[
i] != declared_arg_types[
i])
1849 actual_arg_types[
i],
1850 declared_arg_types[
i], -1,
1860 actual_arg_types[
i],
1861 declared_arg_types[
i], -1,
1865 lfirst(current_fargs) = node;
1890 NULL,
false,
false);
1927 if (
IsA(first_arg,
Var) &&
1933 ((
Var *) first_arg)->varno,
1934 ((
Var *) first_arg)->varlevelsup);
1937 ((
Var *) first_arg)->varlevelsup,
1948 if (
IsA(first_arg,
Var) &&
1949 ((
Var *) first_arg)->vartype == RECORDOID)
1956 for (
i = 0;
i < tupdesc->
natts;
i++)
1966 fselect->
arg = (
Expr *) first_arg;
1968 fselect->resulttype = att->atttypid;
1969 fselect->resulttypmod = att->atttypmod;
1971 fselect->resultcollid = att->attcollation;
1972 return (
Node *) fselect;
1993 List *argnames,
const Oid *argtypes)
2007 for (
i = 0;
i < nargs;
i++)
2011 if (
i >= numposargs)
2014 lc =
lnext(argnames, lc);
2030 List *argnames,
const Oid *argtypes)
2033 nargs, argnames, argtypes);
2049 int nargs,
const Oid *argtypes,
2050 bool include_out_arguments,
bool missing_ok,
2057 Assert(argtypes != NULL || nargs == 0);
2064 include_out_arguments, missing_ok);
2067 for (; clist != NULL; clist = clist->
next)
2074 memcmp(argtypes, clist->
args, nargs *
sizeof(
Oid)) != 0)
2114 result = clist->
oid;
2156 switch (lookupError)
2165 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2166 errmsg(
"could not find a function named \"%s\"",
2170 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2171 errmsg(
"function %s does not exist",
2179 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2180 errmsg(
"function name \"%s\" is not unique",
2182 errhint(
"Specify the argument list to select the function unambiguously.")));
2225 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2226 errmsg_plural(
"procedures cannot have more than %d argument",
2227 "procedures cannot have more than %d arguments",
2232 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2233 errmsg_plural(
"functions cannot have more than %d argument",
2234 "functions cannot have more than %d arguments",
2244 foreach(args_item, func->
objargs)
2270 func->
objname, nargs, argoids,
2286 bool have_param_mode =
false;
2302 have_param_mode =
true;
2307 if (!have_param_mode)
2356 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2357 errmsg(
"%s is not a function",
2366 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2367 errmsg(
"%s is not a procedure",
2376 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2377 errmsg(
"function %s is not an aggregate",
2392 switch (lookupError)
2404 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2405 errmsg(
"could not find a procedure named \"%s\"",
2409 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2410 errmsg(
"procedure %s does not exist",
2418 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2419 errmsg(
"could not find an aggregate named \"%s\"",
2421 else if (argcount == 0)
2423 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2424 errmsg(
"aggregate %s(*) does not exist",
2428 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2429 errmsg(
"aggregate %s does not exist",
2438 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2439 errmsg(
"could not find a function named \"%s\"",
2443 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2444 errmsg(
"function %s does not exist",
2456 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2457 errmsg(
"function name \"%s\" is not unique",
2460 errhint(
"Specify the argument list to select the function unambiguously.") : 0));
2464 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2465 errmsg(
"procedure name \"%s\" is not unique",
2468 errhint(
"Specify the argument list to select the procedure unambiguously.") : 0));
2472 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2473 errmsg(
"aggregate name \"%s\" is not unique",
2476 errhint(
"Specify the argument list to select the aggregate unambiguously.") : 0));
2480 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2481 errmsg(
"routine name \"%s\" is not unique",
2484 errhint(
"Specify the argument list to select the routine unambiguously.") : 0));
2539 err =
_(
"set-returning functions are not allowed in JOIN conditions");
2551 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2552 errmsg(
"set-returning functions must appear at top level of FROM"),
2560 err =
_(
"set-returning functions are not allowed in policy expressions");
2576 err =
_(
"set-returning functions are not allowed in window definitions");
2613 err =
_(
"set-returning functions are not allowed in MERGE WHEN conditions");
2617 err =
_(
"set-returning functions are not allowed in check constraints");
2621 err =
_(
"set-returning functions are not allowed in DEFAULT expressions");
2624 err =
_(
"set-returning functions are not allowed in index expressions");
2627 err =
_(
"set-returning functions are not allowed in index predicates");
2630 err =
_(
"set-returning functions are not allowed in statistics expressions");
2633 err =
_(
"set-returning functions are not allowed in transform expressions");
2636 err =
_(
"set-returning functions are not allowed in EXECUTE parameters");
2639 err =
_(
"set-returning functions are not allowed in trigger WHEN conditions");
2642 err =
_(
"set-returning functions are not allowed in partition bound");
2645 err =
_(
"set-returning functions are not allowed in partition key expressions");
2648 err =
_(
"set-returning functions are not allowed in CALL arguments");
2651 err =
_(
"set-returning functions are not allowed in COPY FROM WHERE conditions");
2654 err =
_(
"set-returning functions are not allowed in column generation expressions");
2670 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2675 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2677 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)
elog(ERROR, "%s: %s", p2, msg)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errmsg_internal(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)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * list_delete_first_n(List *list, int n)
List * list_truncate(List *list, int new_size)
List * lappend(List *list, void *datum)
List * list_copy_tail(const List *oldlist, int nskip)
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)
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok)
char * NameListToString(const List *names)
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)
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type)
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)
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)
FuncDetailCode func_get_detail(List *funcname, List *fargs, List *fargnames, int nargs, Oid *argtypes, bool expand_variadic, bool expand_defaults, bool include_out_arguments, Oid *funcid, Oid *rettype, bool *retset, int *nvargs, Oid *vatype, Oid **true_typeids, List **argdefaults)
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)
Node * ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, Node *last_srf, FuncCall *fn, bool proc_call, int location)
static Oid FuncNameAsType(List *funcname)
Oid LookupFuncWithArgs(ObjectType objtype, ObjectWithArgs *func, bool missing_ok)
const char * funcname_signature_string(const char *funcname, int nargs, List *argnames, const Oid *argtypes)
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_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)
static ListCell * list_head(const List *l)
static ListCell * list_nth_cell(const List *list, int n)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
#define foreach_delete_current(lst, cell)
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)
#define TupleDescAttr(tupdesc, i)