Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: m(dot)sakrejda(at)gmail(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created
Date: 2012-06-30 05:08:51
Message-ID: 20120630050851.GB20759@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)momjian(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message miroslav.sulc 2012-06-30 10:58:11 BUG #6712: PostgreSQL 9.2 beta2: alter table drop constraint does not work on inherited master table
Previous Message Bruce Momjian 2012-06-30 05:00:07 Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created