Re: BUG #14434: Drop a table with a serial in an extension

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: phb07(at)apra(dot)asso(dot)fr
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14434: Drop a table with a serial in an extension
Date: 2016-11-26 00:59:58
Message-ID: 4135.1480121998@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

phb07(at)apra(dot)asso(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message phb07 2016-11-26 08:10:11 Re: BUG #14434: Drop a table with a serial in an extension
Previous Message phb07 2016-11-25 15:14:48 BUG #14434: Drop a table with a serial in an extension