Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Amit Langote <amitlangote09(at)gmail(dot)com>
Subject: Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers
Date: 2020-10-20 20:20:01
Message-ID: 20201020202001.GA6423@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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+.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-10-20 20:36:25 Re: Hash support for row types
Previous Message Tom Lane 2020-10-20 19:56:30 Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers