Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-hackers@postgresql.org, Amit Langote <amitlangote09@gmail.com>
Date: 2020-10-20T20:20:01Z
Lists: pgsql-hackers
On 2020-Oct-16, Alvaro Herrera wrote: > On 2020-Oct-16, Alvaro Herrera wrote: > > > I also just noticed that ALTER TABLE ONLY recurses to children, which it > > should not. > > Apparently I wrote (bogus) bespoke code to handle recursion in > EnableDisableTrigger instead of using ATSimpleRecursion. This patch > seems to fix this problem. ... but it affects legacy inheritance, which would be undesirable because it has never recursed for that case. So it needs to have a relkind check here and only recurse if it's a new-style partitioned table: > diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c > index 511f015a86..c8d6f78da2 100644 > --- a/src/backend/commands/tablecmds.c > +++ b/src/backend/commands/tablecmds.c > @@ -4321,6 +4321,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, > case AT_DisableTrigAll: > case AT_DisableTrigUser: > ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE); > + ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode, context); > pass = AT_PASS_MISC; > break; > case AT_EnableRule: /* ENABLE/DISABLE RULE variants */ I'll add tests for both cases and push to all branches 11+.
Commits
-
Fix pg_dump for disabled triggers on partitioned tables
- f0e21f2f6167 15.0 landed
- ccfc3cbb341a 11.13 landed
- cc340af33453 13.4 landed
- 5992c94dc7e4 12.8 landed
- 3c5b7c628621 14.0 landed
-
Preserve firing-on state when cloning row triggers to partitions
- fed35bd4a650 11.13 landed
- eef92de11e50 14.0 landed
- df80fa2ee504 15.0 landed
- c31516ae5b43 13.4 landed
- 7584ec1f6098 12.8 landed
-
Fix ALTER TABLE .. ENABLE/DISABLE TRIGGER recursion
- bbb927b4db9b 14.0 landed
- a795f6782fa8 11.10 landed
- 5f6463a20af1 13.1 landed
- 0e6b6f8c7192 12.5 landed
-
psql \d: Display table where trigger is defined, if inherited
- c33869cc3bfc 13.0 cited
-
Fix cloning of row triggers to sub-partitions
- 1fa846f1c9af 13.0 cited
-
Make pg_dump emit ATTACH PARTITION instead of PARTITION OF (reprise)
- 33a53130a894 12.0 cited