Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqQSg-0005AM-L1 for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Apr 2016 19:28:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aqQSg-00042L-52 for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Apr 2016 19:28:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aqQSf-00041E-1v for pgsql-hackers@postgreSQL.org; Wed, 13 Apr 2016 19:28:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aqQSb-0007yy-DH for pgsql-hackers@postgreSQL.org; Wed, 13 Apr 2016 19:28:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u3DJSBJu020229; Wed, 13 Apr 2016 15:28:11 -0400 From: Tom Lane To: "Feld, Michael (IMS)" cc: Bruce Momjian , pgsql-hackers@postgreSQL.org Subject: Re: [GENERAL] pg_upgrade error regarding hstore operator In-reply-to: <537e590bee35426cb382ad2b66bae43d@NAIAD.omni.imsweb.com> References: <4b5993299ed948728e2ad6e278861807@NAIAD.omni.imsweb.com> <22170.1457479307@sss.pgh.pa.us> <15c0241a4a14409d9bda8c29a9673d68@NAIAD.omni.imsweb.com> <4937.1459983664@sss.pgh.pa.us> <18103.1460497225@sss.pgh.pa.us> <537e590bee35426cb382ad2b66bae43d@NAIAD.omni.imsweb.com> Comments: In-reply-to "Feld, Michael (IMS)" message dated "Wed, 13 Apr 2016 15:32:23 -0000" Date: Wed, 13 Apr 2016 15:28:11 -0400 Message-ID: <20228.1460575691@sss.pgh.pa.us> X-Pg-Spam-Score: -2.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 "Feld, Michael (IMS)" writes: > In addition, I noticed the following differences in the pg_depend catalog, there are 4 entries in 9.1 that are missing in 9.5 which I have separated with ***: > select classid::regclass, objid, objsubid, refclassid::regclass, refobjid, refobjsubid, deptype, opcname, opfname from pg_depend pgd left join pg_opclass on pgd.objid = pg_opclass.oid left join pg_opfamily on pgd.objid = pg_opfamily.oid where classid in ('pg_opfamily'::regclass, 'pg_opclass'::regclass) order by 7,8,9; > *** > "pg_opfamily";325462122;0;"pg_extension";325462055;0;"e";"";"btree_hstore_ops" > "pg_opfamily";325462163;0;"pg_extension";325462055;0;"e";"";"gin_hstore_ops" > "pg_opfamily";325462146;0;"pg_extension";325462055;0;"e";"";"gist_hstore_ops" > "pg_opfamily";325462131;0;"pg_extension";325462055;0;"e";"";"hash_hstore_ops" > *** Ah-hah, there's the problem: the pg_upgrade process fails to restore the extension membership of the opfamilies that are implicitly created by hstore's CREATE OPERATOR CLASS commands. The reason for this is that in binary-upgrade mode, the backend doesn't install any extension membership entries automatically at all, but leaves it for the pg_dump script to do; and pg_dump doesn't realize that it would need to do ALTER EXTENSION ADD for the families as well as the classes. It's hard to solve this locally in pg_dump's opclass handling, because you can't very easily tell whether a CREATE OPERATOR CLASS command will result in creation of an opfamily or not. (It has to not have a FAMILY clause, *and* the opfamily has to not already exist.) I'm inclined to think that the best fix for this is to stop leaving operator families implicit in the dump, but create them explicitly (at which point the extension membership would get added correctly). The comments in dumpOpfamily say * We want to dump the opfamily only if (1) it contains "loose" operators * or functions, or (2) it contains an opclass with a different name or * owner. Otherwise it's sufficient to let it be created during creation * of the contained opclass, and not dumping it improves portability of * the dump. The "portability" consideration in question is whether the dump file can be fed to a pre-8.3 server without changes. I think we could blow that off now; there are almost certainly other things that would have to be tweaked to load a modern dump file into such old versions. So my proposal for fixing this is to remove the logic in pg_dump that tries to suppress explicit dumps of operator families. This would need to be back-patched to 9.1, because it's certainly broken like this in all extension-supporting versions. (Surprising that nobody's noticed.) Objections, better ideas? regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers