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 1m97iP-00013V-8A for pgsql-general@arkaria.postgresql.org; Thu, 29 Jul 2021 15:12:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m97iO-0007rL-7W for pgsql-general@arkaria.postgresql.org; Thu, 29 Jul 2021 15:12:52 +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 1m97iN-0007rC-T0 for pgsql-general@lists.postgresql.org; Thu, 29 Jul 2021 15:12:51 +0000 Received: from mail.voodoo-arts.net ([85.214.246.71] helo=voodoo-arts.net) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m97iL-0004j2-UL for pgsql-general@postgresql.org; Thu, 29 Jul 2021 15:12:51 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by voodoo-arts.net (Postfix) with ESMTP id 2C2DE4C20CB; Thu, 29 Jul 2021 17:12:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=voodoo-arts.net; s=mail; t=1627571569; bh=zmHFRKuSP/VYSSP+vzARKm0UlR+qD3xungiTzO6Xwb4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DVVCP1PV/dYvsCe3clTBSArp8mC0WSK7uou6wdo12g7KlGVSvwsJV3vb1atZ+2XM5 0TLJpQ7UZcA07uUTXQ61hLFpbFo99itboI91VtcweBcDJj4jRFgqh+BN8KswpPkqE2 xw8FWIxaJuoq/9XYzKHVi/0U44LwY2A1SdLHjEXA= X-Virus-Scanned: Debian amavisd-new at voodoo-arts.net Received: from voodoo-arts.net ([127.0.0.1]) by localhost (h1925366.stratoserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ItbKubj2uY3P; Thu, 29 Jul 2021 17:12:48 +0200 (CEST) Received: from dewberry.localdomain (ip5f5b8a0a.dynamic.kabel-deutschland.de [95.91.138.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by voodoo-arts.net (Postfix) with ESMTPSA id B00A64C1E4A; Thu, 29 Jul 2021 17:12:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=voodoo-arts.net; s=mail; t=1627571568; bh=zmHFRKuSP/VYSSP+vzARKm0UlR+qD3xungiTzO6Xwb4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EK/Qj2Y/87sy8a15t2TKz2jaKxLYOu8YmyeCmAPsWMPkicOarcqFi1hMYXYOhoi5/ ijKVvy4/Qhioy3zlW/cwqs1ZemOs6gmo1FEV0vT3vgQOFSI3IuD9kRVh09wZTP1OOO aGzgm4iEcqeA7mL0OrfPUa5OaRjDR4KdJMOmLbUA= Date: Thu, 29 Jul 2021 17:12:48 +0200 From: Tom Kazimiers To: Tom Lane Cc: pgsql-general@postgresql.org Subject: Re: Updating PK and all FKs to it in CTE Message-ID: References: <713691.1627570269@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <713691.1627570269@sss.pgh.pa.us> User-Agent: Mutt/2.1 (4b100969) (2021-06-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jul 29, 2021 at 10:51:09AM -0400, Tom Lane wrote: >I tried to reproduce your problem and failed; the attached script >acts as I'd expect. So there must be some moving part you've not >mentioned. Can yo create a similar self-contained example that >fails? Thanks very much for trying this. I failed to create a self-contained example and just now realized what the problem is: a trigger function accidentally created an entry with the old ID (changing the primary key was not anticipated until now), throwing off the constraint check. I noticed when running this explicitly in a transaction and then inspecting the table that triggered the error and also got the same error with ON UPDATE CASCADE. My apologies, it just took a while for me to realize where this entry came from and that it was not the CTE or ON UPDATE CASCADE causing this. It's all resolved now and I am glad the CTE behaves as expected. Kind regards, Tom