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

Commit74bd066

Browse files
committed
Add test case for ON DELETE NO ACTION/RESTRICT
This was previously not covered at all; functionRI_FKey_restrict_del() was not exercised in the tests.Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com>Reviewed-by: Mi Tar <mmitar@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/7ae17c95-0c99-d420-032a-c271f510112b@2ndquadrant.com/
1 parent90525d7 commit74bd066

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 (f1intprimary key);
995-
create temp table cc (f1intreferences pponupdate no action);
995+
create temp table cc (f1intreferences pponupdate no actionon delete no action);
996996
insert into ppvalues(12);
997997
insert into ppvalues(11);
998998
update ppset f1=f1+1;
999999
insert into ccvalues(13);
10001000
update ppset f1=f1+1;
10011001
update ppset f1=f1+1;-- fail
1002+
deletefrom ppwhere f1=13;-- fail
10021003
droptable pp, cc;
10031004

10041005
create temp table pp (f1intprimary key);
1005-
create temp table cc (f1intreferences pponupdate restrict);
1006+
create temp table cc (f1intreferences pponupdate restricton delete restrict);
10061007
insert into ppvalues(12);
10071008
insert into ppvalues(11);
10081009
update ppset f1=f1+1;
10091010
insert into ccvalues(13);
10101011
update ppset f1=f1+1;-- fail
1012+
deletefrom ppwhere f1=13;-- fail
10111013
droptable pp, cc;
10121014

10131015
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp