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 1ow6UM-0004G7-E5 for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Nov 2022 18:53:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ow6UL-0000oa-9h for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Nov 2022 18:53:21 +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 1ow6UL-0000oQ-1D for pgsql-bugs@lists.postgresql.org; Fri, 18 Nov 2022 18:53:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ow6UJ-0001Na-2r for pgsql-bugs@lists.postgresql.org; Fri, 18 Nov 2022 18:53:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2AIIrE4w2251432; Fri, 18 Nov 2022 13:53:14 -0500 From: Tom Lane To: Alvaro Herrera cc: Marko Tiikkaja , eugene.pliskin@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17689: Two UPDATE operators in common table expressions (CTE) perform not as expected In-reply-to: <20221118170557.3ndokzwhilygtfq7@alvherre.pgsql> References: <20221118170557.3ndokzwhilygtfq7@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Fri, 18 Nov 2022 18:05:57 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2251430.1668797594.1@sss.pgh.pa.us> Date: Fri, 18 Nov 2022 13:53:14 -0500 Message-ID: <2251431.1668797594@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > On 2022-Nov-18, Marko Tiikkaja wrote: >> This is a documented limitation: >>> Trying to update the same row twice in a single statement is not >>> supported. > I wonder if we should try to detect the case, and raise an error instead > of it resulting in undefined behavior. My recollection is that that is really fallout from an ancient and intentional executor behavior, that we have to ignore multiple updates in order to not get into infinite loops. See comment about the "Halloween problem" in nodeLockRows.c. (I'm pretty sure there were once more comments about that, somewhere closer to ExecUpdate/ExecDelete --- this all dates back to Berkeley.) regards, tom lane