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 1jMF8e-0007rM-Tz for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 18:09:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMF8d-000057-SN for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 18:09:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMF8d-00004s-L6 for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 18:09:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMF8a-0001yg-IQ for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 18:09:22 +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 038I9Iij005955; Wed, 8 Apr 2020 14:09:18 -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: <20200408180110.GA17093@alvherre.pgsql> References: <20200408180110.GA17093@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 08 Apr 2020 14:01:10 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5953.1586369358.1@sss.pgh.pa.us> Date: Wed, 08 Apr 2020 14:09:18 -0400 Message-ID: <5954.1586369358@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2020-Apr-08, Tom Lane wrote: >> 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. > Hmm. Those things are used for the legacy inheritance case supporting > multiple inheritance, where we need to figure out which parent the table > is being detached (disinherited) from. But for partitioning we know > which parent it is, since there can only be one. So I don't think that > argument applies. My point is that so long as you only allow the case of exactly one parent, you can just delete the child trigger, because it must belong to that parent. As soon as there's any flexibility, you are going to end up reinventing all the stuff we had to invent to manage maybe-or-maybe-not-inherited columns. So I think the "detach" idea is the first step on that road, and I counsel not taking that step. (This implies that when creating a child trigger, we should error out, *not* allow the case, if there's already a trigger by that name. Not sure if that's what happens today, but again I'd say that's what we should do to avoid complicated cases.) regards, tom lane