Skip site navigation (1) Skip section navigation (2)

Re: objects tied to missing extension

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Phil Sorber <phil(at)omniti(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: objects tied to missing extension
Date: 2011-11-29 00:22:38
Message-ID: 28130.1322526158@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Phil Sorber <phil(at)omniti(dot)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=871dd024a6adf7766702b1cdacfb02bd8002d2bb

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2011-11-29 01:00:34
Subject: Re: Repeatable crash in pg_dump (with -d2 info)
Previous:From: David SchnurDate: 2011-11-28 22:20:42
Subject: Re: Repeatable crash in pg_dump (with -d2 info)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group