aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2018-11-13 18:12:39 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2018-11-13 18:12:39 -0300
commit9079fe60b2142da6e89403b9a9504e75124c085d (patch)
tree0e8d8012149c3e63cb5279a8e0d5908ec6f71b7d
parentecfd5579561c3e720e696a42aadcd4b5b52aa581 (diff)
downloadpostgresql-9079fe60b2142da6e89403b9a9504e75124c085d.tar.gz
postgresql-9079fe60b2142da6e89403b9a9504e75124c085d.zip
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 by Author: David Rowley Reviewed-by: Amit Langote Discussion: https://postgr.es/m/CAKJS1f-aGCJ5H7_hiSs5PhWs6Obmj+vGARjGymqH1=o5PcrNnQ@mail.gmail.com
-rw-r--r--src/test/regress/expected/insert_conflict.out22
-rw-r--r--src/test/regress/sql/insert_conflict.sql26
2 files changed, 48 insertions, 0 deletions
diff --git a/src/test/regress/expected/insert_conflict.out b/src/test/regress/expected/insert_conflict.out
index 27cf5a01b36..6b841c7850e 100644
--- a/src/test/regress/expected/insert_conflict.out
+++ b/src/test/regress/expected/insert_conflict.out
@@ -904,4 +904,26 @@ select * from parted_conflict order by a;
50 | cincuenta | 2
(1 row)
+-- test with statement level triggers
+create or replace function parted_conflict_update_func() returns trigger as $$
+declare
+ r record;
+begin
+ for r in select * from inserted loop
+ raise notice 'a = %, b = %, c = %', r.a, r.b, r.c;
+ end loop;
+ return new;
+end;
+$$ language plpgsql;
+create trigger parted_conflict_update
+ after update on parted_conflict
+ referencing new table as inserted
+ for each statement
+ execute procedure parted_conflict_update_func();
+truncate parted_conflict;
+insert into parted_conflict values (0, 'cero', 1);
+insert into parted_conflict values(0, 'cero', 1)
+ on conflict (a,b) do update set c = parted_conflict.c + 1;
+NOTICE: a = 0, b = cero, c = 2
drop table parted_conflict;
+drop function parted_conflict_update_func();
diff --git a/src/test/regress/sql/insert_conflict.sql b/src/test/regress/sql/insert_conflict.sql
index c677d70fb7b..fe6dcfaa06b 100644
--- a/src/test/regress/sql/insert_conflict.sql
+++ b/src/test/regress/sql/insert_conflict.sql
@@ -576,4 +576,30 @@ insert into parted_conflict values (50, 'cincuenta', 2)
-- should see (50, 'cincuenta', 2)
select * from parted_conflict order by a;
+-- test with statement level triggers
+create or replace function parted_conflict_update_func() returns trigger as $$
+declare
+ r record;
+begin
+ for r in select * from inserted loop
+ raise notice 'a = %, b = %, c = %', r.a, r.b, r.c;
+ end loop;
+ return new;
+end;
+$$ language plpgsql;
+
+create trigger parted_conflict_update
+ after update on parted_conflict
+ referencing new table as inserted
+ for each statement
+ execute procedure parted_conflict_update_func();
+
+truncate parted_conflict;
+
+insert into parted_conflict values (0, 'cero', 1);
+
+insert into parted_conflict values(0, 'cero', 1)
+ on conflict (a,b) do update set c = parted_conflict.c + 1;
+
drop table parted_conflict;
+drop function parted_conflict_update_func();