truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
ALTER TRIGGER test_trigger_fn_trg1 ON test_trigger_table RENAME TO test_trigger_fn_trg;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
\d+ test_trigger_table
Table "public.test_trigger_table"
Column | Type | Modifiers | Storage | Stats target | Description
test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
-DROP TRIGGER test_trigger_fn_trg2 ON test_trigger_table;
+ALTER TABLE test_trigger_table DISABLE TRIGGER test_trigger_fn_trg;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
\d+ test_trigger_table
Table "public.test_trigger_table"
Column | Type | Modifiers | Storage | Stats target | Description
f1 | integer | | plain | |
f2 | text | | extended | |
Triggers:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Disabled user triggers:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+
+\c regression
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Disabled user triggers:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+
+ALTER TABLE test_trigger_table DISABLE TRIGGER ALL;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Disabled user triggers:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+
+\c postgres
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Disabled user triggers:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+
+ALTER TABLE test_trigger_table ENABLE TRIGGER test_trigger_fn_trg2;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+Disabled user triggers:
test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
\c regression
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+Disabled user triggers:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+
+ALTER TABLE test_trigger_table ENABLE TRIGGER USER;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
\d+ test_trigger_table
Table "public.test_trigger_table"
Column | Type | Modifiers | Storage | Stats target | Description
f2 | text | | extended | |
Triggers:
test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+\c postgres
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+
+ALTER TABLE test_trigger_table ENABLE ALWAYS TRIGGER test_trigger_fn_trg;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Triggers firing always:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+
+\c regression
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Triggers firing always:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+
+ALTER TABLE test_trigger_table ENABLE REPLICA TRIGGER test_trigger_fn_trg2;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Triggers firing always:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+Triggers firing on replica only:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+
+\c postgres
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Triggers firing always:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+Triggers firing on replica only:
+ test_trigger_fn_trg2 AFTER UPDATE OF f1 ON test_trigger_table FOR EACH ROW EXECUTE PROCEDURE test_trigger_fn()
+
+DROP TRIGGER test_trigger_fn_trg2 ON test_trigger_table;
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Triggers firing always:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+
+\c regression
+\d+ test_trigger_table
+ Table "public.test_trigger_table"
+ Column | Type | Modifiers | Storage | Stats target | Description
+--------+---------+-----------+----------+--------------+-------------
+ f1 | integer | | plain | |
+ f2 | text | | extended | |
+Triggers:
+ truncate_trigger AFTER TRUNCATE ON test_trigger_table FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+Triggers firing always:
+ test_trigger_fn_trg BEFORE INSERT OR DELETE ON test_trigger_table FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE test_trigger_fn()
+
-- should fail (for test to be useful it should be called on different node than CREATE FUNCTION)
DROP FUNCTION test_trigger_fn();
ERROR: cannot drop function test_trigger_fn() because other objects depend on it
HINT: Use DROP ... CASCADE to drop the dependent objects too.
DROP TABLE test_trigger_table;
DROP FUNCTION test_trigger_fn();
+SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+ pg_xlog_wait_remote_apply
+---------------------------
+
+
+(2 rows)
+
\d+ test_trigger_table
\c postgres
\d+ test_trigger_table