From eb978b03ea1d839df2ee7d78c2f60685fa5cc7fb Mon Sep 17 00:00:00 2001
From: Dave Byrne <dbyrne@mdb.com>
Date: Wed, 10 Aug 2011 15:11:52 -0700
Subject: [PATCH] Dont include temporary relations in upgrade

---
 contrib/pg_upgrade/info.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c
index 72bc489..7d95e9a 100644
--- a/contrib/pg_upgrade/info.c
+++ b/contrib/pg_upgrade/info.c
@@ -265,7 +265,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
 			 "	   ON c.relnamespace = n.oid "
 			 "  LEFT OUTER JOIN pg_catalog.pg_tablespace t "
 			 "	   ON c.reltablespace = t.oid "
-			 "WHERE relkind IN ('r','t', 'i'%s) AND "
+			 "WHERE relkind IN ('r','t', 'i'%s) AND %s AND "
 			 "  ((n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
 			 "	  c.oid >= %u) "
 			 "  OR (n.nspname = 'pg_catalog' AND "
@@ -275,6 +275,9 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
 	/* see the comment at the top of old_8_3_create_sequence_script() */
 			 (GET_MAJOR_VERSION(old_cluster.major_version) <= 803) ?
 			 "" : ", 'S'",
+	/* skip temporary relations that may be hanging around */
+			 (GET_MAJOR_VERSION(cluster->major_version) <= 900) ? 
+			 " relistemp = false " : " relpersistence <> 't' ",
 	/* this oid allows us to skip system toast tables */
 			 FirstNormalObjectId,
 	/* does pg_largeobject_metadata need to be migrated? */
-- 
1.7.4.1

