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 1sKK41-009Wqu-Pn for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Jun 2024 15:51:05 +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 1sKK3z-00AEqa-IH for pgsql-bugs@arkaria.postgresql.org; Thu, 20 Jun 2024 15:51:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKK3z-00AEqS-9v for pgsql-bugs@lists.postgresql.org; Thu, 20 Jun 2024 15:51:04 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKK3x-002fm5-Ru for pgsql-bugs@lists.postgresql.org; Thu, 20 Jun 2024 15:51:03 +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 45KFovUH354614; Thu, 20 Jun 2024 11:50:57 -0400 From: Tom Lane To: Alvaro Herrera cc: Mujjamil k , Laurenz Albe , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18516: Foreign key data integrity is not validated when reenabled the trigger on tables In-reply-to: <202406201307.ojevjmezqu45@alvherre.pgsql> References: <202406201307.ojevjmezqu45@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Thu, 20 Jun 2024 15:07:44 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <354612.1718898657.1@sss.pgh.pa.us> Date: Thu, 20 Jun 2024 11:50:57 -0400 Message-ID: <354613.1718898657@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > I think it's not a bad idea to suggest that we could have a new command > ALTER TABLE .. DISABLE CONSTRAINT, which can be run by the table owner > and paired with a later ALTER TABLE ENABLE CONSTRAINT, which verifies > the constraint. The existing, supported way to do this is to drop the foreign key constraint and then later re-create it. As noted, if you mess with the triggers directly then any subsequent breakage is your responsibility. regards, tom lane