Hey,
So I'm new to poking around in the PostgreSQL code, so this is a bit of
a shot in the dark. I'm having some problems with pg_dump, and a
database with tablespaces. A couple of the tables are not in the default
tablespace, and I want to ignore this for the dump.
Looking at the pg_dump --help, there seems to be a perfect option for
this:
--no-tablespaces do not dump tablespace assignments
This seems to work fine when using the plain text format, but I'm using
the custom format, and that seems to break the effect of
--no-tablespaces.
Looking at the code, I think I've managed to determine a place where
this behaviour can be changed, and so I've attached a draft patch [1].
Is this an actual problem, and if so, am I anywhere near the right place
in the code in terms of addressing it?
Thanks,
Chris
1:
From 124c10e3eb9f530a42bf294c95ee14b723ca2878 Mon Sep 17 00:00:00 2001
From: Christopher Baines <mail@cbaines.net>
Date: Fri, 15 May 2020 20:57:26 +0100
Subject: [PATCH] Fix pg_dump --no-tablespaces for the custom format
---
src/bin/pg_dump/pg_dump.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index f33c2463a7..ea35984a94 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -16412,7 +16412,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
ARCHIVE_OPTS(.tag = tbinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.tablespace = (tbinfo->relkind == RELKIND_VIEW) ?
- NULL : tbinfo->reltablespace,
+ NULL : (dopt->outputNoTablespaces ?
+ NULL : tbinfo->reltablespace),
.tableam = tableam,
.owner = tbinfo->rolname,
.description = reltypename,
--
2.26.2