Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created
Date
Msg-id 20120630050851.GB20759@momjian.us
Whole thread Raw
In response to Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created  (Bruce Momjian <bruce@momjian.us>)
List pgsql-bugs
On Sat, Jun 30, 2012 at 01:00:07AM -0400, Bruce Momjian wrote:
> On Fri, Jun 29, 2012 at 11:35:15PM -0400, Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > I can't think of how to fix this.  Perhaps we need to query the
> > > pg_extension table as of the SELECT function all.
> >
> > I think you're misjudging the core of the issue.  The same thing
> > would happen if somebody dropped and recreated the public schema.
> > Or anything else that we create at initdb time but allow to be
> > dropped.
>
> I just tested dropping and recreating the 'public' schema and pg_upgrade
> worked fine.
>
> I think the fix we need for extensions is to change:
>
>     SELECT binary_upgrade.create_empty_extension('plpgsql',
>     'pg_catalog', false, '1.0', NULL, NULL,
>     ARRAY[]::pg_catalog.text[]);
>
> to
>
>     SELECT binary_upgrade.create_empty_extension('plpgsql',
>     'pg_catalog', false, '1.0', NULL, NULL, ARRAY[]::pg_catalog.text[])
>     WHERE (SELECT COUNT(*) FROM pg_extension WHERE extname = 'plpgsql') = 0;
>
> This basically conditionally calls
> binary_upgrade.create_empty_extension() based on whether the extension
> already exists in the new cluster.

FYI, I forgot to mention that there is a unique index on extname, so
testing just for the name should work fine.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created
Next
From: miroslav.sulc@fordfrog.com
Date:
Subject: BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table