diff options
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 566b4c910b3..b1bac866aa1 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -401,7 +401,7 @@ static char *get_relation_name(Oid relid); static char *generate_relation_name(Oid relid, List *namespaces); static char *generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes, - bool was_variadic, bool *use_variadic_p); + bool has_variadic, bool *use_variadic_p); static char *generate_operator_name(Oid operid, Oid arg1, Oid arg2); static text *string_to_text(char *str); static char *flatten_reloptions(Oid relid); @@ -8849,16 +8849,16 @@ generate_relation_name(Oid relid, List *namespaces) * * If we're dealing with a potentially variadic function (in practice, this * means a FuncExpr or Aggref, not some other way of calling a function), then - * was_variadic must specify whether VARIADIC appeared in the original call, + * has_variadic must specify whether variadic arguments have been merged, * and *use_variadic_p will be set to indicate whether to print VARIADIC in - * the output. For non-FuncExpr cases, was_variadic should be FALSE and + * the output. For non-FuncExpr cases, has_variadic should be FALSE and * use_variadic_p can be NULL. * * The result includes all necessary quoting and schema-prefixing. */ static char * generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes, - bool was_variadic, bool *use_variadic_p) + bool has_variadic, bool *use_variadic_p) { char *result; HeapTuple proctup; @@ -8884,32 +8884,27 @@ generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes, * Determine whether VARIADIC should be printed. We must do this first * since it affects the lookup rules in func_get_detail(). * - * Currently, we always print VARIADIC if the function is variadic and - * takes a variadic type other than ANY. (In principle, if VARIADIC - * wasn't originally specified and the array actual argument is - * deconstructable, we could print the array elements separately and not - * print VARIADIC, thus more nearly reproducing the original input. For - * the moment that seems like too much complication for the benefit.) - * However, if the function takes VARIADIC ANY, then the parser didn't - * fold the arguments together into an array, so we must print VARIADIC if - * and only if it was used originally. + * Currently, we always print VARIADIC if the function has a merged + * variadic-array argument. Note that this is always the case for + * functions taking a VARIADIC argument type other than VARIADIC ANY. + * + * In principle, if VARIADIC wasn't originally specified and the array + * actual argument is deconstructable, we could print the array elements + * separately and not print VARIADIC, thus more nearly reproducing the + * original input. For the moment that seems like too much complication + * for the benefit, and anyway we do not know whether VARIADIC was + * originally specified if it's a non-ANY type. */ if (use_variadic_p) { - if (OidIsValid(procform->provariadic)) - { - if (procform->provariadic != ANYOID) - use_variadic = true; - else - use_variadic = was_variadic; - } - else - use_variadic = false; + /* Parser should not have set funcvariadic unless fn is variadic */ + Assert(!has_variadic || OidIsValid(procform->provariadic)); + use_variadic = has_variadic; *use_variadic_p = use_variadic; } else { - Assert(!was_variadic); + Assert(!has_variadic); use_variadic = false; } |