From afccd76f1ccef73a341e9b0c6efb29a429f35aa4 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 21 Apr 2020 13:57:00 -0400 Subject: Fix detaching partitions with cloned row triggers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a partition is detached, any triggers that had been cloned from its parent were not properly disentangled from its parent triggers. This resulted in triggers that could not be dropped because they depended on the trigger in the trigger in the no-longer-parent table: ALTER TABLE t DETACH PARTITION t1; DROP TRIGGER trig ON t1; ERROR: cannot drop trigger trig on table t1 because trigger trig on table t requires it HINT: You can drop trigger trig on table t instead. Moreover the table can no longer be re-attached to its parent, because the trigger name is already taken: ALTER TABLE t ATTACH PARTITION t1 FOR VALUES FROM (1)TO(2); ERROR: trigger "trig" for relation "t1" already exists The former is a bug introduced in commit 86f575948c77. (The latter is not necessarily a bug, but it makes the bug more uncomfortable.) To avoid the complexity that would be needed to tell whether the trigger has a local definition that has to be merged with the one coming from the parent table, establish the behavior that the trigger is removed when the table is detached. Backpatch to pg11. Author: Justin Pryzby Reviewed-by: Amit Langote Reviewed-by: Álvaro Herrera Discussion: https://www.postgresql.org/message-id/flat/20200408152412.GZ2228@telsasoft.com --- doc/src/sgml/ref/create_trigger.sgml | 1 + 1 file changed, 1 insertion(+) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index bde3a63f90f..303881fcfbb 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -526,6 +526,7 @@ UPDATE OF column_name1 [, column_name2INSTEAD OF. -- cgit v1.2.3