Hello,
While poking around the dump output, I noticed some unrelated points:
* Command "pg_dump" could tell which database is dumped in the output
Or "pg_dumpall" could issue a comment line in the output telling which
database is being considered.
* The database dumps should have an introductory comment, like there
is one for roles
I agree these are unrelated but would be nice to have. Probably having
pg_dumpall do it would be better. Do you want to do a patch for that?
I do not "want" to do a patch for that:-) Anyway, a small patch is
attached which adds comments to pg_dumpall output sections.
* On extensions, the dump creates both the extension and the extension
comment. However, ISTM that the extension comment is already created
by the extension, so this is redundant:
Maybe it should notice that the comment belongs to the extension and
need not be updated?
What if the owner had updated the comment after installing the extension?
Hmmm… This point could apply to anything related to an extension, which
could be altered by the owner in any way…
--
Fabien.
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 5176626476..021df03250 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -1312,6 +1312,7 @@ dumpUserConfig(PGconn *conn, const char *username)
{
PQExpBuffer buf = createPQExpBuffer();
int count = 1;
+ bool first = true;
for (;;)
{
@@ -1333,6 +1334,14 @@ dumpUserConfig(PGconn *conn, const char *username)
if (PQntuples(res) == 1 &&
!PQgetisnull(res, 0, 0))
{
+ /* comment at section start, only if needed */
+ if (first)
+ {
+ fprintf(OPF, "--\n-- User Configurations\n--\n\n");
+ first = false;
+ }
+
+ fprintf(OPF, "--\n-- User Config \"%s\"\n--\n\n", username);
resetPQExpBuffer(buf);
makeAlterConfigCommand(conn, PQgetvalue(res, 0, 0),
"ROLE", username, NULL, NULL,
@@ -1378,6 +1387,9 @@ dumpDatabases(PGconn *conn)
"WHERE datallowconn "
"ORDER BY (datname <> 'template1'), datname");
+ if (PQntuples(res) > 0)
+ fprintf(OPF, "--\n-- Databases\n--\n\n");
+
for (i = 0; i < PQntuples(res); i++)
{
char *dbname = PQgetvalue(res, i, 0);
@@ -1391,6 +1403,8 @@ dumpDatabases(PGconn *conn)
if (verbose)
fprintf(stderr, _("%s: dumping database \"%s\"...\n"), progname, dbname);
+ fprintf(OPF, "--\n-- Database \"%s\" dump\n--\n\n", dbname);
+
/*
* We assume that "template1" and "postgres" already exist in the
* target installation. dropDBs() won't have removed them, for fear