From fb7890aedbd4d67bc1ddee65f9249f5b6ccc9d49 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 30 Mar 2013 22:20:53 -0400 Subject: pg_upgrade: don't copy/link files for invalid indexes Now that pg_dump no longer dumps invalid indexes, per commit 683abc73dff549e94555d4020dae8d02f32ed78b, have pg_upgrade also skip them. Previously pg_upgrade threw an error if invalid indexes existed. Backpatch to 9.2, 9.1, and 9.0 (where pg_upgrade was added to git) --- contrib/pg_upgrade/info.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'contrib/pg_upgrade/info.c') diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c index 02d3e0f52f0..271c27ce730 100644 --- a/contrib/pg_upgrade/info.c +++ b/contrib/pg_upgrade/info.c @@ -325,6 +325,8 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo, "FROM pg_catalog.pg_class c JOIN " " pg_catalog.pg_namespace n " " ON c.relnamespace = n.oid " + " LEFT OUTER JOIN pg_catalog.pg_index i " + " ON c.oid = i.indexrelid " " LEFT OUTER JOIN pg_catalog.pg_tablespace t " " ON c.reltablespace = t.oid " "WHERE (( " @@ -338,7 +340,11 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo, " n.nspname = 'pg_catalog' " " AND relname IN " " ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) " - " AND relkind IN ('r','t', 'i'%s)" + " AND relkind IN ('r','t', 'i'%s) " + /* pg_dump only dumps valid indexes; testing indisready is + * necessary in 9.2, and harmless in earlier/later versions. */ + " AND i.indisvalid IS DISTINCT FROM false AND " + " i.indisready IS DISTINCT FROM false " "GROUP BY c.oid, n.nspname, c.relname, c.relfilenode," " c.reltoastrelid, c.reltablespace, t.spclocation, " " n.nspname " -- cgit v1.2.3