From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Todd Kover <kovert@omniscient.com>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: renaming+recreating table w/default sequence causes dependency seq issue
Date: Tue, 07 Aug 2012 23:37:12 -0400
Message-ID: <1344396980-sup-4162@alvh.no-ip.org> (raw)
In-Reply-To: <201208080010.q780APDf006070@guinness.omniscient.com>
References: <201208080010.q780APDf006070@guinness.omniscient.com>
Excerpts from Todd Kover's message of mar ago 07 20:10:25 -0400 2012:
> Given this:
> ---<snip>---
> 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;
> ---<snip>---
>
> 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.
I think you need an ALTER SEQUENCE .. OWNED BY to fix up dependencies
for the sequence.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: alvherre@2ndquadrant.com, kovert@omniscient.com
Subject: Re: renaming+recreating table w/default sequence causes dependency seq issue
In-Reply-To: <1344396980-sup-4162@alvh.no-ip.org>
References: <201208080010.q780APDf006070@guinness.omniscient.com> <1344396980-sup-4162@alvh.no-ip.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox