summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/pg_dump/pg_dumpall.c11
-rw-r--r--src/bin/pg_dump/t/002_pg_dump.pl16
2 files changed, 26 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 0ab52ca81d7..e2a9733d348 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -1286,7 +1286,16 @@ dumpTablespaces(PGconn *conn)
appendPQExpBuffer(buf, " OWNER %s", fmtId(spcowner));
appendPQExpBufferStr(buf, " LOCATION ");
- appendStringLiteralConn(buf, spclocation, conn);
+
+ /*
+ * In-place tablespaces use a relative path, and need to be dumped
+ * with an empty string as location.
+ */
+ if (is_absolute_path(spclocation))
+ appendStringLiteralConn(buf, spclocation, conn);
+ else
+ appendStringLiteralConn(buf, "", conn);
+
appendPQExpBufferStr(buf, ";\n");
if (spcoptions && spcoptions[0] != '\0')
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 0efeb3367d5..6ad83102874 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -1907,6 +1907,22 @@ my %tests = (
},
},
+ 'CREATE TABLESPACE regress_dump_tablespace' => {
+ create_order => 2,
+ create_sql => q(
+ SET allow_in_place_tablespaces = on;
+ CREATE TABLESPACE regress_dump_tablespace
+ OWNER regress_dump_test_role LOCATION ''),
+ regexp =>
+ qr/^CREATE TABLESPACE regress_dump_tablespace OWNER regress_dump_test_role LOCATION '';/m,
+ like => {
+ pg_dumpall_dbprivs => 1,
+ pg_dumpall_exclude => 1,
+ pg_dumpall_globals => 1,
+ pg_dumpall_globals_clean => 1,
+ },
+ },
+
'CREATE DATABASE regression_invalid...' => {
create_order => 1,
create_sql => q(