Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkzwg-0007uM-VU for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Dec 2012 16:23:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tkzwf-0001i9-QB for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Dec 2012 16:23:05 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkzwe-0001i2-Hf for pgsql-hackers@postgreSQL.org; Tue, 18 Dec 2012 16:23:04 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkzwa-0006YR-9D for pgsql-hackers@postgreSQL.org; Tue, 18 Dec 2012 16:23:03 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1TkzwW-00070D-Gr; Tue, 18 Dec 2012 11:22:56 -0500 Date: Tue, 18 Dec 2012 11:22:56 -0500 From: Bruce Momjian To: Andrew Dunstan Cc: Bernhard Schrader , PostgreSQL-development Subject: Re: [ADMIN] Problems with enums after pg_upgrade Message-ID: <20121218162256.GA24700@momjian.us> References: <50CEFE95.9040301@innogames.de> <20121218014137.GB29143@momjian.us> <50D02D13.3010004@innogames.de> <50D0914E.3040508@dunslane.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50D0914E.3040508@dunslane.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Tue, Dec 18, 2012 at 10:52:46AM -0500, Andrew Dunstan wrote: > The translations from oid to label are in pg_enum, but it looks like > somehow you have lost that mapping. I'm not sure what you've done > but AFAICT pg_upgrade is doing the right thing. > > I just did this (from 9.0 to 9.2) and the pg_upgrade_dump_all.sql > that is used to create the new catalog has these lines: > > -- For binary upgrade, must preserve pg_type oid > SELECT binary_upgrade.set_next_pg_type_oid('40804'::pg_catalog.oid); > > > -- For binary upgrade, must preserve pg_type array oid > SELECT > binary_upgrade.set_next_array_pg_type_oid('40803'::pg_catalog.oid); > > CREATE TYPE myenum AS ENUM ( > ); > > -- For binary upgrade, must preserve pg_enum oids > SELECT binary_upgrade.set_next_pg_enum_oid('40805'::pg_catalog.oid); > ALTER TYPE public.myenum ADD VALUE 'foo'; > > SELECT binary_upgrade.set_next_pg_enum_oid('40806'::pg_catalog.oid); > ALTER TYPE public.myenum ADD VALUE 'bar'; > > SELECT binary_upgrade.set_next_pg_enum_oid('40807'::pg_catalog.oid); > ALTER TYPE public.myenum ADD VALUE 'baz'; > > and this worked exactly as expected, with a table using this type > showing the expected values. > > Can you produce a test case demonstrating the error? > > When you run pg_upgrade, use the -r flag to keep all the > intermediate files so we can see what's going on. > > It's no good dumping the new db looking for these values if they > have been lost. You would need to have a physical copy of the old db > and dump that in binary upgrade mode looking for the Oid. If you > don't have a physical copy of the old db or the intermediate dump > file pg_upgrade used then recovery is going to be pretty difficult. > It's not necessarily impossible, but it might involve you getting > some outside help. Yes, this matches what I thought too. You see the binary_upgrade.set_next_pg_enum_oid() calls in pg_dump --binary-upgrade --schema-only and those set the oid of the newly created enum. I agree you would need to run this on the _old_ cluster for us to figure out how it failed. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers