]> granicus.if.org Git - postgresql/commitdiff
In pg_upgrade, avoid dumping orphaned temporary tables. This makes the
authorBruce Momjian <bruce@momjian.us>
Tue, 16 Aug 2011 02:39:38 +0000 (22:39 -0400)
committerBruce Momjian <bruce@momjian.us>
Tue, 16 Aug 2011 02:39:38 +0000 (22:39 -0400)
pg_upgrade schema matching pattern match pg_dump/pg_dumpall.

Fix for 9.0, 9.1, and 9.2.

contrib/pg_upgrade/info.c
contrib/pg_upgrade/version_old_8_3.c

index 567c64e8b826bc08d181abdca6520e0447349e11..ca357e78924ff60cb0245852356cd21e3a440cfc 100644 (file)
@@ -326,7 +326,10 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
                         "      ON c.relnamespace = n.oid "
                         "   LEFT OUTER JOIN pg_catalog.pg_tablespace t "
                         "      ON c.reltablespace = t.oid "
-                        "WHERE (( n.nspname NOT IN ('pg_catalog', 'information_schema') "
+                        "WHERE (( "
+                        /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
+                        "      n.nspname !~ '^pg_' "
+                        "      AND n.nspname != 'information_schema' "
                         "      AND c.oid >= %u "
                         "      ) OR ( "
                         "      n.nspname = 'pg_catalog' "
index 6ca266c4eb3e10a3f90b5d3e39253bf116065199..930f76d7146f700c150bd41c1ef77d831aed3526 100644 (file)
@@ -61,7 +61,8 @@ old_8_3_check_for_name_data_type_usage(migratorContext *ctx, Cluster whichCluste
                                                                "               NOT a.attisdropped AND "
                                                                "               a.atttypid = 'pg_catalog.name'::pg_catalog.regtype AND "
                                                                "               c.relnamespace = n.oid AND "
-                                                         "             n.nspname != 'pg_catalog' AND "
+                                                        /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
+                                                               "   n.nspname !~ '^pg_' AND "
                                                 "              n.nspname != 'information_schema'");
 
                ntups = PQntuples(res);
@@ -151,7 +152,8 @@ old_8_3_check_for_tsquery_usage(migratorContext *ctx, Cluster whichCluster)
                                                                "               NOT a.attisdropped AND "
                                                                "               a.atttypid = 'pg_catalog.tsquery'::pg_catalog.regtype AND "
                                                                "               c.relnamespace = n.oid AND "
-                                                         "             n.nspname != 'pg_catalog' AND "
+                                                        /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
+                                                               "   n.nspname !~ '^pg_' AND "
                                                 "              n.nspname != 'information_schema'");
 
                ntups = PQntuples(res);
@@ -250,7 +252,8 @@ old_8_3_rebuild_tsvector_tables(migratorContext *ctx, bool check_mode,
                                                                "               NOT a.attisdropped AND "
                                                                "               a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND "
                                                                "               c.relnamespace = n.oid AND "
-                                                         "             n.nspname != 'pg_catalog' AND "
+                                                        /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
+                                                               "   n.nspname !~ '^pg_' AND "
                                                 "              n.nspname != 'information_schema'");
 
 /*
@@ -268,7 +271,7 @@ old_8_3_rebuild_tsvector_tables(migratorContext *ctx, bool check_mode,
                                                                "               NOT a.attisdropped AND "                \
                                                                "               a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND " \
                                                                "               c.relnamespace = n.oid AND "    \
-                                                               "               n.nspname != 'pg_catalog' AND " \
+                                                               "       n.nspname !~ '^pg_' AND "               \
                                                                "               n.nspname != 'information_schema') "
 
                ntups = PQntuples(res);
@@ -638,7 +641,8 @@ old_8_3_create_sequence_script(migratorContext *ctx, Cluster whichCluster)
                                                                "               pg_catalog.pg_namespace n "
                                                                "WHERE  c.relkind = 'S' AND "
                                                                "               c.relnamespace = n.oid AND "
-                                                         "             n.nspname != 'pg_catalog' AND "
+                                                        /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
+                                                               "   n.nspname !~ '^pg_' AND "
                                                 "              n.nspname != 'information_schema'");
 
                ntups = PQntuples(res);