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 1lQrtz-0001n2-RE for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Mar 2021 13:25:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lQrty-0007lR-NV for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Mar 2021 13:25:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQrty-0007lK-H4 for pgsql-hackers@lists.postgresql.org; Mon, 29 Mar 2021 13:25:54 +0000 Received: from [64.147.123.25] (helo=wout2-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQrtw-0001ON-Fd for pgsql-hackers@lists.postgresql.org; Mon, 29 Mar 2021 13:25:53 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id D5515164B; Mon, 29 Mar 2021 09:25:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 29 Mar 2021 09:25:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm2; bh=sOUOIb9c/uaqaiOHRkhSwTWbOQrZJfZV2L50M0zzBKc=; b=gkfHsfv6 lLI9bVHhK6AbfnMICw09jYv4otOen+9IBYH6P1ZdZ2pNlEWGQCgkdUl63w/AEf+D okJjoH5iCXG0zJepZ5mZ4UAJr9kvfXuVWkjVLqtxN1bfKi/y0GPZqBhddUktgdii o22fjVSalp1w1D1OKg9WxyxBBcXqJH9AC5ttGZhslbfwkBKT5A2xd1EeYtw48RAj WzV0iqnCWY/vw4VwTkHcS9SXU46i2WLIg3UuarX2NzdpccgkUiYV3kuNSXFvNTWP GWefLDOg9PWEgTmFP0Mvz1DB1hQoKm+XU9CGN/Ii96ajrbB1xg6cmGsvyTF6ZZGC JodvW94Lj0uDRA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehkedgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjfgesthekredttderudenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepueffhfejieeuueffgedvudekgeeltdeviedvieeufeei ieevgfetheeufeethedvnecukfhppeduledtrdelhedrudelrdelheenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id AD396108006D; Mon, 29 Mar 2021 09:25:39 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id B85362A0D1C; Mon, 29 Mar 2021 10:25:36 -0300 (-03) Date: Mon, 29 Mar 2021 10:25:36 -0300 From: Alvaro Herrera To: Arne Roland Cc: David Steele , Pg Hackers Subject: Re: Rename of triggers for partitioned tables Message-ID: <20210329132536.GA9798@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: Archived-At: Precedence: bulk On 2021-Mar-29, Arne Roland wrote: > @@ -1475,7 +1467,12 @@ renametrig(RenameStmt *stmt) > tuple = heap_copytuple(tuple); /* need a modifiable copy */ > trigform = (Form_pg_trigger) GETSTRUCT(tuple); > tgoid = trigform->oid; > - > + if (tgparent != 0 && tgparent != trigform->tgparentid) { > + ereport(ERROR, > + (errcode(ERRCODE_UNDEFINED_OBJECT), > + errmsg("trigger \"%s\" for table \"%s\" is not dependent on the trigger on \"%s\"", > + stmt->subname, RelationGetRelationName(targetrel), stmt->relation->relname))); > + } I think this is not what we want to do. What you're doing here as I understand is traversing the inheritance hierarchy down using the trigger name, and then fail if the trigger with that name has a different parent or if no trigger with that name exists in the child. What we really want to have happen, is to search the list of triggers in the child, see which one has tgparentid=, and rename that one -- regardless of what name it had originally. Also, you added grammar support for the ONLY keyword in the command, but it doesn't do anything different when given that flag, does it? At least, I see no change or addition to recursion behavior in ATExecCmd. I would expect that if I say "ALTER TRIGGER .. ON ONLY tab" then it renames the trigger on table "tab" but not on its child tables; only if I remove the ONLY from the command it recurses. I think it would be good to have a new test for pg_dump that verifies that this stuff is doing the right thing. -- Álvaro Herrera 39°49'30"S 73°17'W "Siempre hay que alimentar a los dioses, aunque la tierra esté seca" (Orual)