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;
837 wfunc->runCondition =
NIL;
845 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
846 errmsg(
"DISTINCT is not implemented for window functions"),
853 if (wfunc->winagg && fargs ==
NIL && !agg_star)
855 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
856 errmsg(
"%s(*) must be used to call a parameterless aggregate function",
863 if (agg_order !=
NIL)
865 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
866 errmsg(
"aggregate ORDER BY is not implemented for window functions"),
872 if (!wfunc->winagg && agg_filter)
874 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
875 errmsg(
"FILTER is not implemented for non-aggregate window functions"),
883 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
884 errmsg(
"window function calls cannot contain set-returning function calls"),
885 errhint(
"You might be able to move the set-returning function into a LATERAL FROM item."),
891 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
892 errmsg(
"window functions cannot return sets"),
898 retval = (
Node *) wfunc;
934 for (current_candidate = raw_candidates;
935 current_candidate != NULL;
936 current_candidate = next_candidate)
938 next_candidate = current_candidate->
next;
942 current_candidate->
next = *candidates;
943 *candidates = current_candidate;
1015 Oid *current_typeids;
1025 bool current_is_preferred;
1027 bool resolved_unknowns;
1032 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
1033 errmsg_plural(
"cannot pass more than %d argument to a function",
1034 "cannot pass more than %d arguments to a function",
1052 for (
i = 0;
i < nargs;
i++)
1054 if (input_typeids[
i] != UNKNOWNOID)
1059 input_base_typeids[
i] = UNKNOWNOID;
1070 last_candidate = NULL;
1071 for (current_candidate = candidates;
1072 current_candidate != NULL;
1073 current_candidate = current_candidate->
next)
1075 current_typeids = current_candidate->
args;
1077 for (
i = 0;
i < nargs;
i++)
1079 if (input_base_typeids[
i] != UNKNOWNOID &&
1080 current_typeids[
i] == input_base_typeids[
i])
1085 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1087 nbestMatch = nmatch;
1088 candidates = current_candidate;
1089 last_candidate = current_candidate;
1093 else if (nmatch == nbestMatch)
1095 last_candidate->
next = current_candidate;
1096 last_candidate = current_candidate;
1103 last_candidate->
next = NULL;
1105 if (ncandidates == 1)
1115 for (
i = 0;
i < nargs;
i++)
1119 last_candidate = NULL;
1120 for (current_candidate = candidates;
1121 current_candidate != NULL;
1122 current_candidate = current_candidate->
next)
1124 current_typeids = current_candidate->
args;
1126 for (
i = 0;
i < nargs;
i++)
1128 if (input_base_typeids[
i] != UNKNOWNOID)
1130 if (current_typeids[
i] == input_base_typeids[
i] ||
1136 if ((nmatch > nbestMatch) || (last_candidate == NULL))
1138 nbestMatch = nmatch;
1139 candidates = current_candidate;
1140 last_candidate = current_candidate;
1143 else if (nmatch == nbestMatch)
1145 last_candidate->
next = current_candidate;
1146 last_candidate = current_candidate;
1152 last_candidate->
next = NULL;
1154 if (ncandidates == 1)
1185 resolved_unknowns =
false;
1186 for (
i = 0;
i < nargs;
i++)
1190 if (input_base_typeids[
i] != UNKNOWNOID)
1192 resolved_unknowns =
true;
1193 slot_category[
i] = TYPCATEGORY_INVALID;
1194 slot_has_preferred_type[
i] =
false;
1195 have_conflict =
false;
1196 for (current_candidate = candidates;
1197 current_candidate != NULL;
1198 current_candidate = current_candidate->
next)
1200 current_typeids = current_candidate->
args;
1201 current_type = current_typeids[
i];
1204 ¤t_is_preferred);
1205 if (slot_category[
i] == TYPCATEGORY_INVALID)
1208 slot_category[
i] = current_category;
1209 slot_has_preferred_type[
i] = current_is_preferred;
1211 else if (current_category == slot_category[
i])
1214 slot_has_preferred_type[
i] |= current_is_preferred;
1219 if (current_category == TYPCATEGORY_STRING)
1222 slot_category[
i] = current_category;
1223 slot_has_preferred_type[
i] = current_is_preferred;
1230 have_conflict =
true;
1234 if (have_conflict && slot_category[
i] != TYPCATEGORY_STRING)
1237 resolved_unknowns =
false;
1242 if (resolved_unknowns)
1246 first_candidate = candidates;
1247 last_candidate = NULL;
1248 for (current_candidate = candidates;
1249 current_candidate != NULL;
1250 current_candidate = current_candidate->
next)
1254 current_typeids = current_candidate->
args;
1255 for (
i = 0;
i < nargs;
i++)
1257 if (input_base_typeids[
i] != UNKNOWNOID)
1259 current_type = current_typeids[
i];
1262 ¤t_is_preferred);
1263 if (current_category != slot_category[
i])
1268 if (slot_has_preferred_type[
i] && !current_is_preferred)
1277 last_candidate = current_candidate;
1284 last_candidate->
next = current_candidate->
next;
1286 first_candidate = current_candidate->
next;
1293 candidates = first_candidate;
1295 last_candidate->
next = NULL;
1298 if (ncandidates == 1)
1312 if (nunknowns < nargs)
1314 Oid known_type = UNKNOWNOID;
1316 for (
i = 0;
i < nargs;
i++)
1318 if (input_base_typeids[
i] == UNKNOWNOID)
1320 if (known_type == UNKNOWNOID)
1321 known_type = input_base_typeids[
i];
1322 else if (known_type != input_base_typeids[
i])
1325 known_type = UNKNOWNOID;
1330 if (known_type != UNKNOWNOID)
1333 for (
i = 0;
i < nargs;
i++)
1334 input_base_typeids[
i] = known_type;
1336 last_candidate = NULL;
1337 for (current_candidate = candidates;
1338 current_candidate != NULL;
1339 current_candidate = current_candidate->
next)
1341 current_typeids = current_candidate->
args;
1345 if (++ncandidates > 1)
1347 last_candidate = current_candidate;
1350 if (ncandidates == 1)
1353 last_candidate->
next = NULL;
1354 return last_candidate;
1400 bool expand_variadic,
1401 bool expand_defaults,
1402 bool include_out_arguments,
1420 *true_typeids = NULL;
1426 expand_variadic, expand_defaults,
1427 include_out_arguments,
false);
1433 for (best_candidate = raw_candidates;
1434 best_candidate != NULL;
1435 best_candidate = best_candidate->
next)
1439 memcmp(argtypes, best_candidate->
args, nargs *
sizeof(
Oid)) == 0)
1443 if (best_candidate == NULL)
1484 if (nargs == 1 && fargs !=
NIL && fargnames ==
NIL)
1490 Oid sourceType = argtypes[0];
1494 if (sourceType == UNKNOWNOID &&
IsA(arg1,
Const))
1513 if ((sourceType == RECORDOID ||
1530 *rettype = targetType;
1534 *true_typeids = argtypes;
1543 if (raw_candidates != NULL)
1551 ¤t_candidates);
1554 if (ncandidates == 1)
1555 best_candidate = current_candidates;
1560 else if (ncandidates > 1)
1564 current_candidates);
1570 if (!best_candidate)
1595 if (fargnames !=
NIL && !expand_variadic && nargs > 0 &&
1596 best_candidate->
argnumbers[nargs - 1] != nargs - 1)
1599 *funcid = best_candidate->
oid;
1600 *nvargs = best_candidate->
nvargs;
1601 *true_typeids = best_candidate->
args;
1626 elog(
ERROR,
"cache lookup failed for function %u",
1627 best_candidate->
oid);
1629 *rettype = pform->prorettype;
1630 *retset = pform->proretset;
1631 *vatype = pform->provariadic;
1633 if (argdefaults && best_candidate->
ndargs > 0)
1635 Datum proargdefaults;
1640 if (best_candidate->
ndargs > pform->pronargdefaults)
1641 elog(
ERROR,
"not enough default arguments");
1644 Anum_pg_proc_proargdefaults);
1666 defargnumbers = NULL;
1668 for (
i = 0;
i < best_candidate->
ndargs;
i++)
1673 foreach(lc, defaults)
1681 *argdefaults = newdefaults;
1694 *argdefaults = defaults;
1698 switch (pform->prokind)
1700 case PROKIND_AGGREGATE:
1703 case PROKIND_FUNCTION:
1706 case PROKIND_PROCEDURE:
1709 case PROKIND_WINDOW:
1713 elog(
ERROR,
"unrecognized prokind: %c", pform->prokind);
1743 int numAggregatedArgs,
1744 Oid *actual_arg_types,
1745 Oid *declared_arg_types)
1748 numNonHypotheticalArgs;
1751 numDirectArgs =
list_length(fargs) - numAggregatedArgs;
1752 numNonHypotheticalArgs = numDirectArgs - numAggregatedArgs;
1754 if (numNonHypotheticalArgs < 0)
1755 elog(
ERROR,
"incorrect number of arguments to hypothetical-set aggregate");
1758 for (hargpos = numNonHypotheticalArgs; hargpos < numDirectArgs; hargpos++)
1760 int aargpos = numDirectArgs + (hargpos - numNonHypotheticalArgs);
1767 if (declared_arg_types[hargpos] != declared_arg_types[aargpos])
1768 elog(
ERROR,
"hypothetical-set aggregate has inconsistent declared argument types");
1771 if (declared_arg_types[hargpos] != ANYOID)
1793 actual_arg_types[hargpos],
1794 commontype, commontypmod,
1798 actual_arg_types[hargpos] = commontype;
1801 actual_arg_types[aargpos],
1802 commontype, commontypmod,
1806 actual_arg_types[aargpos] = commontype;
1827 Oid *actual_arg_types,
1828 Oid *declared_arg_types)
1833 foreach(current_fargs, fargs)
1836 if (actual_arg_types[
i] != declared_arg_types[
i])
1850 actual_arg_types[
i],
1851 declared_arg_types[
i], -1,
1861 actual_arg_types[
i],
1862 declared_arg_types[
i], -1,
1866 lfirst(current_fargs) = node;
1891 NULL,
false,
false);
1928 if (
IsA(first_arg,
Var) &&
1934 ((
Var *) first_arg)->varno,
1935 ((
Var *) first_arg)->varlevelsup);
1938 ((
Var *) first_arg)->varlevelsup,
1949 if (
IsA(first_arg,
Var) &&
1950 ((
Var *) first_arg)->vartype == RECORDOID)
1957 for (
i = 0;
i < tupdesc->
natts;
i++)
1967 fselect->
arg = (
Expr *) first_arg;
1969 fselect->resulttype = att->atttypid;
1970 fselect->resulttypmod = att->atttypmod;
1972 fselect->resultcollid = att->attcollation;
1973 return (
Node *) fselect;
1994 List *argnames,
const Oid *argtypes)
2008 for (
i = 0;
i < nargs;
i++)
2012 if (
i >= numposargs)
2015 lc =
lnext(argnames, lc);
2031 List *argnames,
const Oid *argtypes)
2034 nargs, argnames, argtypes);
2050 int nargs,
const Oid *argtypes,
2051 bool include_out_arguments,
bool missing_ok,
2058 Assert(argtypes != NULL || nargs == 0);
2065 include_out_arguments, missing_ok);
2068 for (; clist != NULL; clist = clist->
next)
2075 memcmp(argtypes, clist->
args, nargs *
sizeof(
Oid)) != 0)
2115 result = clist->
oid;
2157 switch (lookupError)
2166 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2167 errmsg(
"could not find a function named \"%s\"",
2171 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2172 errmsg(
"function %s does not exist",
2180 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2181 errmsg(
"function name \"%s\" is not unique",
2183 errhint(
"Specify the argument list to select the function unambiguously.")));
2226 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2227 errmsg_plural(
"procedures cannot have more than %d argument",
2228 "procedures cannot have more than %d arguments",
2233 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2234 errmsg_plural(
"functions cannot have more than %d argument",
2235 "functions cannot have more than %d arguments",
2245 foreach(args_item, func->
objargs)
2271 func->
objname, nargs, argoids,
2287 bool have_param_mode =
false;
2303 have_param_mode =
true;
2308 if (!have_param_mode)
2357 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2358 errmsg(
"%s is not a function",
2367 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2368 errmsg(
"%s is not a procedure",
2377 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2378 errmsg(
"function %s is not an aggregate",
2393 switch (lookupError)
2405 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2406 errmsg(
"could not find a procedure named \"%s\"",
2410 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2411 errmsg(
"procedure %s does not exist",
2419 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2420 errmsg(
"could not find an aggregate named \"%s\"",
2422 else if (argcount == 0)
2424 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2425 errmsg(
"aggregate %s(*) does not exist",
2429 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2430 errmsg(
"aggregate %s does not exist",
2439 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2440 errmsg(
"could not find a function named \"%s\"",
2444 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
2445 errmsg(
"function %s does not exist",
2457 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2458 errmsg(
"function name \"%s\" is not unique",
2461 errhint(
"Specify the argument list to select the function unambiguously.") : 0));
2465 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2466 errmsg(
"procedure name \"%s\" is not unique",
2469 errhint(
"Specify the argument list to select the procedure unambiguously.") : 0));
2473 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2474 errmsg(
"aggregate name \"%s\" is not unique",
2477 errhint(
"Specify the argument list to select the aggregate unambiguously.") : 0));
2481 (
errcode(ERRCODE_AMBIGUOUS_FUNCTION),
2482 errmsg(
"routine name \"%s\" is not unique",
2485 errhint(
"Specify the argument list to select the routine unambiguously.") : 0));
2540 err =
_(
"set-returning functions are not allowed in JOIN conditions");
2552 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2553 errmsg(
"set-returning functions must appear at top level of FROM"),
2561 err =
_(
"set-returning functions are not allowed in policy expressions");
2577 err =
_(
"set-returning functions are not allowed in window definitions");
2615 err =
_(
"set-returning functions are not allowed in MERGE WHEN conditions");
2619 err =
_(
"set-returning functions are not allowed in check constraints");
2623 err =
_(
"set-returning functions are not allowed in DEFAULT expressions");
2626 err =
_(
"set-returning functions are not allowed in index expressions");
2629 err =
_(
"set-returning functions are not allowed in index predicates");
2632 err =
_(
"set-returning functions are not allowed in statistics expressions");
2635 err =
_(
"set-returning functions are not allowed in transform expressions");
2638 err =
_(
"set-returning functions are not allowed in EXECUTE parameters");
2641 err =
_(
"set-returning functions are not allowed in trigger WHEN conditions");
2644 err =
_(
"set-returning functions are not allowed in partition bound");
2647 err =
_(
"set-returning functions are not allowed in partition key expressions");
2650 err =
_(
"set-returning functions are not allowed in CALL arguments");
2653 err =
_(
"set-returning functions are not allowed in COPY FROM WHERE conditions");
2656 err =
_(
"set-returning functions are not allowed in column generation expressions");
2672 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2677 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2679 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 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)
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_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_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)
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)