Re: MERGE ... RETURNING - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: MERGE ... RETURNING
Date
Msg-id CAEZATCWv2JD7ZTx+pfFSw-GtThk5uHE4LyjoRY0r5KakvcgxfQ@mail.gmail.com
Whole thread Raw
In response to Re: MERGE ... RETURNING  (Vik Fearing <vik@postgresfriends.org>)
Responses Re: MERGE ... RETURNING
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: suppressing useless wakeups in logical/worker.c
Next
From: Nathan Bossart
Date:
Subject: Re: add \dpS to psql