Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmkiI-00054X-6Q for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Nov 2021 22:44:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mmkiH-00087O-2X for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Nov 2021 22:44:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmkiG-00087C-4v for pgsql-hackers@lists.postgresql.org; Mon, 15 Nov 2021 22:44:32 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmkiB-0001W5-LN for pgsql-hackers@lists.postgresql.org; Mon, 15 Nov 2021 22:44:31 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 8A5B55C0285; Mon, 15 Nov 2021 17:44:24 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 15 Nov 2021 17:44:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=n9kmDYdpnErm7lzqghfhP8icKARHokQXAGIOW2AChBQ=; b=m2+o8H9s M95twpfzKmjz9FC/y+9/WsGbMJc5HgFAHt3B4t1MOMMekm4j0SrI/wwjoqFoMZPV Mn0EA+jAdxlRTIaRxNFaH3ZVC8MoylcVmhIo0XpmNAPgeYSsvQFdxFrxLPn1+L91 7iVW78u0HSgv2bHVlP9YoetX2I6MFmtz/QBfx5uCUlYbeDYm1uw3EbYhGm4RLRYb X7Hs+Jp4nzoqxbpuMFQrgXaFg08gqi4pg/xfIJ44NgbTyypjVf3TnV6hH0ZEq5Mh TYVtAlurBF6ZVm7C34h4GG38f/6M9OZAETK95INcSEH7I8Wb/m8zhv9K0PTkKCgq moMgRQNciCV4Pg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeduucetufdoteggodetrfdotffvucfrrh hofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgv rhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtf frrghtthgvrhhnpeekudekffeiueeggedvffdvjeffvdekjeehudeiueeffffggfdvfeef feevudelffenucffohhmrghinhepghhithhhuhgsrdgtohhmpdgvnhhtvghrphhrihhsvg gusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Nov 2021 17:44:24 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 3CCE72A05F0; Mon, 15 Nov 2021 19:44:21 -0300 (-03) Date: Mon, 15 Nov 2021 19:44:21 -0300 From: Alvaro Herrera To: Tomas Vondra , Zhihong Yu , Daniel Westermann , Amit Langote , Justin Pryzby Cc: Pg Hackers , Simon Riggs , Pavan Deolasee Subject: Re: support for MERGE Message-ID: <202111152244.7ja4ihufwiqk@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211113225836.GM17618@telsasoft.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks everyone for the feedback. I attach a version with the fixes that were submitted, as well as some additional changes: - I removed the restriction for tables inheritance and added the sample I showed to regression. - I added DO NOTHING support to the WHERE MATCHED case; it previously only covered WHERE NOT MATCHED. I was thinking earlier that it may be possible to clean up the parse_merge.c code by using another RangeTblRef to process the data source RTE. Haven't tried yet. This stuff is all in https://github.com/alvherre/postgres/commits/merge-15 -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "Nunca confiaré en un traidor. Ni siquiera si el traidor lo he creado yo" (Barón Vladimir Harkonnen)