On Mon, 9 Jan 2023 at 16:23, Vik Fearing <vik@postgresfriends.org> wrote:
>
> Bikeshedding here. Instead of Yet Another WITH Clause, could we perhaps
> make a MERGING() function analogous to the GROUPING() function that goes
> with grouping sets?
>
> MERGE ...
> RETURNING *, MERGING('clause'), MERGING('action');
>
Hmm, possibly, but I think that would complicate the implementation quite a bit.
GROUPING() is not really a function (in the sense that there is no
pg_proc entry for it, you can't do "\df grouping", and it isn't
executed with its arguments like a normal function). Rather, it
requires special-case handling in the parser, through to the executor,
and I think MERGING() would be similar.
Also, it masks any user function with the same name, and would
probably require MERGING to be some level of reserved keyword.
I'm not sure that's worth it, just to have a more standard-looking
RETURNING list, without a WITH clause.
Regards,
Dean