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 1kUww7-0000aA-96 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Oct 2020 19:04:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kUww6-0000iE-68 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Oct 2020 19:04:42 +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 1kUww5-0000i7-1N for pgsql-hackers@lists.postgresql.org; Tue, 20 Oct 2020 19:04:41 +0000 Received: from [64.147.123.25] (helo=wout2-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUww1-0004QW-On for pgsql-hackers@postgresql.org; Tue, 20 Oct 2020 19:04:40 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 0176A9E7; Tue, 20 Oct 2020 15:04:24 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 20 Oct 2020 15:04:25 -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=Hdj5k+tSWAa/Q8xOZ Ym0yMKwlovJuICctg/59EB0Nts=; b=om7v4HkM2YAof2CIPePphV0wTYpWERo8d qDklyg9U4g2umSBPVtDs67jtmbzD/73mqBaJ2Gmw7ia/X8g0syUbvudvLVj/QkDk MTuBRzCW5KI+0gOqFUT5xnL5kN5nnTw8t6Q3CJIQP0grE6absWuQmKVo3QUTnUGR ktgOJhy2RZ6CTWHgN4dwKnXS5MpytlZckU0rkKpA5y+m8o5bo/Um6+By20etoSFi AZLILGgqJVPE3byRZFWIssXmABTy5bVLLQPqnehhEyaTg9CyIbwjmL3y5c9Az87r 4eOEEpU1xbTQF9VxU/lAJmwVr1InuUNwC9RKYDj2BBrnR+/0m0lpA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjeefgddufedtucetufdoteggodetrfdotf 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 9F23D328005D; Tue, 20 Oct 2020 15:04:23 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id EB93F2A1AC1; Tue, 20 Oct 2020 16:04:20 -0300 (-03) Date: Tue, 20 Oct 2020 16:04:20 -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: <20201020190420.GA18579@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200930223450.GA14848@telsasoft.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.25 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Sep-30, Justin Pryzby wrote: > CREATE TABLE t(i int) PARTITION BY RANGE(i); > CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (1) TO (10); > CREATE OR REPLACE FUNCTION tgf() RETURNS trigger LANGUAGE plpgsql AS $$ begin raise exception 'except'; end $$; > CREATE TRIGGER tg AFTER INSERT ON t FOR EACH ROW EXECUTE FUNCTION tgf(); > ALTER TABLE t1 DISABLE TRIGGER tg; > INSERT INTO t VALUES(1); -- inserts when trigger is disabled: good > ALTER TABLE t DISABLE TRIGGER tg; > CREATE TABLE t2 PARTITION OF t FOR VALUES FROM (10) TO (20); > > postgres=# SELECT tgrelid::regclass, tgenabled FROM pg_trigger WHERE tgrelid::regclass::text IN ('t1','t2'); > tgrelid | tgenabled > ---------+----------- > t1 | D > t2 | O > (2 rows) > > I consider this a bug,but CreateTrigStmt doesn't have any "enabled" member > (since it's impossible to CREATE TRIGGER .. DISABLED), so I'm not sure where > the fix should be. 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. This is a judgement call, and mine says to backpatch, but I've been wrong on that.