Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 85116A9F9D3 for ; Sat, 30 Jun 2012 02:00:27 -0300 (ADT) Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SkpnC-0008Pt-OV for pgsql-bugs@postgresql.org; Sat, 30 Jun 2012 05:00:26 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1Skpmx-0001cD-LE; Sat, 30 Jun 2012 01:00:07 -0400 Date: Sat, 30 Jun 2012 01:00:07 -0400 From: Bruce Momjian To: Tom Lane Cc: m.sakrejda@gmail.com, pgsql-bugs@postgresql.org Subject: Re: BUG #6706: pg_upgrade fails when plpgsql dropped/re-created Message-ID: <20120630050007.GA20759@momjian.us> References: <20120630015430.GA912@momjian.us> <336.1341027315@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <336.1341027315@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/244 X-Sequence-Number: 33471 On Fri, Jun 29, 2012 at 11:35:15PM -0400, Tom Lane wrote: > Bruce Momjian 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 http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +