diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c new file mode 100644 index 36683fa..e0e3a9f *** a/contrib/pg_upgrade/info.c --- b/contrib/pg_upgrade/info.c *************** get_rel_infos(ClusterInfo *cluster, DbIn *** 256,262 **** i_nspname, i_relname, i_oid, ! i_relfilenode; char query[QUERY_ALLOC]; /* --- 256,263 ---- i_nspname, i_relname, i_oid, ! i_relfilenode, ! i_reltablespace; char query[QUERY_ALLOC]; /* *************** get_rel_infos(ClusterInfo *cluster, DbIn *** 269,275 **** snprintf(query, sizeof(query), "SELECT c.oid, n.nspname, c.relname, " ! " c.relfilenode, %s " "FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n " " ON c.relnamespace = n.oid " " LEFT OUTER JOIN pg_catalog.pg_tablespace t " --- 270,276 ---- snprintf(query, sizeof(query), "SELECT c.oid, n.nspname, c.relname, " ! " c.relfilenode, c.reltablespace, %s " "FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n " " ON c.relnamespace = n.oid " " LEFT OUTER JOIN pg_catalog.pg_tablespace t " *************** get_rel_infos(ClusterInfo *cluster, DbIn *** 306,311 **** --- 307,313 ---- i_nspname = PQfnumber(res, "nspname"); i_relname = PQfnumber(res, "relname"); i_relfilenode = PQfnumber(res, "relfilenode"); + i_reltablespace = PQfnumber(res, "reltablespace"); i_spclocation = PQfnumber(res, "spclocation"); for (relnum = 0; relnum < ntups; relnum++) *************** get_rel_infos(ClusterInfo *cluster, DbIn *** 323,332 **** curr->relfilenode = atooid(PQgetvalue(res, relnum, i_relfilenode)); ! tblspace = PQgetvalue(res, relnum, i_spclocation); ! /* if no table tablespace, use the database tablespace */ ! if (strlen(tblspace) == 0) tblspace = dbinfo->db_tblspace; strlcpy(curr->tablespace, tblspace, sizeof(curr->tablespace)); } PQclear(res); --- 325,337 ---- curr->relfilenode = atooid(PQgetvalue(res, relnum, i_relfilenode)); ! if (atooid(PQgetvalue(res, relnum, i_reltablespace)) != 0) ! /* Might be "", meaning the cluster default location. */ ! tblspace = PQgetvalue(res, relnum, i_spclocation); ! else ! /* A zero reltablespace indicates the database tablespace. */ tblspace = dbinfo->db_tblspace; + strlcpy(curr->tablespace, tblspace, sizeof(curr->tablespace)); } PQclear(res); diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h new file mode 100644 index c1925cf..6dcb1a5 *** a/contrib/pg_upgrade/pg_upgrade.h --- b/contrib/pg_upgrade/pg_upgrade.h *************** typedef struct *** 109,115 **** char relname[NAMEDATALEN]; /* relation name */ Oid reloid; /* relation oid */ Oid relfilenode; /* relation relfile node */ ! char tablespace[MAXPGPATH]; /* relations tablespace path */ } RelInfo; typedef struct --- 109,116 ---- char relname[NAMEDATALEN]; /* relation name */ Oid reloid; /* relation oid */ Oid relfilenode; /* relation relfile node */ ! /* relation tablespace path, or "" for the cluster default */ ! char tablespace[MAXPGPATH]; } RelInfo; typedef struct