From: phb07 <phb07@apra.asso.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14434: Drop a table with a serial in an extension
Date: Sat, 26 Nov 2016 09:10:11 +0100
Message-ID: <e8067935-5649-8215-42e5-fe306c92fb80@apra.asso.fr> (raw)
In-Reply-To: <4135.1480121998@sss.pgh.pa.us>
References: <20161125151448.6529.33039@wrigleys.postgresql.org>
<4135.1480121998@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Thanks Tom,
Le 26/11/2016 à 01:59, Tom Lane a écrit :
> 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.
Because depending on the way a table has been included in the extension
(either directly created inside the extension or first created outside
and then linked to the extension) the procedure to drop it some versions
later would be different.
Of course it would be normal to get this error if the sequence would
have been linked to another extension. But my feeling is that dropping a
table that generates a sequence drop, both belonging to the same
extension, shouldn't be refused.
If the current behaviour is considered as "normal", then the error
message looks strange anyway. In particular the DETAIL output doesn't
reflect the real issue as it doesn't mention the faulting sequence. And
the DROP TABLE ... CASCADE suggested in the HINT doesn't help too. And a
short sentence in the documentation (in the ALTER EXTENSION page for
instance) would also probably help.
> 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.
OK, but in this case, I didn't want to keep the sequence.
> regards, tom lane
>
Regards. Philippe Beaudoin
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: phb07@apra.asso.fr, tgl@sss.pgh.pa.us
Subject: Re: BUG #14434: Drop a table with a serial in an extension
In-Reply-To: <e8067935-5649-8215-42e5-fe306c92fb80@apra.asso.fr>
References: <20161125151448.6529.33039@wrigleys.postgresql.org> <4135.1480121998@sss.pgh.pa.us> <e8067935-5649-8215-42e5-fe306c92fb80@apra.asso.fr>
* 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