summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorBruce Momjian2015-09-11 19:51:11 +0000
committerBruce Momjian2015-09-11 19:51:11 +0000
commit35d2fc1f299a977483a1ac6d08bfbda104ad2b25 (patch)
tree8f2f84e574534c89087bbf2ab65295612c0fd860 /contrib
parent7d0712890d1e18379394cec33b01edb7102928de (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')
-rw-r--r--contrib/pg_upgrade/info.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/contrib/pg_upgrade/info.c b/contrib/pg_upgrade/info.c
index 93ea2667bc8..0a8467294dc 100644
--- a/contrib/pg_upgrade/info.c
+++ b/contrib/pg_upgrade/info.c
@@ -140,6 +140,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)
{
/*
@@ -147,16 +148,24 @@ create_rel_filename_map(const char *old_data, const char *new_data,
* exist in the data directories.
*/
map->old_tablespace = old_data;
- map->new_tablespace = new_data;
map->old_tablespace_suffix = "/base";
- map->new_tablespace_suffix = "/base";
}
else
{
/* relation belongs to a tablespace, so use the tablespace location */
map->old_tablespace = old_rel->tablespace;
- map->new_tablespace = new_rel->tablespace;
map->old_tablespace_suffix = old_cluster.tablespace_suffix;
+ }
+
+ /* Do the same for new tablespaces */
+ if (strlen(new_rel->tablespace) == 0)
+ {
+ map->new_tablespace = new_data;
+ map->new_tablespace_suffix = "/base";
+ }
+ else
+ {
+ map->new_tablespace = new_rel->tablespace;
map->new_tablespace_suffix = new_cluster.tablespace_suffix;
}