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 1jMF0q-0007ay-Ey for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 18:01:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMF0p-0007zG-CW for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 18:01:19 +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 1jMF0p-0007z9-5t for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 18:01:19 +0000 Received: from mail-qv1-xf43.google.com ([2607:f8b0:4864:20::f43]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jMF0l-0001oP-LA for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 18:01:18 +0000 Received: by mail-qv1-xf43.google.com with SMTP id s18so4159905qvn.1 for ; Wed, 08 Apr 2020 11:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=HNySreXie0Wm2WQh44QMp8MqDKdRS3EruRYC+owciV0=; b=YlLlqxUnvOvEVv6H9VTFfsZ8X8ApLHuhmJALOcpSRVkmNTDM7JN4BK39DyHbh4GHnq Std8R7H/jyxapUGtMGl8QGeG/GwhVxpeZD4vqg6zF/XDUE65S/2ur+gPZ76UKTpaxQQ7 LJQS1Ho/94KNV2YAU9WEk8xm592g/+h65+Ow9xp8Yj9c/1PbxHTuKrDCpk3vElh8pO2c icOvRRpH6XmUDIWMSglnnoULJSpBeCLfKjFMghhFXn6ySssOnhgo1Yx7j4HCAfugLTaB fgyEclgHGq+qxLsFJGC8xQtjP01a9T8MXBEfgTw5kgOBuH1Z1meghaas4B8Ig/LuzHyg FXFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=HNySreXie0Wm2WQh44QMp8MqDKdRS3EruRYC+owciV0=; b=fKu1I0bTcnVckGpx+HEfbgFVA0Sp2ck8cORSuHKyF4E/3ocaRcQ1+wiT9VhlNrKjrC uV5JEmSGiS+5yzubIizJIe9JjgTcnRocIytWaxkEs9hDCNXziD0WwpnYimPsssvofV5E 9ad5p1cr3V09mcIXMNizre4EZw91tgDz5KHEcaEvZTugqb7XiEItQc+asIVaeGI+uigY Pldk+d0+XSA7ZqwuvB/l5u+UzLj2ZspQrTYfxkmhks4ztImrdg3eHZOLivYhKmUYIraG mFZgejxsKK3agqHAKMg6dHk84Q5azUsxpcmRjrLosruZiisotxkCfj+iiN6HV5AKvS03 NbSQ== X-Gm-Message-State: AGi0PuZfhAgVHpEryVL14QfoHxj9DfoZhyZynYnTiiYS2h0YnKJyEIw+ nHwPy8SUadp92WFM1wSpxsiQV///TN9cEhg0NBzvt8i5s6sCnPPxMP06CygvoolhjW9kWAVxkuY IT+s+f1lJv61AeJodiSxLOVUYObGXjDMU/eh9/odHZ9e1L07bQTgNvszg4gJsvszZ0sNeKb813O 6gg5Xtdu2hzg3SWwvQ X-Google-Smtp-Source: APiQypIGPx2X0CdXQWPI4qwdeMLmEO7PWeATqoFIK2/9Sau31UivPU7wZYEFHrulmtEylYly83RJQQ== X-Received: by 2002:a0c:ee81:: with SMTP id u1mr8771744qvr.187.1586368873736; Wed, 08 Apr 2020 11:01:13 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id o13sm19116111qkg.111.2020.04.08.11.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:01:13 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id A44C3300AAD; Wed, 8 Apr 2020 14:01:10 -0400 (-04) Date: Wed, 8 Apr 2020 14:01:10 -0400 From: Alvaro Herrera To: Tom Lane Cc: Justin Pryzby , pgsql-hackers@lists.postgresql.org Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables Message-ID: <20200408180110.GA17093@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1012.1586364645@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Apr-08, Tom Lane wrote: > 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. 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. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services