Re: FOR EACH ROW triggers on partitioned tables
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>, Simon Riggs <simon@2ndquadrant.com>
Date: 2018-01-23T22:10:27Z
Lists: pgsql-hackers
Attachments
Peter Eisentraut wrote: > On 12/29/17 17:53, Alvaro Herrera wrote: > > This patch enables FOR EACH ROW triggers on partitioned tables. > > > > As presented, this patch is sufficient to discuss the semantics that we > > want for triggers on partitioned tables, which is the most pressing > > question here ISTM. > > This seems pretty straightforward. What semantics questions do you have? The main question is this: when running the trigger function, it is going to look as it is running in the context of the partition, not in the context of the parent partitioned table (TG_RELNAME etc). That seems mildly ugly: some users may be expecting that the partitioning stuff is invisible to the rest of the system, so if you have triggers on a regular table and later on decide to partition that table, the behavior of triggers will change, which is maybe unexpected. Maybe this is not really a problem, but I'm not sure and would like further opinions. Anyway, the attached v2 has the following changes 1. ALTER TABLE ATTACH PARTITION and CREATE TABLE PARTITION OF now clone any triggers from the main table, as if the trigger had been created with the partitions in place. 2. dependencies work correctly: dropping the trigger on a partition is disallowed; dropping the table removes the trigger. This is pretty much the same behavior we have for indexes in partitions; I've reused the new dependency type. While existing pg_dump tests pass, I have not verified that it does anything remotely sensible. > Also, does ALTER TABLE ... ENABLE/DISABLE TRIGGER do the right things on > partitioned tables? Haven't done this yet, either. I like Simon's suggestion of outright disallowing this. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Allow FOR EACH ROW triggers on partitioned tables
- 86f575948c77 11.0 landed
-
Fix CommandCounterIncrement in partition-related DDL
- 4dba331cb3dc 11.0 landed
-
Mention trigger name in trigger test
- cef60043dd27 11.0 landed
-
Fix transition tables for partition/inheritance.
- 501ed02cf6f4 10.0 cited