Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 28B09B61353 for ; Thu, 2 Jun 2011 08:23:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 97804-05 for ; Thu, 2 Jun 2011 11:23:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 93A9DB6134E for ; Thu, 2 Jun 2011 08:23:42 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p52BNg7q053023 for ; Thu, 2 Jun 2011 11:23:42 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p52BNgZL053022; Thu, 2 Jun 2011 11:23:42 GMT (envelope-from www) Date: Thu, 2 Jun 2011 11:23:42 GMT Message-Id: <201106021123.p52BNgZL053022@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6048: TRUNCATE vs TRUNCATE CASCADE: misleading message From: "Artiom Makarov" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201106/14 X-Sequence-Number: 30393 The following bug has been logged online: Bug reference: 6048 Logged by: Artiom Makarov Email address: artiom.makarov@gmail.com PostgreSQL version: 9.04 Operating system: 2.6.32-30-server #59-Ubuntu SMP Tue Mar 1 22:46:09 UTC 2011 x86_64 GNU/Linux Description: TRUNCATE vs TRUNCATE CASCADE: misleading message Details: 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_test2(id2) 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,2); truncate tr_test1; 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. This is definetly misleading message, because of when applying truncate tr_test1 CASCADE; all 3 tables truncated: NOTICE: truncate cascades to table "tr_test2" NOTICE: truncate cascades to table "tr_test3" While drop schema public; command list all affected objects: ERROR: cannot drop schema public because other objects depend on it SQL state: 2BP01 Detail: table tr_test1 depends on schema public table tr_test2 depends on schema public table tr_test3 depends on schema public Hint: Use DROP ... CASCADE to drop the dependent objects too.