pgsql: Allow FOR EACH ROW triggers on partitioned tables

Started by Alvaro Herreraover 8 years ago5 messagescomitters
Jump to latest
#1Alvaro Herrera
alvherre@2ndquadrant.com

Allow FOR EACH ROW triggers on partitioned tables

Previously, FOR EACH ROW triggers were not allowed in partitioned
tables. Now we allow AFTER triggers on them, and on trigger creation we
cascade to create an identical trigger in each partition. We also clone
the triggers to each partition that is created or attached later.

This means that deferred unique keys are allowed on partitioned tables,
too.

Author: Álvaro Herrera
Reviewed-by: Peter Eisentraut, Simon Riggs, Amit Langote, Robert Haas,
Thomas Munro
Discussion: /messages/by-id/20171229225319.ajltgss2ojkfd3kp@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/86f575948c773b0ec5b0f27066e37dd93a7f0a96

Modified Files
--------------
doc/src/sgml/catalogs.sgml | 8 +
doc/src/sgml/ref/create_trigger.sgml | 7 +
src/backend/catalog/heap.c | 1 +
src/backend/catalog/index.c | 4 +-
src/backend/catalog/pg_constraint.c | 3 +
src/backend/commands/tablecmds.c | 150 ++++++++++++-
src/backend/commands/trigger.c | 313 +++++++++++++++++++++++---
src/backend/commands/typecmds.c | 1 +
src/backend/tcop/utility.c | 3 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/indexing.h | 2 +
src/include/catalog/pg_constraint.h | 39 ++--
src/include/catalog/pg_constraint_fn.h | 1 +
src/include/commands/trigger.h | 5 +-
src/test/regress/expected/oidjoins.out | 8 +
src/test/regress/expected/triggers.out | 344 +++++++++++++++++++++++++++--
src/test/regress/input/constraints.source | 16 ++
src/test/regress/output/constraints.source | 26 +++
src/test/regress/sql/oidjoins.sql | 4 +
src/test/regress/sql/triggers.sql | 234 +++++++++++++++++++-
20 files changed, 1078 insertions(+), 93 deletions(-)

#2Andres Freund
andres@anarazel.de
In reply to: Alvaro Herrera (#1)
Re: pgsql: Allow FOR EACH ROW triggers on partitioned tables

Hi,

On 2018-03-23 13:48:53 +0000, Alvaro Herrera wrote:

Allow FOR EACH ROW triggers on partitioned tables

Previously, FOR EACH ROW triggers were not allowed in partitioned
tables. Now we allow AFTER triggers on them, and on trigger creation we
cascade to create an identical trigger in each partition. We also clone
the triggers to each partition that is created or attached later.

This means that deferred unique keys are allowed on partitioned tables,
too.

Author: �lvaro Herrera
Reviewed-by: Peter Eisentraut, Simon Riggs, Amit Langote, Robert Haas,
Thomas Munro
Discussion: /messages/by-id/20171229225319.ajltgss2ojkfd3kp@alvherre.pgsql

The inherit.sql here looks like it's racing against the concurrentlys
scheduled triggers.sql according to my new desmoxytes animal:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=desmoxytes&dt=2018-03-25%2004%3A48%3A01

Greetings,

Andres Freund

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Andres Freund (#2)
Re: pgsql: Allow FOR EACH ROW triggers on partitioned tables

Andres Freund wrote:

On 2018-03-23 13:48:53 +0000, Alvaro Herrera wrote:

Allow FOR EACH ROW triggers on partitioned tables

The inherit.sql here looks like it's racing against the concurrentlys
scheduled triggers.sql according to my new desmoxytes animal:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=desmoxytes&dt=2018-03-25%2004%3A48%3A01

You're right -- fixed.

Thanks

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#3)
Re: pgsql: Allow FOR EACH ROW triggers on partitioned tables

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:

Andres Freund wrote:

The inherit.sql here looks like it's racing against the concurrentlys
scheduled triggers.sql according to my new desmoxytes animal:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=desmoxytes&amp;dt=2018-03-25%2004%3A48%3A01

You're right -- fixed.

I don't see any push for this?

regards, tom lane

#5Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#4)
Re: pgsql: Allow FOR EACH ROW triggers on partitioned tables

Tom Lane wrote:

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:

Andres Freund wrote:

The inherit.sql here looks like it's racing against the concurrentlys
scheduled triggers.sql according to my new desmoxytes animal:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=desmoxytes&amp;dt=2018-03-25%2004%3A48%3A01

You're right -- fixed.

I don't see any push for this?

Oops. It went out later together with another commit.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services