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 1mn1HJ-0000Ok-33 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Nov 2021 16:25:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mn1HG-0005nX-Ug for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Nov 2021 16:25:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mn1HG-0005nO-8k for pgsql-hackers@lists.postgresql.org; Tue, 16 Nov 2021 16:25:46 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mn1HD-0001I2-2V for pgsql-hackers@lists.postgresql.org; Tue, 16 Nov 2021 16:25:45 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 25E545C0198; Tue, 16 Nov 2021 11:25:41 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 16 Nov 2021 11:25:41 -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=95qjV5It8H3uOGiQRoDdsXvNOfEV5gKynwbrdooUBvw=; b=JceApGot z0x0wxOG6taVGsyqs0u1oLNaeFIou944jJoSCB742KueK51jnAsc4JfeFIZvR8Qw sUC1WBSixPCsTKY2qFmETa2Nr3F1N3Ikofw6Biuuz0v8h1ZQh2iYepnyM2gA56AJ SpQD0zluuiONW+NIpv5LokACSmuZQdASOscAGlSELIz2xeSRL61PLbcN23OXXJDM RvKN4WW1VTnukCI6u3YtLXMqUQU/5RnVCq4LT2FnOjjRwHyvLwrigHLtVfhNbcRl TEaFiO7nI9O7bgOa+Y85VD3HzmQJtY1HF12EHo47SgYHUYB3sXJQbCvo4cb8Ct0M EETWwsWp6XpCIQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfedvgdekiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepudevgeetieeiheefudevveefgeejieejtdevteekkeelgffg leegteehvdduteegnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Nov 2021 11:25:40 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id C2BE72A05A8; Tue, 16 Nov 2021 13:25:37 -0300 (-03) Date: Tue, 16 Nov 2021 13:25:37 -0300 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Amit Langote Cc: Daniel Westermann , pgsql-hackers@lists.postgresql.org, Simon Riggs , Pavan Deolasee Subject: Re: support for MERGE Message-ID: <202111161625.ypdd2kxce64b@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Amit On 2021-Nov-16, Amit Langote wrote: > AFAICS, MERGE operating on an inheritance parent that is not > partitioned should work mostly the same as the case where it is > partitioned (good thing that it works at all without needing any > special code!), though only the INSERT actions would have to be > handled appropriately by the user using triggers and such. And also I > guess any UPDATE actions that need to move rows between child tables > because that too involves tuple routing logic. As long as we're clear > on that in the documentation, I don't see why this case should not be > covered in the initial version. Yeah, I think the reason it works so cleanly is that the code you and/or Tom added to be able to get rid of inheritance_planner is superb, including the new row identity stuff. For the same reason, I suspect that adding support for foreign tables should be reasonably simple -- just add explicit support for handling "wholerow" in a few places. I have not tried. > I thought for a second about the cases where child tables have columns > not present in the root parent mentioned in the command, but I guess > that possibility doesn't present problems given that the command > wouldn't be able to mention such columns to begin with; it can only > refer to the root parent's column which must be present in all of the > affected child tables. Right. On the other hand, if we did have a problem with extra columns, ISTM that would be on the user's head, not our responsibility. In the example I added, there is one child table with variant column layout; it did require that the insertion trigger explicitly lists the columns in the INSERT statement for that table, but otherwise it work correctly. > In any case, I have a feeling that the planner would catch any > problematic cases if there're any while converting MergeAction > expressions into the individual child table layouts. Yeah, AFAICS it worked fine for the case I tried. Maybe there are more elaborate ones that I didn't think of, of course. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "Puedes vivir sólo una vez, pero si lo haces bien, una vez es suficiente"