]> 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:37 +0000 (22:39 -0400)
committerBruce Momjian <bruce@momjian.us>
Tue, 16 Aug 2011 02:40:09 +0000 (22:40 -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 f0cd8e5ede29a02db5c4f45ce414897f91772e7f..f7031bc6be13bbd116a46fc0f3f4ed1b6f94fd18 100644 (file)
@@ -266,7 +266,9 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
                         "  LEFT OUTER JOIN pg_catalog.pg_tablespace t "
                         "         ON c.reltablespace = t.oid "
                         "WHERE relkind IN ('r','t', 'i'%s) AND "
-                        "  ((n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
+                        /* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
+                        "  ((n.nspname !~ '^pg_' AND "
+                       "     n.nspname NOT IN ('information_schema', 'binary_upgrade') AND "
                         "        c.oid >= %u) "
                         "  OR (n.nspname = 'pg_catalog' AND "
        "    relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
index 1a31f8d68350914eb7d779ea13b2dcbe537ef830..6122f78beea72205086a73b37d84f6c9bcc9300d 100644 (file)
@@ -59,7 +59,8 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
                                                                "               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);
@@ -149,7 +150,8 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
                                                                "               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);
@@ -247,7 +249,8 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, 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'");
 
 /*
@@ -265,7 +268,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, 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);
@@ -631,7 +634,8 @@ old_8_3_create_sequence_script(ClusterInfo *cluster)
                                                                "               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);