Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 327582E8109 for ; Tue, 7 Aug 2012 21:10:44 -0300 (ADT) Received: from guinness.omniscient.com ([205.129.9.5]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SytrF-0001I6-4b for pgsql-bugs@postgresql.org; Wed, 08 Aug 2012 00:10:43 +0000 Received: from guinness.omniscient.com (localhost [127.0.0.1]) by guinness.omniscient.com (8.14.5/8.14.4) with ESMTP id q780APDf006070 for ; Tue, 7 Aug 2012 20:10:25 -0400 (EDT) Message-Id: <201208080010.q780APDf006070@guinness.omniscient.com> To: pgsql-bugs@postgresql.org Subject: renaming+recreating table w/default sequence causes dependency seq issue Date: Tue, 07 Aug 2012 20:10:25 -0400 From: Todd Kover X-Virus-Scanned: clamav-milter 0.97.3-exp at guinness.omniscient.com X-Virus-Status: Clean X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED,MISSING_MID autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on guinness.omniscient.com X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.7 (guinness.omniscient.com [127.0.0.1]); Tue, 07 Aug 2012 20:10:26 -0400 (EDT) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/29 X-Sequence-Number: 33753 I saw issues around renaming tables and not renaming sequences in the TODO list but did not see anything about this. Apologies if I missed it. This is with a 9.1.4 server (enterprisedb download on mac os/x lion) and also seen on 9.1.3 built from netbsd pkgsrc. It appears that something is amiss if you try to drop a table that has been renamed that used to have a default mapping to a sequence: Given this: ------ drop table IF EXISTS foo; drop table IF EXISTS foo_v26; create table foo (id serial not null, bar integer ); alter table foo alter column id drop default; alter table foo rename to foo_v26; create table foo (id integer not null, bar integer ); alter table foo alter id SET DEFAULT nextval('foo_id_seq'); drop table foo_v26; ------ everthing works as expected until the final drop, which says: jazzhands=> drop table foo_v26; ERROR: cannot drop table foo_v26 because other objects depend on it DETAIL: default for table foo column id depends on sequence foo_id_seq HINT: Use DROP ... CASCADE to drop the dependent objects too. however... jazzhands=> \d foo; Table "public.foo" Column | Type | Modifiers --------+---------+-------------------------------------------------- id | integer | not null default nextval('foo_id_seq'::regclass) jazzhands=> \d foo_v26; Table "public.foo_v26" Column | Type | Modifiers --------+---------+----------- id | integer | not null Interestingly, I can drop table foo without any complaints. It seems like the dependency did not move (it also seems like its backwards but that's probably all me). Sadly, if I move setting the default to after I drop the old table, the sequence goes away, so I am still digging into a work around. thanks, -Todd