Re: MERGE ... RETURNING
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Dean Rasheed <dean.a.rasheed@gmail.com>, jian he <jian.universality@gmail.com>
Cc: walther@technowledgy.de, Vik Fearing <vik@postgresfriends.org>, Gurjeet
Singh <gurjeet@singh.im>, Isaac Morland <isaac.morland@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Alvaro Herrera
<alvherre@alvh.no-ip.org>
Date: 2024-03-15T17:14:15Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add RETURNING support to MERGE.
- c649fa24a42b 17.0 landed
-
doc: Improve a couple of places in the MERGE docs.
- 97d4262683ac 17.0 landed
- d4c573d8e81e 16.3 landed
- a875743ff402 15.7 landed
-
doc: improve description of privileges for MERGE and update glossary.
- 4bc8f29088f8 17.0 landed
- 3b6728910ace 16.2 landed
- ff772853d02e 15.6 landed
-
Fix RLS policy usage in MERGE.
- c2e08b04c9e7 17.0 cited
-
Fix leak of LLVM "fatal-on-oom" section counter.
- 4f4d73466d71 17.0 cited
-
Implement outer-level aggregates to conform to the SQL spec, with
- e649796f128b 7.4.1 cited
On Fri, 2024-03-15 at 11:20 +0000, Dean Rasheed wrote:
> To recap, this adds support for a single RETURNING list at the end of
> a MERGE command, and a special MERGE_ACTION() function that may be
> used in the RETURNING list to return the action command string
> ('INSERT', 'UPDATE', or 'DELETE') that was executed.
...
> So barring any further objections, I'd like to go ahead and get this
> patch committed.
All of my concerns have been extensively discussed and it seems like
they are just the cost of having a good feature. Thank you for going
through so many alternative approaches, I think the one you've arrived
at is consistent with what Vik endorsed[1].
The MERGE_ACTION keyword is added to the 'col_name_keyword' and the
'bare_label_keyword' lists. That has some annoying effects, like:
CREATE FUNCTION merge_action() RETURNS TEXT
LANGUAGE SQL AS $$ SELECT 'asdf'; $$;
ERROR: syntax error at or near "("
LINE 1: CREATE FUNCTION merge_action() RETURNS TEXT
I didn't see any affirmative endorsement of exactly how the keyword is
implemented, but that patch has been around for a while, and I didn't
see any objection, either.
I like this feature from a user perspective. So +1 from me.
Regards,
Jeff Davis
[1]
https://www.postgresql.org/message-id/7db39b45-821f-4894-ada9-c19570b11b63@postgresfriends.org