Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id C280810EE895 for ; Wed, 8 Aug 2012 00:38:01 -0300 (ADT) Received: from outmail148112.authsmtp.co.uk ([62.13.148.112]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Syx5q-0004nn-IK for pgsql-bugs@postgresql.org; Wed, 08 Aug 2012 03:38:00 +0000 Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id q783bL6V060223; Wed, 8 Aug 2012 04:37:21 +0100 (BST) Received: from perhan.alvh.no-ip.org ([200.85.213.230]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2) with ESMTP id q783bEtV082264; Wed, 8 Aug 2012 04:37:16 +0100 (BST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 73F326E402; Tue, 7 Aug 2012 23:37:13 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: Pg Bugs Subject: Re: renaming+recreating table w/default sequence causes dependency seq issue From: Alvaro Herrera To: Todd Kover In-reply-to: <201208080010.q780APDf006070@guinness.omniscient.com> References: <201208080010.q780APDf006070@guinness.omniscient.com> Date: Tue, 07 Aug 2012 23:37:12 -0400 Message-Id: <1344396980-sup-4162@alvh.no-ip.org> User-Agent: Sup/git X-Server-Quench: 598e3c9c-e10a-11e1-97bb-002264978518 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZcSBoa BzkeAQdJTRslYBtL RB4bawxAL0wMSABN M15eIxoJcUtEFRZw RjEUWVRVUk1xXWl2 bABQa0tfYkpQVwB0 UklKXFBRFBpqBB4E GR5QEx56dFczPBhw bURgWHQVX0ZzdQh4 S0YBFj4PNno1aWBO TUFZIgJJeQQYLAJF alJ9UncEZm0CZ3Iu JQJhdwMbABpkHWxP TwcEKFMUTgUREzUm ShkeHDMgVVEMTSE+ ZwNhJlMSFVsVLg0p PEI8VFQTPlcZAxBF EloFDCJBKl8NSiwg HEtBUFdWESZGXCo0 X-Authentic-SMTP: 61633235383639.1014:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 200.85.213.230/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by punt9.authsmtp.com id q783bL6V060223 X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201208/31 X-Sequence-Number: 33755 Excerpts from Todd Kover's message of mar ago 07 20:10:25 -0400 2012: > Given this: > ------ > drop table IF EXISTS foo; > drop table IF EXISTS foo_v26; >=20 > create table foo (id serial not null, bar integer ); > alter table foo alter column id drop default; >=20 > alter table foo rename to foo_v26; >=20 > create table foo (id integer not null, bar integer ); >=20 > alter table foo alter id SET DEFAULT nextval('foo_id_seq'); >=20 > drop table foo_v26; > ------ >=20 > everthing works as expected until the final drop, which says: >=20 > jazzhands=3D> 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. I think you need an ALTER SEQUENCE .. OWNED BY to fix up dependencies for the sequence. --=20 =C3=81lvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services