summaryrefslogtreecommitdiff
path: root/contrib/pg_upgrade/info.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2015-09-11 15:51:10 -0400
committerBruce Momjian <bruce@momjian.us>2015-09-11 15:51:10 -0400
commitbefc63e849d24a4d4aacece42937f7600af7967f (patch)
tree029b93ede0272e29ee7a02060fcaef35f3522ad2 /contrib/pg_upgrade/info.c
parentfe146952547ce3e7b2e13f764d62e9c27d370793 (diff)
pg_dump, pg_upgrade: allow postgres/template1 tablespace moves
Modify pg_dump to restore postgres/template1 databases to non-default tablespaces by switching out of the database to be moved, then switching back. Also, to fix potentially cases where the old/new tablespaces might not match, fix pg_upgrade to process new/old tablespaces separately in all cases. Report by Marti Raudsepp Patch by Marti Raudsepp, me Backpatch through 9.0
Diffstat (limited to 'contrib/pg_upgrade/info.c')
-rw-r--r--contrib/pg_upgrade/info.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c
index eec087fc486..709b45ba188 100644
--- a/contrib/pg_upgrade/info.c
+++ b/contrib/pg_upgrade/info.c
@@ -137,6 +137,7 @@ create_rel_filename_map(const char *old_data, const char *new_data,
const RelInfo *old_rel, const RelInfo *new_rel,
FileNameMap *map)
{
+ /* In case old/new tablespaces don't match, do them separately. */
if (strlen(old_rel->tablespace) == 0)
{
/*
@@ -145,14 +146,27 @@ create_rel_filename_map(const char *old_data, const char *new_data,
*/
snprintf(map->old_dir, sizeof(map->old_dir), "%s/base/%u", old_data,
old_db->db_oid);
- snprintf(map->new_dir, sizeof(map->new_dir), "%s/base/%u", new_data,
- new_db->db_oid);
}
else
{
/* relation belongs to a tablespace, so use the tablespace location */
snprintf(map->old_dir, sizeof(map->old_dir), "%s%s/%u", old_rel->tablespace,
old_cluster.tablespace_suffix, old_db->db_oid);
+ }
+
+ /* Do the same for new tablespaces */
+ if (strlen(new_rel->tablespace) == 0)
+ {
+ /*
+ * relation belongs to the default tablespace, hence relfiles should
+ * exist in the data directories.
+ */
+ snprintf(map->new_dir, sizeof(map->new_dir), "%s/base/%u", new_data,
+ new_db->db_oid);
+ }
+ else
+ {
+ /* relation belongs to a tablespace, so use the tablespace location */
snprintf(map->new_dir, sizeof(map->new_dir), "%s%s/%u", new_rel->tablespace,
new_cluster.tablespace_suffix, new_db->db_oid);
}