Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8i77-005Zkn-H1 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2024 15:38:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t8i74-00771S-AD for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2024 15:38:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8i73-00770J-UX for pgsql-hackers@lists.postgresql.org; Wed, 06 Nov 2024 15:38:30 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8i71-000UVb-Cu for pgsql-hackers@postgresql.org; Wed, 06 Nov 2024 15:38:29 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 5833C13805E8; Wed, 6 Nov 2024 10:38:26 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Wed, 06 Nov 2024 10:38:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1730907506; x=1730993906; bh=E 2DBkdt53vBpjWXfzPCz7TVV7CRda7DvsVJvCxxK8zg=; b=CDE0lO54DjOWmx0T0 L0B1+5UAuTeD6S8/wR0KOhfeqtbRivJaJ4F2Pjea6N6vzXIkBwRMNbK6X3FEF8US YbtUxtcJCyVo6aEXPya/LcHfPLZWxhQ2Jg2ErvfPKH7vBJ9t04Zd97M6ucnCFxuT Qfgk8h6T636xruWm7YOyRfsHfRBOBhMnXUGoPMr+l2z3XuDQLq5fh9/p/K3k/T8m ODWcq9vXHmOc/hGssFkeId7+G4QXtihXBfNOfYL6FxPH+Xpph2ZFXrpZJVO6FsSR vanTGF+gVDub1YnOakDK26HP8sLl4RRp04Yle8bdxjJ4NB7ULe1nzBDz1EF0rVss 6/myw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrtddvgdejjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecu hfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrd hnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfej jefhgfeiueeukeejkeffgfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprh hishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrghdpnhgspghrtg hpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepjhhgughrsegurghl ihgsohdrtghomhdprhgtphhtthhopegvgigtlhhushhiohhnsehgmhgrihhlrdgtohhmpd hrtghpthhtohepthhnughrfigrnhhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepghhu ihhllhgruhhmvgeslhgvlhgrrhhgvgdrihhnfhhopdhrtghpthhtohepphhgshhqlhdqhh grtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohepthhglhesshhs shdrphhghhdrphgrrdhush X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Nov 2024 10:38:25 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1730907502; bh=bS3LJ6MaRq/8tQVTp/2cYP8iEOx8fJNE1te5FxLZYIk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=MgI8CchQMtJ8kJRRr1S6gywz61giZkdfk5oUHPZOz7ZVQEg1LIYtfxiyKOR1bQ/y6 GR36jWCj+M2bblLC51C/UZN3gVT2dVpvgv9ZBbC4zPDAPOPZIuGjy7QQyfyA7oELe2 QUS1rX6rZaTJRQ5J05oc32WI9PdNTxmPUE100F/yQn9tu8uoJPOXf+lfkVig4M6rUx TJfqqUrAeNRaYKMwuqyMM8GBpmog6rYTr1NQv+gdwQvH/qRqoPNGQD9lYrtaFuUJEV Lbl9hHdd8EYIHNPHKRYY7BxnklRpHnRT4b8zzuwclHfAqsdu8en9m7W4Cbg1OZRL5O ZVVV5SCuGztTA== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 9D1819B; Wed, 6 Nov 2024 16:38:22 +0100 (CET) Date: Wed, 6 Nov 2024 16:38:22 +0100 From: Alvaro Herrera To: Tom Lane Cc: Tender Wang , Alexander Lakhin , Jehan-Guillaume de Rorthais , "pgsql-hackers@postgresql.org" , Guillaume Lelarge Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails Message-ID: <202411061538.oko7rvbfp2gh@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3097658.1730840765@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Nov-05, Tom Lane wrote: > I'm trying to write release notes for commits 53af9491a et al, > and it seems to me that we need to explain how to get out of > the mess that would be left behind by the old DETACH code. > There's no hint about that in the commit message :-( > Clearly, if you have now-inconsistent data, there's little > help for that but to manually fix the inconsistencies. > What I am worried about is how to get to a state where you > have correct catalog entries for the constraint. > > Will ALTER TABLE DROP CONSTRAINT on the now stand-alone table > work to clean out the old catalog entries for the constraint? Yes -- as far as I can tell, a DROP CONSTRAINT of the offending constraint is successful and leaves no unwanted detritus. Perhaps one more task for me is to figure out a way to get a list of all the constraints that are broken because of this ... let me see if I can figure that out. > I'm worried that it will either fail, or go through but remove > triggers on the referenced table that we still need for the > original partitioned table. If that doesn't work I think we had > better create a recipe for manually removing the detritus. As as far as I can see, it works and no triggers are spuriously removed. > Once the old entries are gone it should be possible to do ALTER TABLE > ADD CONSTRAINT (with an updated server), and that would validate > your data. It's the DROP CONSTRAINT part that worries me. Yeah, that's correct: adding the constraint again after removing its broken self detects that there are values violating the RI. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest "foo" someone someday shall type "supercalifragilisticexpialidocious" (5th Commandment for C programmers)