pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: phb07@apra.asso.fr
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14434: Drop a table with a serial in an extension
Date: Fri, 25 Nov 2016 19:59:58 -0500
Message-ID: <4135.1480121998@sss.pgh.pa.us> (raw)
In-Reply-To: <20161125151448.6529.33039@wrigleys.postgresql.org>
References: <20161125151448.6529.33039@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (5+ messages)  latest in thread

Message-ID: <4135.1480121998@sss.pgh.pa.us>
Permalink:  ../4135.1480121998@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4135.1480121998@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, phb07@apra.asso.fr
  Subject: Re: BUG #14434: Drop a table with a serial in an extension
  In-Reply-To: <4135.1480121998@sss.pgh.pa.us>
  References: <20161125151448.6529.33039@wrigleys.postgresql.org> <4135.1480121998@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox