Re: renaming+recreating table w/default sequence causes dependency seq issue - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: renaming+recreating table w/default sequence causes dependency seq issue
Date
Msg-id 1344396980-sup-4162@alvh.no-ip.org
Whole thread Raw
In response to renaming+recreating table w/default sequence causes dependency seq issue  (Todd Kover <kovert@omniscient.com>)
List 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;
>=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;
> ---<snip>---
>=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

pgsql-bugs by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Small bug in psqlodbc-09.01 prevents interoperability with LISTSERV
Next
From: Tom Lane
Date:
Subject: Re: renaming+recreating table w/default sequence causes dependency seq issue