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 1jMDud-000513-OU for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 16:50:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMDuc-0007da-FL for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 16:50:50 +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 1jMDuc-0007dE-8b for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 16:50:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMDuZ-0002v6-Vf for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 16:50:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 038GojFC001013; Wed, 8 Apr 2020 12:50:45 -0400 From: Tom Lane To: Alvaro Herrera cc: Justin Pryzby , pgsql-hackers@lists.postgresql.org Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables In-reply-to: <20200408160239.GA13987@alvherre.pgsql> References: <20200408160239.GA13987@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 08 Apr 2020 12:02:39 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1011.1586364645.1@sss.pgh.pa.us> Date: Wed, 08 Apr 2020 12:50:45 -0400 Message-ID: <1012.1586364645@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > Hmm. Let's agree to what behavior we want, and then we implement that. > It seems to me there are two choices: > 1. on detach, keep the trigger but make it independent of the trigger on > parent. (This requires that the trigger is made dependent on the > trigger on parent, if the table is attached as partition again; > otherwise you'd end up with multiple copies of the trigger if you > detach/attach multiple times). > 2. on detach, remove the trigger from the partition. > I think (2) is easier to implement, but (1) is the more convenient > behavior. I think that #1 would soon lead to needing all the same infrastructure as we have for inherited columns and constraints, ie triggers would need equivalents of attislocal and attinhcount. I don't really want to go there, so I'd vote for #2. regards, tom lane