Re: renaming+recreating table w/default sequence causes dependency seq issue

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Todd Kover <kovert(at)omniscient(dot)com>
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: renaming+recreating table w/default sequence causes dependency seq issue
Date: 2012-08-08 03:37:12
Message-ID: 1344396980-sup-4162@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2012-08-08 03:42:07 Re: renaming+recreating table w/default sequence causes dependency seq issue
Previous Message Craig Ringer 2012-08-08 01:22:02 Re: Small bug in psqlodbc-09.01 prevents interoperability with LISTSERV