Re: BUG #6048: TRUNCATE vs TRUNCATE CASCADE: misleading message

From: Artiom Makarov <artiom(dot)makarov(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6048: TRUNCATE vs TRUNCATE CASCADE: misleading message
Date: 2011-06-03 07:00:13
Message-ID: BANLkTi=y_nxJ1WC_E-snGa+Oh5BgEZwZPg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2011/6/2 Robert Haas <robertmhaas(at)gmail(dot)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 !

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Cristian Cruz 2011-06-03 12:38:10 BUG #6050: Dump and restore of view after a schema change: can't restore the view
Previous Message Craig Ringer 2011-06-03 02:13:54 Re: UTC4115FATAL: the database system is in recovery mode