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 1lQsTj-0003DJ-VJ for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Mar 2021 14:02:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lQsTi-00062n-HI for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Mar 2021 14:02:50 +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 1lQsTi-00062f-8B for pgsql-hackers@lists.postgresql.org; Mon, 29 Mar 2021 14:02:50 +0000 Received: from mxout3.routing.net ([2a03:2900:1:a::8]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQsTa-0001fa-FZ for pgsql-hackers@lists.postgresql.org; Mon, 29 Mar 2021 14:02:49 +0000 Received: from mxbox4.masterlogin.de (unknown [192.168.10.79]) by mxout3.routing.net (Postfix) with ESMTP id C7B686048A; Mon, 29 Mar 2021 14:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1617026557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tTCKKt6NSgwxh3jUzjSnHUrXS82EYeArC0UHI/13+0Q=; b=DJQmtYC4/ykJ891ZQIhWNEPTz69SCxyKppuYTi26qL7x0OYjT4uqYn07gmwrspAXA0BL8Y Y3i4M03s3ImFOliLLzDoMWSy+P7t0rdPno+k/gFrHoiuKzqhzXtm6LoGFxigWjCi2FVQtb SEoyB1psskzDU73fqeVvhvpbwkIkAzI= Received: from remote.index.de (business-90-187-114-221.pool2.vodafone-ip.de [90.187.114.221]) by mxbox4.masterlogin.de (Postfix) with ESMTPSA id 2A18E8039A; Mon, 29 Mar 2021 14:02:37 +0000 (UTC) Received: from acedia.index-gruppe.local (192.168.3.121) by acedia.index-gruppe.local (192.168.3.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 29 Mar 2021 16:02:36 +0200 Received: from acedia.index-gruppe.local ([fe80::ecd1:5d0a:a834:dd56]) by acedia.index-gruppe.local ([fe80::ecd1:5d0a:a834:dd56%5]) with mapi id 15.01.2176.009; Mon, 29 Mar 2021 16:02:36 +0200 From: Arne Roland To: Alvaro Herrera CC: David Steele , Pg Hackers Subject: Re: Rename of triggers for partitioned tables Thread-Topic: Rename of triggers for partitioned tables Thread-Index: AQHWxEk1+rora/wutkWbcRQhC03q0KnbGQ2sgAAECBOATmSTgIBhAeKAgBDG6bOAACCNT4AAKOcAgAAj1kM= Date: Mon, 29 Mar 2021 14:02:35 +0000 Message-ID: <6e04673973bf4922bf30fe22d5b0f067@index.de> References: ,<20210329132536.GA9798@alvherre.pgsql> In-Reply-To: <20210329132536.GA9798@alvherre.pgsql> Accept-Language: en-US, de-DE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.255.1.33] Content-Type: multipart/alternative; boundary="_000_6e04673973bf4922bf30fe22d5b0f067indexde_" MIME-Version: 1.0 X-Mail-ID: 539571ad-f02b-40c0-8b32-2630a2d62751 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_6e04673973bf4922bf30fe22d5b0f067indexde_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thank you for the quick reply! Alvaro Herrera wrote: > 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. The basic concept here was to fail in any circumstance where the trigger on= the child isn't as expected. May it be the name or the parent for that matter. > What we really want to have happen, is to search the list of triggers in > the child, see which one has tgparentid=3D, and >rename that one -- regardless of what name it had originally. So if we have a trigger named t42 can be renamed to my_trigger by ALTER TRIGGER sometrigg ON my_table RENAME TO my_trigger;? Equivalently there is the question whether we just want to silently ignore if the corresponding child doesn't have a corresponding trigger. I am not convinced this is really what we want, but I could agree to raise = a notice in these cases. > 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. The syntax does work via + if (stmt->relation->inh && has_subclass(relid)) in renametrigHelper (src/backend/commands/trigger.c line 1543). I am not sure which sort of addition in ATExecCmd you expected. Maybe I can make this more obvious one way or the other. You input would be= appreciated. > I think it would be good to have a new test for pg_dump that verifies > that this stuff is doing the right thing. Good idea, I will add a case involving pg_dump. Regards Arne --_000_6e04673973bf4922bf30fe22d5b0f067indexde_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thank you for the quick reply!

Alvaro Herrera wrote:
> I think this is not what we want to do.  What you're doing here a= s 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.<= br>
The basic concept here was to fail in any circumstance where the trigger on= the child isn't as expected.
May it be the name or the parent for that matter.

> What we really want to have happen, is to search the list of triggers = in
> the child, see which one has tgparentid=3D<the one we're renaming&g= t;, and
>rename that one -- regardless of what name it had originally.

So if we have a trigger named t42 can be renamed to my_trigger by
ALTER TRIGGER sometrigg ON my_table RENAME TO my_trigger;?
Equivalently there is the question whether we just want to silently ignore<= br> if the corresponding child doesn't have a corresponding trigger.
I am not convinced this is really what we want, but I could agree to raise = a notice in these cases.

> Also, you added grammar support for the ONLY keyword in the command, b= ut
> 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 tabl= es; only if
> I remove the ONLY from the command it recurses.

The syntax does work via
+    if (stmt->relation->inh && has_subcla= ss(relid))
in renametrigHelper (src/backend/commands/trigger.c line 1543).
I am not sure which sort of addition in ATExecCmd you expected.
Maybe I can make this more obvious one way or the other. You input would be= appreciated.

> I think it would be good to have a new test for pg_dump that verifies<= br> > that this stuff is doing the right thing.

Good idea, I will add a case involving pg_dump.

Regards
Arne


--_000_6e04673973bf4922bf30fe22d5b0f067indexde_--