pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Phil Sorber <phil@omniti.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: objects tied to missing extension
Date: Mon, 28 Nov 2011 19:22:38 -0500
Message-ID: <28130.1322526158@sss.pgh.pa.us> (raw)
In-Reply-To: <CADAkt-iJWPaSSsLpVjQeXr+TwVWsgsY-K_GrxqoF3_CUs_9O=Q@mail.gmail.com>
References: <CADAkt-ikZcoupPAOz1WjfnZu=jgKiqPX6YQfoiPmD1Si_WiXJQ@mail.gmail.com>
<21905.1322511142@sss.pgh.pa.us>
<CADAkt-iJWPaSSsLpVjQeXr+TwVWsgsY-K_GrxqoF3_CUs_9O=Q@mail.gmail.com>
Phil Sorber <phil@omniti.com> writes:
> I compiled 9.1 stable head and tested it out. You are correct my
> example no longer works there because of the patch that stopped the
> auto-generated types from becoming dependencies of the extension. In
> fact, the cascade no longer works even if I don't remove the table or
> sequence from the extension. And I agree with your assertions here
> that allowing the extension authors to be adults is fine. However, I
> don't think leaving the database in a bad state is acceptable.
My initial reaction was that this wouldn't be worth the trouble, but
on reflection it occurred to me that the case can still be produced in
HEAD without anything as obviously bogus as dropping the script's own
extension. For instance, suppose the upgrade script in your example
attempts to add the rowtype to the extension explicitly:
alter extension bug_example add type table_a;
alter extension bug_example drop table table_a;
alter extension bug_example drop sequence table_a_id_seq;
drop table table_a cascade;
create table table_b ( id serial, primary key (id) );
With this script, the failure naturally will occur just the same way
in HEAD, since the extension will get dropped due to CASCADE and then
the CREATE TABLE step will add a pg_depend entry referencing the
already-dropped extension.
This is still a bit improbable, but it demonstrates that non-obvious
mistakes in dependency management could lead to the situation happening,
so it convinces me that it's worth expending a little bit of code to
prevent it. Fortunately it's quite trivial to do: we can just make
RemoveExtensionById refuse to delete the extension if its OID is equal
to the CurrentExtensionObject state variable. Committed at
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=871dd024a6adf7766702b1cdacfb02bd80...
regards, tom lane
view thread (6+ messages)
Message-ID: <28130.1322526158@sss.pgh.pa.us> Permalink: ../28130.1322526158@sss.pgh.pa.us/ Also on: postgresql.org/message-id/28130.1322526158@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, phil@omniti.com Subject: Re: objects tied to missing extension In-Reply-To: <28130.1322526158@sss.pgh.pa.us> References: <CADAkt-ikZcoupPAOz1WjfnZu=jgKiqPX6YQfoiPmD1Si_WiXJQ@mail.gmail.com> <21905.1322511142@sss.pgh.pa.us> <CADAkt-iJWPaSSsLpVjQeXr+TwVWsgsY-K_GrxqoF3_CUs_9O=Q@mail.gmail.com> <28130.1322526158@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