Ruleutils_17 Add RETURNING support to MERGE.

Relevant PG commit:
c649fa24a42ba89bf5460c7110e4fc8eeca65959
c649fa24a4
m3hm3t/pg17_isolation_test_cmd_from
naisila 2024-07-25 15:24:49 +02:00
parent 61b92ee697
commit c6c1ff2681
No known key found for this signature in database
GPG Key ID: A824BA9862D73E6D
1 changed files with 12 additions and 2 deletions

View File

@ -3874,8 +3874,13 @@ get_merge_query_def(Query *query, deparse_context *context,
appendStringInfoString(buf, "DO NOTHING");
}
/* No RETURNING support in MERGE yet */
Assert(query->returningList == NIL);
/* Add RETURNING if present */
if (query->returningList)
{
appendContextKeyword(context, " RETURNING",
-PRETTYINDENT_STD, PRETTYINDENT_STD, 1);
get_target_list(query->returningList, context, NULL, colNamesVisible);
}
ereport(DEBUG1, (errmsg("<Deparsed MERGE query: %s>", buf->data)));
}
@ -5033,6 +5038,7 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
case T_Aggref:
case T_GroupingFunc:
case T_WindowFunc:
case T_MergeSupportFunc:
case T_FuncExpr:
case T_JsonConstructorExpr:
/* function-like: name(..) or name[..] */
@ -5384,6 +5390,10 @@ get_rule_expr(Node *node, deparse_context *context,
get_windowfunc_expr((WindowFunc *) node, context);
break;
case T_MergeSupportFunc:
appendStringInfoString(buf, "MERGE_ACTION()");
break;
case T_SubscriptingRef:
{
SubscriptingRef *sbsref = (SubscriptingRef *) node;