Skip to content

Commit 2f57965

Browse files
committed
IvorySQL: update IvorySQL code for pg commit 6342d49
1 parent 6198d7d commit 2f57965

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

src/oracle_test/regress/expected/triggers.out

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,6 +3112,57 @@ drop trigger child_row_trig on child;
31123112
alter table parent attach partition child for values in ('AAA');
31133113
drop table child, parent;
31143114
--
3115+
-- Verify access of transition tables with UPDATE triggers and tuples
3116+
-- moved across partitions.
3117+
--
3118+
create or replace function dump_update_new() returns trigger language plpgsql as
3119+
$$
3120+
begin
3121+
raise notice 'trigger = %, new table = %', TG_NAME,
3122+
(select string_agg(new_table::text, ', ' order by a) from new_table);
3123+
return null;
3124+
end;
3125+
$$;
3126+
/
3127+
create or replace function dump_update_old() returns trigger language plpgsql as
3128+
$$
3129+
begin
3130+
raise notice 'trigger = %, old table = %', TG_NAME,
3131+
(select string_agg(old_table::text, ', ' order by a) from old_table);
3132+
return null;
3133+
end;
3134+
$$;
3135+
/
3136+
create table trans_tab_parent (a text) partition by list (a);
3137+
create table trans_tab_child1 partition of trans_tab_parent for values in ('AAA1', 'AAA2');
3138+
create table trans_tab_child2 partition of trans_tab_parent for values in ('BBB1', 'BBB2');
3139+
create trigger trans_tab_parent_update_trig
3140+
after update on trans_tab_parent referencing old table as old_table
3141+
for each statement execute procedure dump_update_old();
3142+
create trigger trans_tab_parent_insert_trig
3143+
after insert on trans_tab_parent referencing new table as new_table
3144+
for each statement execute procedure dump_insert();
3145+
create trigger trans_tab_parent_delete_trig
3146+
after delete on trans_tab_parent referencing old table as old_table
3147+
for each statement execute procedure dump_delete();
3148+
insert into trans_tab_parent values ('AAA1'), ('BBB1');
3149+
NOTICE: trigger = trans_tab_parent_insert_trig, new table = (AAA1), (BBB1)
3150+
-- should not trigger access to new table when moving across partitions.
3151+
update trans_tab_parent set a = 'BBB2' where a = 'AAA1';
3152+
NOTICE: trigger = trans_tab_parent_update_trig, old table = (AAA1)
3153+
drop trigger trans_tab_parent_update_trig on trans_tab_parent;
3154+
create trigger trans_tab_parent_update_trig
3155+
after update on trans_tab_parent referencing new table as new_table
3156+
for each statement execute procedure dump_update_new();
3157+
-- should not trigger access to old table when moving across partitions.
3158+
update trans_tab_parent set a = 'AAA2' where a = 'BBB1';
3159+
NOTICE: trigger = trans_tab_parent_update_trig, new table = (AAA2)
3160+
delete from trans_tab_parent;
3161+
NOTICE: trigger = trans_tab_parent_delete_trig, old table = (AAA2), (BBB2)
3162+
-- clean up
3163+
drop table trans_tab_parent, trans_tab_child1, trans_tab_child2;
3164+
drop function dump_update_new, dump_update_old;
3165+
--
31153166
-- Verify behavior of statement triggers on (non-partition)
31163167
-- inheritance hierarchy with transition tables; similar to the
31173168
-- partition case, except there is no rerouting on insertion and child

src/oracle_test/regress/sql/triggers.sql

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,54 @@ alter table parent attach partition child for values in ('AAA');
22332233

22342234
drop table child, parent;
22352235

2236+
--
2237+
-- Verify access of transition tables with UPDATE triggers and tuples
2238+
-- moved across partitions.
2239+
--
2240+
create or replace function dump_update_new() returns trigger language plpgsql as
2241+
$$
2242+
begin
2243+
raise notice 'trigger = %, new table = %', TG_NAME,
2244+
(select string_agg(new_table::text, ', ' order by a) from new_table);
2245+
return null;
2246+
end;
2247+
$$;
2248+
/
2249+
create or replace function dump_update_old() returns trigger language plpgsql as
2250+
$$
2251+
begin
2252+
raise notice 'trigger = %, old table = %', TG_NAME,
2253+
(select string_agg(old_table::text, ', ' order by a) from old_table);
2254+
return null;
2255+
end;
2256+
$$;
2257+
/
2258+
create table trans_tab_parent (a text) partition by list (a);
2259+
create table trans_tab_child1 partition of trans_tab_parent for values in ('AAA1', 'AAA2');
2260+
create table trans_tab_child2 partition of trans_tab_parent for values in ('BBB1', 'BBB2');
2261+
create trigger trans_tab_parent_update_trig
2262+
after update on trans_tab_parent referencing old table as old_table
2263+
for each statement execute procedure dump_update_old();
2264+
create trigger trans_tab_parent_insert_trig
2265+
after insert on trans_tab_parent referencing new table as new_table
2266+
for each statement execute procedure dump_insert();
2267+
create trigger trans_tab_parent_delete_trig
2268+
after delete on trans_tab_parent referencing old table as old_table
2269+
for each statement execute procedure dump_delete();
2270+
insert into trans_tab_parent values ('AAA1'), ('BBB1');
2271+
-- should not trigger access to new table when moving across partitions.
2272+
update trans_tab_parent set a = 'BBB2' where a = 'AAA1';
2273+
drop trigger trans_tab_parent_update_trig on trans_tab_parent;
2274+
create trigger trans_tab_parent_update_trig
2275+
after update on trans_tab_parent referencing new table as new_table
2276+
for each statement execute procedure dump_update_new();
2277+
-- should not trigger access to old table when moving across partitions.
2278+
update trans_tab_parent set a = 'AAA2' where a = 'BBB1';
2279+
delete from trans_tab_parent;
2280+
-- clean up
2281+
drop table trans_tab_parent, trans_tab_child1, trans_tab_child2;
2282+
drop function dump_update_new, dump_update_old;
2283+
22362284
--
22372285
-- Verify behavior of statement triggers on (non-partition)
22382286
-- inheritance hierarchy with transition tables; similar to the

0 commit comments

Comments
 (0)