Re: support for MERGE

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Daniel Westermann <dwe(at)dbi-services(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: support for MERGE
Date: 2022-03-25 15:36:59
Message-ID: 202203251536.dbvhn2ygk3aa@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here's v20, another rebase with some small changes:

- Changed psql tab-completion as suggested by Peter. However, I didn't
use Query_for_list_of_updatables because that includes relation types
that aren't supported by MERGE, so I kept a separate query definition
including only plain and partitioned tables. While at it, fix its
quoting: use of quote_ident() is no longer necessary.

- I changed the MergeWhenClause productions in the grammar to be more
self-contained. In the original, there was too much stuff being done
in its caller production. For example, the production for DELETE was
returning NULL and the caller was creating the struct .. not sure why.

Also, set all the fields in the struct, not just some. This is not
strictly necessary since the struct is zeroed by makeNode anyway, but
this is out standard practice and looks more tidy -- this is what led
me to discover the next point.

- I noticed that node MergeWhenClause had a member 'cols' to store
INSERT columns, but at the same time it was ignoring the targetList
member, which was documented to be used for this. I don't know the
reason for this separate member. I removed 'cols' and made the code
use 'targetList' instead.

- parse_clause.[ch] still contained some changes that were no longer
necessary due to my earlier hacking on parse analysis. Put them back
as they were.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/

Attachment Content-Type Size
v20-0001-MERGE-SQL-Command-following-SQL-2016.patch text/x-diff 380.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2022-03-25 15:46:52 Re: psql - add SHOW_ALL_RESULTS option
Previous Message Justin Pryzby 2022-03-25 15:27:42 Re: pg_relation_size on partitioned table