Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39a713e

Browse files
committed
In pg_upgrade, limit schema name filter to include toast tables. Bug
introduced recently when trying to filter out temp tables. Backpatch to 9.0 and 9.1.
1 parent 0b298bd commit 39a713e

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

contrib/pg_upgrade/info.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,10 @@ 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-
/* 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 "
269+
/* exclude possible orphaned temp tables */
270+
" ((n.nspname !~ '^pg_temp_' AND "
271+
" n.nspname !~ '^pg_toast_temp_' AND "
272+
" n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
272273
" c.oid >= %u) "
273274
" OR (n.nspname = 'pg_catalog' AND "
274275
" relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "

contrib/pg_upgrade/version_old_8_3.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ 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-
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
63-
" n.nspname !~ '^pg_' AND "
64-
" n.nspname != 'information_schema'");
62+
/* exclude possible orphaned temp tables */
63+
" n.nspname !~ '^pg_temp_' AND "
64+
" n.nspname !~ '^pg_toast_temp_' AND "
65+
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
6566

6667
ntups = PQntuples(res);
6768
i_nspname = PQfnumber(res, "nspname");
@@ -150,9 +151,10 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
150151
" NOT a.attisdropped AND "
151152
" a.atttypid = 'pg_catalog.tsquery'::pg_catalog.regtype AND "
152153
" c.relnamespace = n.oid AND "
153-
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
154-
" n.nspname !~ '^pg_' AND "
155-
" n.nspname != 'information_schema'");
154+
/* exclude possible orphaned temp tables */
155+
" n.nspname !~ '^pg_temp_' AND "
156+
" n.nspname !~ '^pg_toast_temp_' AND "
157+
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
156158

157159
ntups = PQntuples(res);
158160
i_nspname = PQfnumber(res, "nspname");
@@ -249,9 +251,10 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
249251
" NOT a.attisdropped AND "
250252
" a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND "
251253
" c.relnamespace = n.oid AND "
252-
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
253-
" n.nspname !~ '^pg_' AND "
254-
" n.nspname != 'information_schema'");
254+
/* exclude possible orphaned temp tables */
255+
" n.nspname !~ '^pg_temp_' AND "
256+
" n.nspname !~ '^pg_toast_temp_' AND "
257+
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
255258

256259
/*
257260
* This macro is used below to avoid reindexing indexes already rebuilt
@@ -634,9 +637,10 @@ old_8_3_create_sequence_script(ClusterInfo *cluster)
634637
" pg_catalog.pg_namespace n "
635638
"WHERE c.relkind = 'S' AND "
636639
" c.relnamespace = n.oid AND "
637-
/* exclude pg_catalog and pg_temp_ (could be orphaned tables) */
638-
" n.nspname !~ '^pg_' AND "
639-
" n.nspname != 'information_schema'");
640+
/* exclude possible orphaned temp tables */
641+
" n.nspname !~ '^pg_temp_' AND "
642+
" n.nspname !~ '^pg_toast_temp_' AND "
643+
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
640644

641645
ntups = PQntuples(res);
642646
i_nspname = PQfnumber(res, "nspname");

0 commit comments

Comments
 (0)