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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #14434: Drop a table with a serial in an extension
Дата
Msg-id 4135.1480121998@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #14434: Drop a table with a serial in an extension  (phb07@apra.asso.fr)
Ответы Re: BUG #14434: Drop a table with a serial in an extension  (phb07 <phb07@apra.asso.fr>)
Список 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 по дате отправления:

Предыдущее
От: phb07@apra.asso.fr
Дата:
Сообщение: BUG #14434: Drop a table with a serial in an extension
Следующее
От: phb07
Дата:
Сообщение: Re: BUG #14434: Drop a table with a serial in an extension