diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_dump/pg_dumpall.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index cb744f5ab33..e4fde3f1303 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -1326,6 +1326,28 @@ dumpCreateDB(PGconn *conn) appendPQExpBuffer(buf, ";\n"); } } + else if (strcmp(dbtablespace, "pg_default") != 0 && !no_tablespaces) + { + /* + * Cannot change tablespace of the database we're connected to, + * so to move "postgres" to another tablespace, we connect to + * "template1", and vice versa. + */ + if (strcmp(dbname, "postgres") == 0) + appendPQExpBuffer(buf, "%s\\connect template1\n", + /* Add a space before \\connect so pg_upgrade can split */ + binary_upgrade ? " " : ""); + else + appendPQExpBuffer(buf, "%s\\connect postgres\n", + binary_upgrade ? " " : ""); + + appendPQExpBuffer(buf, "ALTER DATABASE %s SET TABLESPACE %s;\n", + fdbname, fmtId(dbtablespace)); + + /* connect to original database */ + appendPQExpBuffer(buf, "%s\\connect %s\n", + binary_upgrade ? " " : "", fdbname); + } if (binary_upgrade) { |