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 1oM6Xv-0002Lq-Ll for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Aug 2022 11:40:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oM6Xt-0006mB-8S for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Aug 2022 11:40:13 +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 1oM6Xs-0006l7-AZ for pgsql-bugs@lists.postgresql.org; Thu, 11 Aug 2022 11:40:12 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oM6Xn-0003QA-B1 for pgsql-bugs@lists.postgresql.org; Thu, 11 Aug 2022 11:40:11 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CF9645C0292; Thu, 11 Aug 2022 07:40:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 11 Aug 2022 07:40:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1660218004; x=1660304404; bh=8 m6olFevmDLr8iG5OftNx27SpsO+6NYOdkW7R0d/HzA=; b=pV1j6Dijy9byKDPzG 7FcfI8OrQIGPSn8DwiscQo0kxY3/URnMpXyakkoRgKHM02aX6qhLxiy1z1j1H6Wb gPZE5cFNm3wsVeogUYuKfZWfBM6hQiAUrcD3aeUcnRuroGinlkAgeRQ0roObtZI5 JBnUBpslUFv/Pc45FAfp3lKG9n/2mOqq39LVRJ7h+f9fC57VsGp3sDx9+kKHTlwu CESJ4qwJLZf9RYT3lLoLFB8wPmZC+t1imAIhcZdxer5O0FGN3trhHNERMgz+up4t GAV0H5SZ4gWsjmRRPlFuJTMrX8XPJoXbPgBAXmnwCbGulEggKWiX521EGEOvDEAP hqBQg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeggedggeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfggtggugfgjsehmke erredttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeduleekkefgtd dttedtkefguddvieffleetgeejiefhteehkeevfeettdduvdfhueenucffohhmrghinhep vghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhr gh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 Aug 2022 07:40:02 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 40F92376; Thu, 11 Aug 2022 13:40:20 +0200 (CEST) Date: Thu, 11 Aug 2022 13:40:20 +0200 From: Alvaro Herrera To: Richard Guo Cc: Tom Lane , borz_off@cs.msu.su, PostgreSQL mailing lists Subject: Re: BUG #17579: 15beta2: strange error when trying to use MERGE statement as a CTE Message-ID: <20220811114020.li7sp32bxqsnlx7n@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="54exrjnke3mqqaau" 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 --54exrjnke3mqqaau Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2022-Aug-11, Richard Guo wrote: > Seems we neglect to think of MERGE statements when we transform WITH > clauses and when we rewrite the query. If we add the check against MERGE > statement in parse_cte.c and in rewriteHandler.c, the query in problem > can work. But I'm not sure if that's enough. I would like to have MERGE within CTEs, but I think for it to be truly useful we need a RETURNING clause, which is currently not implemented. I don't think it's terribly difficult to implement ... AFAICS most of the pieces are there ... but clearly out of scope for pg15. > +1 to disallow it for now. This patch does that. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ --54exrjnke3mqqaau Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Reject-MERGE-in-CTE.patch"