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: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@postgresql.org, Amit Langote <amitlangote09@gmail.com>
Date: 2021-07-16T22:01:12Z
Lists: pgsql-hackers
On 2021-Jul-16, Justin Pryzby wrote:

> CREATE TABLE p(i int) PARTITION BY RANGE(i);
> CREATE TABLE p1 PARTITION OF p FOR VALUES FROM (1)TO(2);
> CREATE FUNCTION foo() returns trigger LANGUAGE plpgsql AS $$begin end$$;
> CREATE TRIGGER x AFTER DELETE ON p1 EXECUTE FUNCTION foo();
> CREATE TRIGGER x AFTER DELETE ON p EXECUTE FUNCTION foo();

Hmm, interesting -- those statement triggers are not cloned, so what is
going on here is just that the psql query to show them is tripping on
its shoelaces ... I'll try to find a fix.

I *think* the problem is that the query matches triggers by name and
parent/child relationship; we're missing to ignore triggers by tgtype.
It's not great design that tgtype is a bitmask of unrelated flags ...

-- 
Álvaro Herrera              Valdivia, Chile  —  https://www.EnterpriseDB.com/



Commits

  1. Fix pg_dump for disabled triggers on partitioned tables

  2. Preserve firing-on state when cloning row triggers to partitions

  3. Fix ALTER TABLE .. ENABLE/DISABLE TRIGGER recursion

  4. psql \d: Display table where trigger is defined, if inherited

  5. Fix cloning of row triggers to sub-partitions

  6. Make pg_dump emit ATTACH PARTITION instead of PARTITION OF (reprise)