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 1kUy7C-0004vu-CH for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Oct 2020 20:20:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kUy7A-0005Sb-Uu for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Oct 2020 20:20:12 +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 1kUy79-0005SU-Ui for pgsql-hackers@lists.postgresql.org; Tue, 20 Oct 2020 20:20:12 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUy77-00059T-3D for pgsql-hackers@postgresql.org; Tue, 20 Oct 2020 20:20:11 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 9E29C99D; Tue, 20 Oct 2020 16:20:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 20 Oct 2020 16:20:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Sd1shuXynPOHbj10i oD656cin8g6yLU79juhgRGdnjo=; b=jUpvs1oOmf43GShA7IEQ1n6QO+mH+9t0Y /EP41FLi2KrdyWz3KQRRa74fqlgRCvQ3L942igt52C5ByQjXnbUk/LpkqJl7K1Yp Jt//Omz3nf+7WC2VOyVEngI4uXfyT9U5RfdbAIdChGIWeVtz5kuVYUKXjkwOgzml Qsz2mf/HcxYli+M3redRAhrUCH3IqZu9HZBR+wSxhmwVLTTpH2dWg82q+d1lxCNk 7NZH6zdw3MFQhMz9yuPEEtwQhev4ByH18a/pjQE3kxCC33VHXKIBuLMzj4HDsVIP 4sOUSN5wqa2LHWj3wSIugK/cmbGMusbzPp58zqN8nB3XZgWDbMItw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjeefgddugeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggujggfsehttdertddtredvnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpeevgfelveegueejgefhgeetgefhgeehieefheehleetteei udeiiefhgffgheffteenucfkphepudeltddrleehrdduledrudegkeenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 9F2CD328005D; Tue, 20 Oct 2020 16:20:04 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 167872A104B; Tue, 20 Oct 2020 17:20:01 -0300 (-03) Date: Tue, 20 Oct 2020 17:20:01 -0300 From: Alvaro Herrera To: Justin Pryzby Cc: pgsql-hackers@postgresql.org, Amit Langote Subject: Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers Message-ID: <20201020202001.GA6423@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201016235925.GA29829@alvherre.pgsql> 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-Oct-16, Alvaro Herrera wrote: > On 2020-Oct-16, Alvaro Herrera wrote: > > > I also just noticed that ALTER TABLE ONLY recurses to children, which it > > should not. > > Apparently I wrote (bogus) bespoke code to handle recursion in > EnableDisableTrigger instead of using ATSimpleRecursion. This patch > seems to fix this problem. ... but it affects legacy inheritance, which would be undesirable because it has never recursed for that case. So it needs to have a relkind check here and only recurse if it's a new-style partitioned table: > diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c > index 511f015a86..c8d6f78da2 100644 > --- a/src/backend/commands/tablecmds.c > +++ b/src/backend/commands/tablecmds.c > @@ -4321,6 +4321,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, > case AT_DisableTrigAll: > case AT_DisableTrigUser: > ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE); > + ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode, context); > pass = AT_PASS_MISC; > break; > case AT_EnableRule: /* ENABLE/DISABLE RULE variants */ I'll add tests for both cases and push to all branches 11+.