Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9079fe6

Browse files
committed
Add INSERT ON CONFLICT test on partitioned tables with transition table
This case was uncovered by existing tests, so breakage went undetected.Make sure it remains stable.Extracted from a larger patch byAuthor: David RowleyReviewed-by: Amit LangoteDiscussion:https://postgr.es/m/CAKJS1f-aGCJ5H7_hiSs5PhWs6Obmj+vGARjGymqH1=o5PcrNnQ@mail.gmail.com
1 parentecfd557 commit9079fe6

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

‎src/test/regress/expected/insert_conflict.out

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,4 +904,26 @@ select * from parted_conflict order by a;
904904
50 | cincuenta | 2
905905
(1 row)
906906

907+
-- test with statement level triggers
908+
create or replace function parted_conflict_update_func() returns trigger as $$
909+
declare
910+
r record;
911+
begin
912+
for r in select * from inserted loop
913+
raise notice 'a = %, b = %, c = %', r.a, r.b, r.c;
914+
end loop;
915+
return new;
916+
end;
917+
$$ language plpgsql;
918+
create trigger parted_conflict_update
919+
after update on parted_conflict
920+
referencing new table as inserted
921+
for each statement
922+
execute procedure parted_conflict_update_func();
923+
truncate parted_conflict;
924+
insert into parted_conflict values (0, 'cero', 1);
925+
insert into parted_conflict values(0, 'cero', 1)
926+
on conflict (a,b) do update set c = parted_conflict.c + 1;
927+
NOTICE: a = 0, b = cero, c = 2
907928
drop table parted_conflict;
929+
drop function parted_conflict_update_func();

‎src/test/regress/sql/insert_conflict.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,30 @@ insert into parted_conflict values (50, 'cincuenta', 2)
576576
-- should see (50, 'cincuenta', 2)
577577
select*from parted_conflictorder by a;
578578

579+
-- test with statement level triggers
580+
create or replacefunctionparted_conflict_update_func() returns triggeras $$
581+
declare
582+
r record;
583+
begin
584+
for rinselect*from inserted loop
585+
raise notice'a = %, b = %, c = %',r.a,r.b,r.c;
586+
end loop;
587+
return new;
588+
end;
589+
$$ language plpgsql;
590+
591+
createtriggerparted_conflict_update
592+
afterupdateon parted_conflict
593+
referencing new tableas inserted
594+
for each statement
595+
execute procedure parted_conflict_update_func();
596+
597+
truncate parted_conflict;
598+
599+
insert into parted_conflictvalues (0,'cero',1);
600+
601+
insert into parted_conflictvalues(0,'cero',1)
602+
on conflict (a,b) doupdateset c=parted_conflict.c+1;
603+
579604
droptable parted_conflict;
605+
dropfunction parted_conflict_update_func();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp