Re: BUG #6048: TRUNCATE vs TRUNCATE CASCADE: misleading message - Mailing list pgsql-bugs

From Artiom Makarov
Subject Re: BUG #6048: TRUNCATE vs TRUNCATE CASCADE: misleading message
Date
Msg-id BANLkTi=y_nxJ1WC_E-snGa+Oh5BgEZwZPg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #6048: TRUNCATE vs TRUNCATE CASCADE: misleading message  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-bugs
2011/6/2 Robert Haas <robertmhaas@gmail.com>:

>
> It's a fairly unusual case to have two inheritance children one of
> which has a foreign key referencing the other, and to then try to

BTW, when the both tables refer to tr_test1 directly the same thing
happens on  truncating:

create table tr_test1(id1 int, primary key(id1));
create table tr_test2(id2 int, id int, primary key(id2), foreign key
(id) references tr_test1(id1) MATCH SIMPLE ON UPDATE RESTRICT ON
DELETE RESTRICT);
create table tr_test3(id3 int, id int, primary key(id3), foreign key
(id) references tr_test1(id1) MATCH SIMPLE ON UPDATE RESTRICT ON
DELETE RESTRICT);

insert into tr_test1(id1) values (1);
insert into tr_test2(id2,id) values (1,1);
insert into tr_test2(id2,id) values (2,1);
insert into tr_test3(id3,id) values (1,1);

truncate tr_test1;  -- No message about tr_test3 !
__ERROR: cannot truncate a table referenced in a foreign key constraint
__SQL state: 0A000
__Detail: Table "tr_test2" references "tr_test1".
__Hint: Truncate table "tr_test2" at the same time, or use TRUNCATE ... CASCADE.

truncate tr_test1 cascade;

__NOTICE:  truncate cascades to table "tr_test2"
__NOTICE:  truncate cascades to table "tr_test3"
__Query returned successfully with no result in 94 ms.

No message about tr_test3 !

pgsql-bugs by date:

Previous
From: Craig Ringer
Date:
Subject: Re: UTC4115FATAL: the database system is in recovery mode
Next
From: "Daniel Cristian Cruz"
Date:
Subject: BUG #6050: Dump and restore of view after a schema change: can't restore the view