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 1jMDod-0004mX-Vk for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 16:44:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMDoc-0000Gl-T8 for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 16:44:38 +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 1jMDoc-0000EP-Lt for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 16:44:38 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jMDoa-0002qv-Ne for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 16:44:38 +0000 Received: by mail-qt1-x841.google.com with SMTP id b10so332217qtt.9 for ; Wed, 08 Apr 2020 09:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8ToX/CKGB6jAMSdWQzGxDvd13lRfYVJLEmaqwlj5LSc=; b=PuNNKYZXFDG0gCB5gXncycE2OMZ8WjtD28lTX30AqOjMqX5Ui5ppXFNmDQl1703+OY Bm89b+DCxPNNAhJAgNHxpGBmNsIV0TPM9OEbSl7s5XBZK1pzSCL845epJmaA4SoBZbLy RLdZ3Rh7POx/p1wRAVlHkBQNVxoZuNcZLMSq6bxtokhse/ZK31CA2tDJUkyEPl6hh7FM J/niAPymy/QcL4sUiE5PFdYOeedakqdKHm8oN12nmbQcD73oj+aDcX/HGLp/+NO/Oje2 8sKW+ySzTVZRsoz94IaMrTRBYSYJPIt6Z25qWeBB9bqfZXzsd7E7Zu72qXlc+BaVYo8/ phAw== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8ToX/CKGB6jAMSdWQzGxDvd13lRfYVJLEmaqwlj5LSc=; b=hiEk/uReXj5VO2FrkgjCcgUQFqXrGd9goL78ygOaDjueA0aaGghAtbdSZPuN+KZYxN Ikqvbp+I5MmrvMIKgCgbEVtAs8aP7i6s+vkW/nPKBVJDjQx7NKlVHGf//qU1HUW6Lv3e iRy39wIPmJ27SveT+dwfnhyfWRbSZaqfTPHlEOS1FEy5OFF7XCaZdoqwsVZw8k5tryfw 7ZnnB7ut2usXyhMu1KHv+9Mya93bzQUjVzrl4X5EhfQguHfKXON/cBRfrrhaf48CkyCY Pvvn75OcauvvxHBNrt+nJZQ/kWEx2RYcP1qp+D1HpA0iXEiScjmAcstNmKHWZf28bbxE 5SBg== X-Gm-Message-State: AGi0Pub/8Lpo74eP5Pp24dEhSYVhI3RIQQ/y9/viJTbwMrNSfBN2tbse 2KS63t/12fLDI1vl049tZeoDaA== X-Google-Smtp-Source: APiQypKzGSpGqRPLbKSkR/5lkG4Psd841sVDSgnajOiXFOttTAPmutKuSzmF7o5bX08dO9kG0/zU/Q== X-Received: by 2002:aed:2ba2:: with SMTP id e31mr7913187qtd.286.1586364275498; Wed, 08 Apr 2020 09:44:35 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h138sm19464821qke.86.2020.04.08.09.44.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Apr 2020 09:44:34 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 4205A800897; Wed, 8 Apr 2020 11:44:33 -0500 (CDT) Date: Wed, 8 Apr 2020 11:44:33 -0500 From: Justin Pryzby To: Alvaro Herrera Cc: pgsql-hackers@lists.postgresql.org Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables Message-ID: <20200408164433.GE2228@telsasoft.com> References: <20200408152412.GZ2228@telsasoft.com> <20200408160239.GA13987@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200408160239.GA13987@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Apr 08, 2020 at 12:02:39PM -0400, Alvaro Herrera wrote: > On 2020-Apr-08, Justin Pryzby wrote: > > > This seems to be a bug in master, v12, and (probably) v11, where "FOR EACH FOR" > > was first allowed on partition tables (86f575948). > > > > I thought this would work like partitioned indexes (8b08f7d48), where detaching > > a partition makes its index non-inherited, and attaching a partition marks a > > pre-existing, matching partition as inherited rather than creating a new one. > > 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. At telsasoft, we don't care (we uninherit tables before ALTERing parents to avoid disruptive locking and to avoid worst-case disk use). (1) is consistent with the behavior for indexes, which is a slight advantage for users' ability to understand and keep track of the behavior. But adding triggers is pretty different so I'm not sure it's a totally compelling parallel. -- Justin