Skip to content

Commit 6cbdbd9

Browse files
committed
Add extra descriptive headings in pg_dumpall
Headings are added for the User Configurations and Databases sections, and for each user configuration and database in the output. Author: Fabien Coelho Discussion: https://postgr.es/m/alpine.DEB.2.21.1812272222130.32444@lancre
1 parent f092de0 commit 6cbdbd9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/bin/pg_dump/pg_dumpall.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ dumpUserConfig(PGconn *conn, const char *username)
13461346
{
13471347
PQExpBuffer buf = createPQExpBuffer();
13481348
int count = 1;
1349+
bool first = true;
13491350

13501351
for (;;)
13511352
{
@@ -1367,6 +1368,14 @@ dumpUserConfig(PGconn *conn, const char *username)
13671368
if (PQntuples(res) == 1 &&
13681369
!PQgetisnull(res, 0, 0))
13691370
{
1371+
/* comment at section start, only if needed */
1372+
if (first)
1373+
{
1374+
fprintf(OPF, "--\n-- User Configurations\n--\n\n");
1375+
first = false;
1376+
}
1377+
1378+
fprintf(OPF, "--\n-- User Config \"%s\"\n--\n\n", username);
13701379
resetPQExpBuffer(buf);
13711380
makeAlterConfigCommand(conn, PQgetvalue(res, 0, 0),
13721381
"ROLE", username, NULL, NULL,
@@ -1454,6 +1463,9 @@ dumpDatabases(PGconn *conn)
14541463
"WHERE datallowconn "
14551464
"ORDER BY (datname <> 'template1'), datname");
14561465

1466+
if (PQntuples(res) > 0)
1467+
fprintf(OPF, "--\n-- Databases\n--\n\n");
1468+
14571469
for (i = 0; i < PQntuples(res); i++)
14581470
{
14591471
char *dbname = PQgetvalue(res, i, 0);
@@ -1476,6 +1488,8 @@ dumpDatabases(PGconn *conn)
14761488
if (verbose)
14771489
fprintf(stderr, _("%s: dumping database \"%s\"...\n"), progname, dbname);
14781490

1491+
fprintf(OPF, "--\n-- Database \"%s\" dump\n--\n\n", dbname);
1492+
14791493
/*
14801494
* We assume that "template1" and "postgres" already exist in the
14811495
* target installation. dropDBs() won't have removed them, for fear

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy