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 1kVHVg-0007Td-50 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 17:02:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVHVf-0003Ws-3J for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 17:02:47 +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 1kVHVe-0003PM-Sf for pgsql-hackers@lists.postgresql.org; Wed, 21 Oct 2020 17:02:46 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVHVc-0008SY-N9 for pgsql-hackers@postgresql.org; Wed, 21 Oct 2020 17:02:46 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 02848D4C; Wed, 21 Oct 2020 13:02:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 21 Oct 2020 13:02:42 -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=ekdSUNs232e9+470t 99m32X7iuWWP2wGLmarDINGvaA=; b=A3XGI+GoNiiTbvo8cLdvD6w2GLFm563eu AZGT8PrvvMchxXPl73ftRBrPs2pYcJu3dOrV46EQTDlWfQJRWCWWra889yFseoJ+ uhVejmZIWl+v0QVVKtyfUwjKAzWdv0FxZijrm1YCchv4vp6Rb9f27kC+xp5s6E58 Xmi1FqWe73zJKR70DcUjq2HetzqyyHC4BvSBqq68GE3z3GAUKQlRuDfoZs4etjZj iBqsG1Q0Uhqwljrh1po76RIznkDuHGydySbJsimTtjt+3hwh2hYKMjYHN1w+dby1 kgaSGsCFckJ90DpDLW8jL1xuyWQfuJbs+HU7brINnbRoih0g5eTrA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjeehgddutdelucetufdoteggodetrfdotf 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 780FF306467E; Wed, 21 Oct 2020 13:02:40 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 97B272A150F; Wed, 21 Oct 2020 14:02:37 -0300 (-03) Date: Wed, 21 Oct 2020 14:02:37 -0300 From: Alvaro Herrera To: Justin Pryzby Cc: Tom Lane , pgsql-hackers@postgresql.org, Amit Langote Subject: Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers Message-ID: <20201021170237.GA17401@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201021115453.GL9241@telsasoft.com> 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-21, Justin Pryzby wrote: > I came up with this, which probably needs more than a little finesse. Hmm, there are two important changes needed on this: 1) it must not emit CREATE lines for the child triggers; only the ALTER TABLE ONLY lines to set disable state on the partition are needed. 2) tgparentid does not exist prior to pg13, so you need some additional trick to cover that case. Also, I think the multipartition case is broken: if grandparent has trigger enabled, parent has trigger disabled and child trigger set to always, is that dumped correctly? I think the right way to do this is change only the partitions that differ from the topmost partitioned table -- not their immediate parents; and use ONLY to ensure they don't affect downstream children. Change 1 also means that the test with the "this shouldn't ever get emitted" comment remains unchanged. I'm not sure how to tackle change 2. You need to search pg_depend for entries with classid=pg_trigger and refclass=pg_trigger ... (commit 1fa846f1c9af might give some clue)