Skip to content

Commit f239ec5

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 5707f35 commit f239ec5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

contrib/pg_upgrade/info.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
326326
" ON c.relnamespace = n.oid "
327327
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
328328
" ON c.reltablespace = t.oid "
329-
"WHERE (( n.nspname NOT IN ('pg_catalog', 'information_schema') "
329+
"WHERE (( "
330+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
331+
" n.nspname !~ '^pg_' "
332+
" AND n.nspname != 'information_schema' "
330333
" AND c.oid >= %u "
331334
" ) OR ( "
332335
" n.nspname = 'pg_catalog' "

contrib/pg_upgrade/version_old_8_3.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ old_8_3_check_for_name_data_type_usage(migratorContext *ctx, Cluster whichCluste
6161
" NOT a.attisdropped AND "
6262
" a.atttypid = 'pg_catalog.name'::pg_catalog.regtype AND "
6363
" c.relnamespace = n.oid AND "
64-
" n.nspname != 'pg_catalog' AND "
64+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
65+
" n.nspname !~ '^pg_' AND "
6566
" n.nspname != 'information_schema'");
6667

6768
ntups = PQntuples(res);
@@ -151,7 +152,8 @@ old_8_3_check_for_tsquery_usage(migratorContext *ctx, Cluster whichCluster)
151152
" NOT a.attisdropped AND "
152153
" a.atttypid = 'pg_catalog.tsquery'::pg_catalog.regtype AND "
153154
" c.relnamespace = n.oid AND "
154-
" n.nspname != 'pg_catalog' AND "
155+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
156+
" n.nspname !~ '^pg_' AND "
155157
" n.nspname != 'information_schema'");
156158

157159
ntups = PQntuples(res);
@@ -250,7 +252,8 @@ old_8_3_rebuild_tsvector_tables(migratorContext *ctx, bool check_mode,
250252
" NOT a.attisdropped AND "
251253
" a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND "
252254
" c.relnamespace = n.oid AND "
253-
" n.nspname != 'pg_catalog' AND "
255+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
256+
" n.nspname !~ '^pg_' AND "
254257
" n.nspname != 'information_schema'");
255258

256259
/*
@@ -268,7 +271,7 @@ old_8_3_rebuild_tsvector_tables(migratorContext *ctx, bool check_mode,
268271
" NOT a.attisdropped AND " \
269272
" a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND " \
270273
" c.relnamespace = n.oid AND " \
271-
" n.nspname != 'pg_catalog' AND " \
274+
" n.nspname !~ '^pg_' AND " \
272275
" n.nspname != 'information_schema') "
273276

274277
ntups = PQntuples(res);
@@ -638,7 +641,8 @@ old_8_3_create_sequence_script(migratorContext *ctx, Cluster whichCluster)
638641
" pg_catalog.pg_namespace n "
639642
"WHERE c.relkind = 'S' AND "
640643
" c.relnamespace = n.oid AND "
641-
" n.nspname != 'pg_catalog' AND "
644+
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
645+
" n.nspname !~ '^pg_' AND "
642646
" n.nspname != 'information_schema'");
643647

644648
ntups = PQntuples(res);

0 commit comments

Comments
 (0)