This has been saved for the 7.5 release:
http:/momjian.postgresql.org/cgi-bin/pgpatches2
I will probably merge those two options into a single option.
---------------------------------------------------------------------------
Jonathan Bartlett wrote:
> I have created a patch to postgresql 7.3.3 to make pg_dump more CVS
> friendly. Basically, pg_dump numbers all of it's TOC entries. Therefore,
> if you modify or recreate a view that used to be at the beginning, then
> ALL of your tables/indexes/etc get renumbered, which causes a lot of junk
> in your CVS.
>
> Anyway, the patch is at
>
> http://www.eskimo.com/~johnnyb/pgdump-cvs-patch.diff
>
> Comments welcome, but this is my first patch, so please be gentle :)
>
> Jon
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
diff -Naur postgresql-7.3.3/doc/src/sgml/backup.sgml postgresql-7.3.3-new/doc/src/sgml/backup.sgml
--- postgresql-7.3.3/doc/src/sgml/backup.sgml 2002-11-06 17:30:39.000000000 -0600
+++ postgresql-7.3.3-new/doc/src/sgml/backup.sgml 2003-07-04 09:58:31.000000000 -0500
@@ -92,6 +92,15 @@
</para>
</important>
+ <note>
+ <para>
+ If you are storing your schema dumps in CVS, using the -m -M
+ options will clean up your diffs from version to version by
+ omitting some of the SQL comments produced by Postgres that
+ number your entries.
+ </para>
+ </note>
+
<sect2 id="backup-dump-restore">
<title>Restoring the dump</title>
diff -Naur postgresql-7.3.3/src/bin/pg_dump/pg_backup_archiver.c
postgresql-7.3.3-new/src/bin/pg_dump/pg_backup_archiver.c
--- postgresql-7.3.3/src/bin/pg_dump/pg_backup_archiver.c 2003-05-03 17:19:18.000000000 -0500
+++ postgresql-7.3.3-new/src/bin/pg_dump/pg_backup_archiver.c 2003-07-04 10:17:10.000000000 -0500
@@ -72,6 +72,9 @@
static int _canRestoreBlobs(ArchiveHandle *AH);
static int _restoringToDB(ArchiveHandle *AH);
+bool should_print_oid_comment = true; /* These two control output to make it more suitable for CVS */
+bool should_print_toc_entry_comment = true;
+
/*
* Wrapper functions.
*
@@ -2216,10 +2219,21 @@
else
pfx = "";
- ahprintf(AH, "--\n-- %sTOC entry %d (OID %s)\n-- Name: %s; Type: %s; Schema: %s; Owner: %s\n",
- pfx, te->id, te->oid, te->tag, te->desc,
- te->namespace ? te->namespace : "-",
- te->owner);
+ ahprintf(AH, "--\n-- ");
+
+ if(should_print_toc_entry_comment)
+ {
+ ahprintf(AH, "%sTOC entry %d ", pfx, te->id);
+ }
+ if(should_print_oid_comment)
+ {
+ ahprintf(AH, "(OID %s)", te->oid);
+ }
+ ahprintf(AH, "\n-- Name %s; Type: %s; Schema: %s; Owner: %s\n",
+ te->tag, te->desc,
+ te->namespace ? te->namespace : "-",
+ te->owner);
+
if (AH->PrintExtraTocPtr !=NULL)
(*AH->PrintExtraTocPtr) (AH, te);
ahprintf(AH, "--\n\n");
diff -Naur postgresql-7.3.3/src/bin/pg_dump/pg_dump.c postgresql-7.3.3-new/src/bin/pg_dump/pg_dump.c
--- postgresql-7.3.3/src/bin/pg_dump/pg_dump.c 2003-05-16 08:57:03.000000000 -0500
+++ postgresql-7.3.3-new/src/bin/pg_dump/pg_dump.c 2003-07-04 10:20:07.000000000 -0500
@@ -201,6 +201,8 @@
{"column-inserts", no_argument, NULL, 'D'},
{"host", required_argument, NULL, 'h'},
{"ignore-version", no_argument, NULL, 'i'},
+ {"no-oid-comment", no_argument, NULL, 'm'},
+ {"no-toc-entry-comment", no_argument, NULL, 'M'},
{"no-reconnect", no_argument, NULL, 'R'},
{"oids", no_argument, NULL, 'o'},
{"no-owner", no_argument, NULL, 'O'},
@@ -270,9 +272,9 @@
}
#ifdef HAVE_GETOPT_LONG
- while ((c = getopt_long(argc, argv, "abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:", long_options, &optindex)) != -1)
+ while ((c = getopt_long(argc, argv, "abcCdDf:F:h:imMoOp:RsS:t:uU:vWxX:Z:", long_options, &optindex)) != -1)
#else
- while ((c = getopt(argc, argv, "abcCdDf:F:h:ioOp:RsS:t:uU:vWxX:Z:-")) != -1)
+ while ((c = getopt(argc, argv, "abcCdDf:F:h:imMoOp:RsS:t:uU:vWxX:Z:-")) != -1)
#endif
{
@@ -321,6 +323,13 @@
ignore_version = true;
break;
+ case 'm':
+ should_print_oid_comment = false;
+ break;
+
+ case 'M':
+ should_print_toc_entry_comment = false;
+ break;
case 'o': /* Dump oids */
oids = true;
break;
@@ -693,6 +704,8 @@
printf(_(" -o, --oids include OIDs in dump\n"));
printf(_(" -O, --no-owner do not output \\connect commands in plain\n"
" text format\n"));
+ printf(_(" -m, --no-oid-comments Don't print the OID comments (makes CVS easier)\n"));
+ printf(_(" -M, --no-toc-entry-comments Don't print the TOC comments (makes CVS easier)\n"));
printf(_(" -R, --no-reconnect disable ALL reconnections to the database in\n"
" plain text format\n"));
printf(_(" -s, --schema-only dump only the schema, no data\n"));
@@ -715,6 +728,8 @@
printf(_(" -o include OIDs in dump\n"));
printf(_(" -O do not output \\connect commands in plain\n"
" text format\n"));
+ printf(_(" -m, Don't print the OID comments (makes CVS easier)\n"));
+ printf(_(" -M, Don't print the TOC comments (makes CVS easier)\n"));
printf(_(" -R disable ALL reconnections to the database in\n"
" plain text format\n"));
printf(_(" -s dump only the schema, no data\n"));
diff -Naur postgresql-7.3.3/src/bin/pg_dump/pg_dump.h postgresql-7.3.3-new/src/bin/pg_dump/pg_dump.h
--- postgresql-7.3.3/src/bin/pg_dump/pg_dump.h 2002-10-09 11:20:25.000000000 -0500
+++ postgresql-7.3.3-new/src/bin/pg_dump/pg_dump.h 2003-07-04 09:46:32.000000000 -0500
@@ -167,6 +167,8 @@
extern bool force_quotes; /* double-quotes for identifiers flag */
extern bool g_verbose; /* verbose flag */
extern Archive *g_fout; /* the script file */
+extern bool should_print_oid_comment; /* these two make the output for palatable for CVS */
+extern bool should_print_toc_entry_comment;
/* placeholders for comment starting and ending delimiters */
extern char g_comment_start[10];
diff -Naur postgresql-7.3.3/src/bin/pg_dump/README postgresql-7.3.3-new/src/bin/pg_dump/README
--- postgresql-7.3.3/src/bin/pg_dump/README 2000-07-21 06:40:08.000000000 -0500
+++ postgresql-7.3.3-new/src/bin/pg_dump/README 2003-07-04 09:50:46.000000000 -0500
@@ -89,6 +89,19 @@
the BLOB files at the end.
+CVS
+===
+
+The pg_dump output is a plain text file. However, all entities in the dump
+are numbered within the contents. This makes using CVS problematic, as the
+numbers for all tables will change with each dump, even if the table itself
+did not change. To get output that is more suitable for CVS usage, add the
+flags -m -M which will disable printing the OID comments and the TOC entry
+comments. This will not affect re-importing the dumps at all, since this
+information was only printed on SQL comments.
+
+
+
Philip Warner, 16-Jul-2000
pjw@rhyme.com.au