Re: BUG #14434: Drop a table with a serial in an extension - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #14434: Drop a table with a serial in an extension
Date
Msg-id 4135.1480121998@sss.pgh.pa.us
Whole thread Raw
In response to BUG #14434: Drop a table with a serial in an extension  (phb07@apra.asso.fr)
Responses Re: BUG #14434: Drop a table with a serial in an extension
List pgsql-bugs
phb07@apra.asso.fr writes:
> Let's create a table with a serial column (outside any extension).
> Then let's link the table with its sequence to a new extension using ALTER
> EXTENSION ADD ... in the extension script.
> Even though the documentation is not clear on that point, it is necessary to
> explicitly link the sequence to the extension, not to be in trouble with
> pg_dump for instance.
> So far so good. Everything reacts as if the table had been created inside
> the extension.
> But an error occurs when I try to drop this table in the next extension
> upgrade script:
> ERROR:  cannot drop table old_tbl1 because other objects depend on it
> DETAIL:  extension ext1 depends on table old_tbl1
> HINT:  Use DROP ... CASCADE to drop the dependent objects too.

> As a workaround, the sequence can be unlinked from the extension just before
> dropping the table.

Don't see why that's a "workaround".  You added the extension membership
for the sequence explicitly, why wouldn't you expect to need to drop it
explicitly?  Seems to me the system is behaving properly.

If you want to drop the table but keep the sequence, you need to unlink
the sequence from the table, a la

alter sequence old_tbl1_col1_seq owned by none;

before dropping the table.

            regards, tom lane

pgsql-bugs by date:

Previous
From: phb07@apra.asso.fr
Date:
Subject: BUG #14434: Drop a table with a serial in an extension
Next
From: phb07
Date:
Subject: Re: BUG #14434: Drop a table with a serial in an extension