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 20120630050007.GA20759@momjian.us
Whole thread Raw
In response to Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created
Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created
List pgsql-bugs
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.

--
  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: Tom Lane
Date:
Subject: Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created