Skip to content

Commit 2411fbd

Browse files
committed
In pg_upgrade, avoid dumping orphaned temporary tables. This makes the
pg_upgrade schema matching pattern match pg_dump/pg_dumpall. Fix for 9.0, 9.1, and 9.2.
1 parent 5845f42 commit 2411fbd

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

contrib/pg_upgrade/info.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
266266
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
267267
" ON c.reltablespace = t.oid "
268268
"WHERE relkind IN ('r','t', 'i'%s) AND "
269-
" ((n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
269+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
270+
" ((n.nspname !~ '^pg_' AND "
271+
" n.nspname NOT IN ('information_schema', 'binary_upgrade') AND "
270272
" c.oid >= %u) "
271273
" OR (n.nspname = 'pg_catalog' AND "
272274
" relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "

contrib/pg_upgrade/version_old_8_3.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
5959
" NOT a.attisdropped AND "
6060
" a.atttypid = 'pg_catalog.name'::pg_catalog.regtype AND "
6161
" c.relnamespace = n.oid AND "
62-
" n.nspname != 'pg_catalog' AND "
62+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
63+
" n.nspname !~ '^pg_' AND "
6364
" n.nspname != 'information_schema'");
6465

6566
ntups = PQntuples(res);
@@ -148,7 +149,8 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
148149
" NOT a.attisdropped AND "
149150
" a.atttypid = 'pg_catalog.tsquery'::pg_catalog.regtype AND "
150151
" c.relnamespace = n.oid AND "
151-
" n.nspname != 'pg_catalog' AND "
152+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
153+
" n.nspname !~ '^pg_' AND "
152154
" n.nspname != 'information_schema'");
153155

154156
ntups = PQntuples(res);
@@ -245,7 +247,8 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
245247
" NOT a.attisdropped AND "
246248
" a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND "
247249
" c.relnamespace = n.oid AND "
248-
" n.nspname != 'pg_catalog' AND "
250+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
251+
" n.nspname !~ '^pg_' AND "
249252
" n.nspname != 'information_schema'");
250253

251254
/*
@@ -263,7 +266,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
263266
" NOT a.attisdropped AND " \
264267
" a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND " \
265268
" c.relnamespace = n.oid AND " \
266-
" n.nspname != 'pg_catalog' AND " \
269+
" n.nspname !~ '^pg_' AND " \
267270
" n.nspname != 'information_schema') "
268271

269272
ntups = PQntuples(res);
@@ -616,7 +619,8 @@ old_8_3_create_sequence_script(ClusterInfo *cluster)
616619
" pg_catalog.pg_namespace n "
617620
"WHERE c.relkind = 'S' AND "
618621
" c.relnamespace = n.oid AND "
619-
" n.nspname != 'pg_catalog' AND "
622+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
623+
" n.nspname !~ '^pg_' AND "
620624
" n.nspname != 'information_schema'");
621625

622626
ntups = PQntuples(res);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy