diff options
Diffstat (limited to 'src/test/regress/sql/triggers.sql')
-rw-r--r-- | src/test/regress/sql/triggers.sql | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/regress/sql/triggers.sql b/src/test/regress/sql/triggers.sql index 51610788b21..a3c3115a6e7 100644 --- a/src/test/regress/sql/triggers.sql +++ b/src/test/regress/sql/triggers.sql @@ -2188,6 +2188,52 @@ alter table parent attach partition child for values in ('AAA'); drop table child, parent; -- +-- Verify access of transition tables with UPDATE triggers and tuples +-- moved across partitions. +-- +create or replace function dump_update_new() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, new table = %', TG_NAME, + (select string_agg(new_table::text, ', ' order by a) from new_table); + return null; + end; +$$; +create or replace function dump_update_old() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, old table = %', TG_NAME, + (select string_agg(old_table::text, ', ' order by a) from old_table); + return null; + end; +$$; +create table trans_tab_parent (a text) partition by list (a); +create table trans_tab_child1 partition of trans_tab_parent for values in ('AAA1', 'AAA2'); +create table trans_tab_child2 partition of trans_tab_parent for values in ('BBB1', 'BBB2'); +create trigger trans_tab_parent_update_trig + after update on trans_tab_parent referencing old table as old_table + for each statement execute procedure dump_update_old(); +create trigger trans_tab_parent_insert_trig + after insert on trans_tab_parent referencing new table as new_table + for each statement execute procedure dump_insert(); +create trigger trans_tab_parent_delete_trig + after delete on trans_tab_parent referencing old table as old_table + for each statement execute procedure dump_delete(); +insert into trans_tab_parent values ('AAA1'), ('BBB1'); +-- should not trigger access to new table when moving across partitions. +update trans_tab_parent set a = 'BBB2' where a = 'AAA1'; +drop trigger trans_tab_parent_update_trig on trans_tab_parent; +create trigger trans_tab_parent_update_trig + after update on trans_tab_parent referencing new table as new_table + for each statement execute procedure dump_update_new(); +-- should not trigger access to old table when moving across partitions. +update trans_tab_parent set a = 'AAA2' where a = 'BBB1'; +delete from trans_tab_parent; +-- clean up +drop table trans_tab_parent, trans_tab_child1, trans_tab_child2; +drop function dump_update_new, dump_update_old; + +-- -- Verify behavior of statement triggers on (non-partition) -- inheritance hierarchy with transition tables; similar to the -- partition case, except there is no rerouting on insertion and child |