diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index bafa031..ca2136d 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -790,6 +790,15 @@ PostgreSQL documentation
+
+
+
+ Do not dump comments.
+
+
+
+
+
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 144068a..8806b8c 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -146,6 +146,7 @@ typedef struct _dumpOptions
int dump_inserts;
int column_inserts;
int if_exists;
+ int no_comments;
int no_security_labels;
int no_publications;
int no_subscriptions;
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 502d5eb..53c2095 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -351,6 +351,7 @@ main(int argc, char **argv)
{"snapshot", required_argument, NULL, 6},
{"strict-names", no_argument, &strict_names, 1},
{"use-set-session-authorization", no_argument, &dopt.use_setsessauth, 1},
+ {"no-comments", no_argument, &dopt.no_comments, 1},
{"no-publications", no_argument, &dopt.no_publications, 1},
{"no-security-labels", no_argument, &dopt.no_security_labels, 1},
{"no-synchronized-snapshots", no_argument, &dopt.no_synchronized_snapshots, 1},
@@ -952,6 +953,7 @@ help(const char *progname)
printf(_(" --exclude-table-data=TABLE do NOT dump data for the named table(s)\n"));
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
+ printf(_(" --no-comments do not dump comments\n"));
printf(_(" --no-publications do not dump publications\n"));
printf(_(" --no-security-labels do not dump security label assignments\n"));
printf(_(" --no-subscriptions do not dump subscriptions\n"));
@@ -2711,8 +2713,9 @@ dumpDatabase(Archive *fout)
destroyPQExpBuffer(loOutQry);
}
- /* Dump DB comment if any */
- if (fout->remoteVersion >= 80200)
+
+ /* Dump DB comment if any, and if --no-comments is not supplied */
+ if (fout->remoteVersion >= 80200 && !dopt->no_comments)
{
/*
* 8.2 keeps comments on shared objects in a shared table, so we
@@ -9073,6 +9076,10 @@ dumpComment(Archive *fout, const char *target,
return;
}
+ /* do nothing, if --no-comments is supplied */
+ if (dopt->no_comments)
+ return;
+
/* Search for comments associated with catalogId, using table */
ncomments = findComments(fout, catalogId.tableoid, catalogId.oid,
&comments);
@@ -9131,6 +9138,10 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
if (dopt->dataOnly)
return;
+ /* do nothing, if --no-comments is supplied */
+ if (dopt->no_comments)
+ return;
+
/* Search for comments associated with relation, using table */
ncomments = findComments(fout,
tbinfo->dobj.catId.tableoid,
@@ -10778,6 +10789,10 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo)
int i_attname;
int i_attnum;
+ /* do nothing, if --no-comments is supplied */
+ if (fout->dopt->no_comments)
+ return;
+
query = createPQExpBuffer();
appendPQExpBuffer(query,
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index b14bb8e..5465295 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -74,6 +74,7 @@ static int if_exists = 0;
static int inserts = 0;
static int no_tablespaces = 0;
static int use_setsessauth = 0;
+static int no_comments = 0;
static int no_publications = 0;
static int no_security_labels = 0;
static int no_subscriptions = 0;
@@ -130,6 +131,7 @@ main(int argc, char *argv[])
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"role", required_argument, NULL, 3},
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
+ {"no-comments", no_argument, &no_comments, 1},
{"no-publications", no_argument, &no_publications, 1},
{"no-role-passwords", no_argument, &no_role_passwords, 1},
{"no-security-labels", no_argument, &no_security_labels, 1},
@@ -387,6 +389,8 @@ main(int argc, char *argv[])
appendPQExpBufferStr(pgdumpopts, " --quote-all-identifiers");
if (use_setsessauth)
appendPQExpBufferStr(pgdumpopts, " --use-set-session-authorization");
+ if (no_comments)
+ appendPQExpBufferStr(pgdumpopts, " --no-comments");
if (no_publications)
appendPQExpBufferStr(pgdumpopts, " --no-publications");
if (no_security_labels)
@@ -598,6 +602,7 @@ help(void)
printf(_(" --disable-triggers disable triggers during data-only restore\n"));
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
+ printf(_(" --no-comments do not dump comments\n"));
printf(_(" --no-publications do not dump publications\n"));
printf(_(" --no-role-passwords do not dump passwords for roles\n"));
printf(_(" --no-security-labels do not dump security label assignments\n"));
@@ -905,7 +910,7 @@ dumpRoles(PGconn *conn)
appendPQExpBufferStr(buf, ";\n");
- if (!PQgetisnull(res, i, i_rolcomment))
+ if (!no_comments && !PQgetisnull(res, i, i_rolcomment))
{
appendPQExpBuffer(buf, "COMMENT ON ROLE %s IS ", fmtId(rolename));
appendStringLiteralConn(buf, PQgetvalue(res, i, i_rolcomment), conn);
@@ -1211,7 +1216,7 @@ dumpTablespaces(PGconn *conn)
exit_nicely(1);
}
- if (spccomment && strlen(spccomment))
+ if (!no_comments && spccomment && strlen(spccomment))
{
appendPQExpBuffer(buf, "COMMENT ON TABLESPACE %s IS ", fspcname);
appendStringLiteralConn(buf, spccomment, conn);