Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, pgsql-hackers@postgresql.org, Amit Langote <amitlangote09@gmail.com>
Date: 2021-07-16T19:33:19Z
Lists: pgsql-hackers
On Fri, Jul 16, 2021 at 02:15:26PM -0400, Tom Lane wrote:
> Justin Pryzby <pryzby@telsasoft.com> writes:
> > I think there's still an issue that comments on child triggers aren't
> > preserved, right ?
>
> Do we care? That seems like messing with a system-internal object.
> In general we won't promise to preserve the results of doing so.
It's fine if that's the conclusion.
Back in October, that seemed like one too many things misbehaving, which led me
to walk away from the patch and re-orient.
I was going re-check the behavior, but instead hit another bug:
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();
\d p1
2021-07-16 14:30:12.371 CDT client backend[6252] psql ERROR: more than one row returned by a subquery used as an expression
2021-07-16 14:30:12.371 CDT client backend[6252] psql STATEMENT: SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid, true), t.tgenabled, t.tgisinternal, (SELECT (NULLIF(a.relid, t.tgrelid))::pg_catalog.regclass FROM pg_catalog.pg_trigger AS u, pg_catalog.pg_partition_ancestors(t.tgrelid) AS a WHERE u.tgname = t.tgname AND u.tgrelid = a.relid AND u.tgparentid = 0) AS parent
FROM pg_catalog.pg_trigger t
WHERE t.tgrelid = '37718' AND (NOT t.tgisinternal OR (t.tgisinternal AND t.tgenabled = 'D')
OR EXISTS (SELECT 1 FROM pg_catalog.pg_depend WHERE objid = t.oid
AND refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass))
ORDER BY 1;
ERROR: more than one row returned by a subquery used as an expression
The tgenabled issue was a contributing factor which led us to stop using
inherited triggers, so I'm not very motivated to dig into it.
--
Justin
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