diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index bb0bf5d..8d9b533 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 1b47baa..dc1fb92 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 053ae0e..a5b6c8d 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 @@ -9068,6 +9071,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); @@ -9126,6 +9133,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, @@ -10773,6 +10784,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,