mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
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 <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/
This commit is contained in:
@ -1339,7 +1339,7 @@ DETAIL: Key (f1)=(1) is still referenced from table "defc".
|
|||||||
-- Test the difference between NO ACTION and RESTRICT
|
-- Test the difference between NO ACTION and RESTRICT
|
||||||
--
|
--
|
||||||
create temp table pp (f1 int primary key);
|
create temp table pp (f1 int primary key);
|
||||||
create temp table cc (f1 int references pp on update no action);
|
create temp table cc (f1 int references pp on update no action on delete no action);
|
||||||
insert into pp values(12);
|
insert into pp values(12);
|
||||||
insert into pp values(11);
|
insert into pp values(11);
|
||||||
update pp set f1=f1+1;
|
update pp set f1=f1+1;
|
||||||
@ -1348,9 +1348,12 @@ update pp set f1=f1+1;
|
|||||||
update pp set f1=f1+1; -- fail
|
update pp set f1=f1+1; -- fail
|
||||||
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
|
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
|
||||||
DETAIL: Key (f1)=(13) is still referenced from table "cc".
|
DETAIL: Key (f1)=(13) is still referenced from table "cc".
|
||||||
|
delete from pp where f1 = 13; -- fail
|
||||||
|
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
|
||||||
|
DETAIL: Key (f1)=(13) is still referenced from table "cc".
|
||||||
drop table pp, cc;
|
drop table pp, cc;
|
||||||
create temp table pp (f1 int primary key);
|
create temp table pp (f1 int primary key);
|
||||||
create temp table cc (f1 int references pp on update restrict);
|
create temp table cc (f1 int references pp on update restrict on delete restrict);
|
||||||
insert into pp values(12);
|
insert into pp values(12);
|
||||||
insert into pp values(11);
|
insert into pp values(11);
|
||||||
update pp set f1=f1+1;
|
update pp set f1=f1+1;
|
||||||
@ -1358,6 +1361,9 @@ insert into cc values(13);
|
|||||||
update pp set f1=f1+1; -- fail
|
update pp set f1=f1+1; -- fail
|
||||||
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
|
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
|
||||||
DETAIL: Key (f1)=(13) is still referenced from table "cc".
|
DETAIL: Key (f1)=(13) is still referenced from table "cc".
|
||||||
|
delete from pp where f1 = 13; -- fail
|
||||||
|
ERROR: update or delete on table "pp" violates foreign key constraint "cc_f1_fkey" on table "cc"
|
||||||
|
DETAIL: Key (f1)=(13) is still referenced from table "cc".
|
||||||
drop table pp, cc;
|
drop table pp, cc;
|
||||||
--
|
--
|
||||||
-- Test interaction of foreign-key optimization with rules (bug #14219)
|
-- Test interaction of foreign-key optimization with rules (bug #14219)
|
||||||
|
@ -992,22 +992,24 @@ delete from defp where f1 = 1; -- fail
|
|||||||
-- Test the difference between NO ACTION and RESTRICT
|
-- Test the difference between NO ACTION and RESTRICT
|
||||||
--
|
--
|
||||||
create temp table pp (f1 int primary key);
|
create temp table pp (f1 int primary key);
|
||||||
create temp table cc (f1 int references pp on update no action);
|
create temp table cc (f1 int references pp on update no action on delete no action);
|
||||||
insert into pp values(12);
|
insert into pp values(12);
|
||||||
insert into pp values(11);
|
insert into pp values(11);
|
||||||
update pp set f1=f1+1;
|
update pp set f1=f1+1;
|
||||||
insert into cc values(13);
|
insert into cc values(13);
|
||||||
update pp set f1=f1+1;
|
update pp set f1=f1+1;
|
||||||
update pp set f1=f1+1; -- fail
|
update pp set f1=f1+1; -- fail
|
||||||
|
delete from pp where f1 = 13; -- fail
|
||||||
drop table pp, cc;
|
drop table pp, cc;
|
||||||
|
|
||||||
create temp table pp (f1 int primary key);
|
create temp table pp (f1 int primary key);
|
||||||
create temp table cc (f1 int references pp on update restrict);
|
create temp table cc (f1 int references pp on update restrict on delete restrict);
|
||||||
insert into pp values(12);
|
insert into pp values(12);
|
||||||
insert into pp values(11);
|
insert into pp values(11);
|
||||||
update pp set f1=f1+1;
|
update pp set f1=f1+1;
|
||||||
insert into cc values(13);
|
insert into cc values(13);
|
||||||
update pp set f1=f1+1; -- fail
|
update pp set f1=f1+1; -- fail
|
||||||
|
delete from pp where f1 = 13; -- fail
|
||||||
drop table pp, cc;
|
drop table pp, cc;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
Reference in New Issue
Block a user