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 1kV2Pe-0003mb-DE for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 00:55:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kV2P7-0007e1-KU for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Oct 2020 00:55:01 +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 1kV2P7-0007ar-Dl for pgsql-hackers@lists.postgresql.org; Wed, 21 Oct 2020 00:55:01 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kV2P5-0007Nn-15 for pgsql-hackers@postgresql.org; Wed, 21 Oct 2020 00:55:00 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 801D95C0112; Tue, 20 Oct 2020 20:54:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 20 Oct 2020 20:54:57 -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=I7kQuVfwwsDy0puIF tNpxS6Y6wMn86vkaiZl9uHtX4Y=; b=ID1nT9cYPSN5Wxzp4cRIaWWW+XiT6HJej K67Tq/tM+7gszI9aZrWfonCXwJe3YJXDvKwjJ/bCBCXbxiEvIyLCLuk0PuU1Qewo APuCORAl/yG8+L9XpNogjss84OzweRC+AYGTta76bkyGEHmgdYzfBw02QStuyYSr tOV3suwUmmpTOeFSLfOZLaxWmlvih1pKIA5FYcXWHa2MoVdyd4wrOiN0J/2tcKIh 9vq7jvJLwp4J6V6NJ+3kkFfq6xxvzDf8SqEcbb3AJlopnWA4/AeQx1XYeJtzdxuJ fZIP7szWycx1IRm4P2FejvxylaH103z0xOZS08VZwmki9OB5pnxxg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjeeggdefkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtuggjfgesthdtredttdervdenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvefgleevgeeujeeghfegteeghfegheeifeehheelteetiedu ieeihffggfehffetnecukfhppeduledtrdelhedrudelrddugeeknecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhv hhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id C264C3064680; Tue, 20 Oct 2020 20:54:56 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 8923B2A104B; Tue, 20 Oct 2020 21:54:53 -0300 (-03) Date: Tue, 20 Oct 2020 21:54:53 -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: <20201021005453.GA18765@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201020220116.GH9241@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-20, Justin Pryzby wrote: > On Tue, Oct 20, 2020 at 03:56:30PM -0400, Tom Lane wrote: > > Alvaro Herrera writes: > > > Hmm, next question: should we backpatch a fix for this? (This applies > > > all the way back to 11.) If we do, then we would change behavior of > > > partition creation. It's hard to see that the current behavior is > > > desirable ... and I think anybody who would have come across this, would > > > wish it behaved the other way. But still -- it would definitely be a > > > behavior change. > > > > The behavior change seems like it'd be an improvement in a vacuum, > > but I wonder how it would interact with catalog contents left behind > > by the old misbehavior. Also, would we expect pg_dump to try to do > > anything to clean up the mess? If so, allowing a back branch to have > > had more than one behavior would complicate that greatly. > > I don't think there's a problem with catalog content ? > I think it's fine if there's an enabled child trigger inheriting from a > disabled parent? This changes the initial tgenabled for new partitions. I don't think we'd need to do anything special here ... particularly considering the discovery that pg_dump does not preserve the disable status of trigger on partitions: > However...it looks like pg_dump should ALTER the child trigger state if it > differ from its parent. Or maybe it needs to CREATE child triggers with the > proper state before attaching the child table ? I guess *something* needs to be done, but I'm not clear on what it is. Creating the trigger on partition beforehand does not work: an error is raised on attach that the trigger already exists. The only way I see to do this, is to have pg_dump extract tgenabled for all child triggers that doesn't have the same tgenabled as the parent, and append ALTER .. DISABLE commands for each one to the parent table trigger creation command. So pg_dump.c's getTriggers would have to obtain the list of altered child triggers, and then dumpTrigger would have to append the ALTER TABLE ONLY .. ENABLE/DISABLE command for that particular trigger.