Skip to content

Commit 74bd066

Browse files
committed
Add test case for ON DELETE NO ACTION/RESTRICT
This was previously not covered at all; function RI_FKey_restrict_del() was not exercised in the tests. Reviewed-by: Alvaro Herrera <[email protected]> Reviewed-by: Mi Tar <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]/
1 parent 90525d7 commit 74bd066

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/test/regress/expected/foreign_key.out

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ DETAIL: Key (f1)=(1) is still referenced from table "defc".
13391339
-- Test the difference between NO ACTION and RESTRICT
13401340
--
13411341
create temp table pp (f1 int primary key);
1342-
create temp table cc (f1 int references pp on update no action);
1342+
create temp table cc (f1 int references pp on update no action on delete no action);
13431343
insert into pp values(12);
13441344
insert into pp values(11);
13451345
update pp set f1=f1+1;
@@ -1348,16 +1348,22 @@ update pp set f1=f1+1;
13481348
update pp set f1=f1+1; -- fail
13491349
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
13501350
DETAIL: Key (f1)=(13) is still referenced from table "cc".
1351+
delete from pp where f1 = 13; -- fail
1352+
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
1353+
DETAIL: Key (f1)=(13) is still referenced from table "cc".
13511354
drop table pp, cc;
13521355
create temp table pp (f1 int primary key);
1353-
create temp table cc (f1 int references pp on update restrict);
1356+
create temp table cc (f1 int references pp on update restrict on delete restrict);
13541357
insert into pp values(12);
13551358
insert into pp values(11);
13561359
update pp set f1=f1+1;
13571360
insert into cc values(13);
13581361
update pp set f1=f1+1; -- fail
13591362
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
13601363
DETAIL: Key (f1)=(13) is still referenced from table "cc".
1364+
delete from pp where f1 = 13; -- fail
1365+
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
1366+
DETAIL: Key (f1)=(13) is still referenced from table "cc".
13611367
drop table pp, cc;
13621368
--
13631369
-- Test interaction of foreign-key optimization with rules (bug #14219)

src/test/regress/sql/foreign_key.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,22 +992,24 @@ delete from defp where f1 = 1; -- fail
992992
-- Test the difference between NO ACTION and RESTRICT
993993
--
994994
create temp table pp (f1 int primary key);
995-
create temp table cc (f1 int references pp on update no action);
995+
create temp table cc (f1 int references pp on update no action on delete no action);
996996
insert into pp values(12);
997997
insert into pp values(11);
998998
update pp set f1=f1+1;
999999
insert into cc values(13);
10001000
update pp set f1=f1+1;
10011001
update pp set f1=f1+1; -- fail
1002+
delete from pp where f1 = 13; -- fail
10021003
drop table pp, cc;
10031004

10041005
create temp table pp (f1 int primary key);
1005-
create temp table cc (f1 int references pp on update restrict);
1006+
create temp table cc (f1 int references pp on update restrict on delete restrict);
10061007
insert into pp values(12);
10071008
insert into pp values(11);
10081009
update pp set f1=f1+1;
10091010
insert into cc values(13);
10101011
update pp set f1=f1+1; -- fail
1012+
delete from pp where f1 = 13; -- fail
10111013
drop table pp, cc;
10121014

10131015
--

0 commit comments

Comments
 (0)