Fix display of SQL-std func's args in INSERT/SELECT in ruleutils_15.c

Relevant PG commit:
a8d8445a7b2f80f6d0bfe97b19f90bd2cbef8759
boolean_node
naisila 2022-07-25 15:07:30 +03:00
parent c5650a06e4
commit 8539162bfc
1 changed files with 6 additions and 4 deletions

View File

@ -3269,7 +3269,7 @@ get_insert_query_def(Query *query, deparse_context *context)
if (select_rte) if (select_rte)
{ {
/* Add the SELECT */ /* Add the SELECT */
get_query_def(select_rte->subquery, buf, NIL, NULL, get_query_def(select_rte->subquery, buf, context->namespaces, NULL,
context->prettyFlags, context->wrapColumn, context->prettyFlags, context->wrapColumn,
context->indentLevel); context->indentLevel);
} }
@ -4722,10 +4722,12 @@ get_parameter(Param *param, deparse_context *context)
* If it's an external parameter, see if the outermost namespace provides * If it's an external parameter, see if the outermost namespace provides
* function argument names. * function argument names.
*/ */
if (param->paramkind == PARAM_EXTERN) if (param->paramkind == PARAM_EXTERN && context->namespaces != NIL)
{ {
dpns = lfirst(list_tail(context->namespaces)); dpns = llast(context->namespaces);
if (dpns->argnames) if (dpns->argnames &&
param->paramid > 0 &&
param->paramid <= dpns->numargs)
{ {
char *argname = dpns->argnames[param->paramid - 1]; char *argname = dpns->argnames[param->paramid - 1];