diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 0653ff1..85af773 100644
*** a/src/bin/pg_upgrade/info.c
--- b/src/bin/pg_upgrade/info.c
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 323,329 ****
  	int			i_spclocation,
  				i_nspname,
  				i_relname,
! 				i_oid,
  				i_relfilenode,
  				i_reltablespace;
  	char		query[QUERY_ALLOC];
--- 323,331 ----
  	int			i_spclocation,
  				i_nspname,
  				i_relname,
! 				i_reloid,
! 				i_indtable,
! 				i_toastheap,
  				i_relfilenode,
  				i_reltablespace;
  	char		query[QUERY_ALLOC];
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 345,352 ****
  	 * if it exists.
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "WITH regular_heap (reloid) AS ( "
! 			 "  SELECT c.oid "
  			 "  FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
  			 "         ON c.relnamespace = n.oid "
  			 "  WHERE relkind IN ('r', 'm', 'S') AND "
--- 347,354 ----
  	 * if it exists.
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "WITH regular_heap (reloid, indtable, toastheap) AS ( "
! 			 "  SELECT c.oid, 0::oid, 0::oid "
  			 "  FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
  			 "         ON c.relnamespace = n.oid "
  			 "  WHERE relkind IN ('r', 'm', 'S') AND "
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 368,375 ****
  	 * because the namespace-name rules above don't work for toast tables.)
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "  toast_heap (reloid) AS ( "
! 			 "  SELECT c.reltoastrelid "
  			 "  FROM regular_heap JOIN pg_catalog.pg_class c "
  			 "      ON regular_heap.reloid = c.oid "
  			 "  WHERE c.reltoastrelid != 0), ");
--- 370,377 ----
  	 * because the namespace-name rules above don't work for toast tables.)
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "  toast_heap (reloid, indtable, toastheap) AS ( "
! 			 "  SELECT c.reltoastrelid, 0::oid, c.oid "
  			 "  FROM regular_heap JOIN pg_catalog.pg_class c "
  			 "      ON regular_heap.reloid = c.oid "
  			 "  WHERE c.reltoastrelid != 0), ");
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 381,388 ****
  	 * versions.
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "  all_index (reloid) AS ( "
! 			 "  SELECT indexrelid "
  			 "  FROM pg_catalog.pg_index "
  			 "  WHERE indisvalid AND indisready "
  			 "    AND indrelid IN "
--- 383,390 ----
  	 * versions.
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "  all_index (reloid, indtable, toastheap) AS ( "
! 			 "  SELECT indexrelid, indrelid, 0::oid "
  			 "  FROM pg_catalog.pg_index "
  			 "  WHERE indisvalid AND indisready "
  			 "    AND indrelid IN "
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 395,407 ****
  	 * heap and index relation.  Make sure result is sorted by OID.
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "SELECT c.oid, n.nspname, c.relname, "
  			 "  c.relfilenode, c.reltablespace, %s "
! 			 "FROM (SELECT reloid FROM regular_heap "
  			 "      UNION ALL "
! 			 "      SELECT reloid FROM toast_heap "
  			 "      UNION ALL "
! 			 "      SELECT reloid FROM all_index) all_rels "
  			 "  JOIN pg_catalog.pg_class c "
  			 "      ON all_rels.reloid = c.oid "
  			 "  JOIN pg_catalog.pg_namespace n "
--- 397,409 ----
  	 * heap and index relation.  Make sure result is sorted by OID.
  	 */
  	snprintf(query + strlen(query), sizeof(query) - strlen(query),
! 			 "SELECT all_rels.*, n.nspname, c.relname, "
  			 "  c.relfilenode, c.reltablespace, %s "
! 			 "FROM (SELECT * FROM regular_heap "
  			 "      UNION ALL "
! 			 "      SELECT * FROM toast_heap "
  			 "      UNION ALL "
! 			 "      SELECT * FROM all_index) all_rels "
  			 "  JOIN pg_catalog.pg_class c "
  			 "      ON all_rels.reloid = c.oid "
  			 "  JOIN pg_catalog.pg_namespace n "
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 420,426 ****
  
  	relinfos = (RelInfo *) pg_malloc(sizeof(RelInfo) * ntups);
  
! 	i_oid = PQfnumber(res, "oid");
  	i_nspname = PQfnumber(res, "nspname");
  	i_relname = PQfnumber(res, "relname");
  	i_relfilenode = PQfnumber(res, "relfilenode");
--- 422,430 ----
  
  	relinfos = (RelInfo *) pg_malloc(sizeof(RelInfo) * ntups);
  
! 	i_reloid = PQfnumber(res, "reloid");
! 	i_indtable = PQfnumber(res, "indtable");
! 	i_toastheap = PQfnumber(res, "toastheap");
  	i_nspname = PQfnumber(res, "nspname");
  	i_relname = PQfnumber(res, "relname");
  	i_relfilenode = PQfnumber(res, "relfilenode");
*************** get_rel_infos(ClusterInfo *cluster, DbIn
*** 431,437 ****
  	{
  		RelInfo    *curr = &relinfos[num_rels++];
  
! 		curr->reloid = atooid(PQgetvalue(res, relnum, i_oid));
  
  		nspname = PQgetvalue(res, relnum, i_nspname);
  		curr->nsp_alloc = false;
--- 435,443 ----
  	{
  		RelInfo    *curr = &relinfos[num_rels++];
  
! 		curr->reloid = atooid(PQgetvalue(res, relnum, i_reloid));
! 		curr->indtable = atooid(PQgetvalue(res, relnum, i_indtable));
! 		curr->toastheap = atooid(PQgetvalue(res, relnum, i_toastheap));
  
  		nspname = PQgetvalue(res, relnum, i_nspname);
  		curr->nsp_alloc = false;
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 89beb73..389d463 100644
*** a/src/bin/pg_upgrade/pg_upgrade.h
--- b/src/bin/pg_upgrade/pg_upgrade.h
*************** extern char *output_files[];
*** 137,151 ****
   */
  typedef struct
  {
! 	/* Can't use NAMEDATALEN;  not guaranteed to fit on client */
  	char	   *nspname;		/* namespace name */
  	char	   *relname;		/* relation name */
! 	Oid			reloid;			/* relation oid */
  	Oid			relfilenode;	/* relation relfile node */
! 	/* relation tablespace path, or "" for the cluster default */
! 	char	   *tablespace;
! 	bool		nsp_alloc;
! 	bool		tblsp_alloc;
  } RelInfo;
  
  typedef struct
--- 137,152 ----
   */
  typedef struct
  {
! 	/* Can't use NAMEDATALEN; not guaranteed to be same on client */
  	char	   *nspname;		/* namespace name */
  	char	   *relname;		/* relation name */
! 	Oid			reloid;			/* relation OID */
  	Oid			relfilenode;	/* relation relfile node */
! 	Oid			indtable;		/* if index, OID of its table, else 0 */
! 	Oid			toastheap;		/* if toast table, OID of base table, else 0 */
! 	char	   *tablespace;		/* tablespace path; "" for cluster default */
! 	bool		nsp_alloc;		/* should nspname be freed? */
! 	bool		tblsp_alloc;	/* should tablespace be freed? */
  } RelInfo;
  
  typedef struct
