fix-sql-function-param-decompile.patch
text/x-diff
Filename: fix-sql-function-param-decompile.patch
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/adt/ruleutils.c | 6 | 4 |
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1bb25738a5..6b4022c3bc 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -6566,7 +6566,7 @@ get_insert_query_def(Query *query, deparse_context *context)
if (select_rte)
{
/* 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->indentLevel);
}
@@ -7919,10 +7919,12 @@ get_parameter(Param *param, deparse_context *context)
* If it's an external parameter, see if the outermost namespace provides
* function argument names.
*/
- if (param->paramkind == PARAM_EXTERN)
+ if (param->paramkind == PARAM_EXTERN && context->namespaces != NIL)
{
- dpns = lfirst(list_tail(context->namespaces));
- if (dpns->argnames)
+ dpns = llast(context->namespaces);
+ if (dpns->argnames &&
+ param->paramid > 0 &&
+ param->paramid <= dpns->numargs)
{
char *argname = dpns->argnames[param->paramid - 1];