OSDN Git Service

Fix patch for printing backend and pg_dump versions so that it works in
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Feb 2010 02:42:55 +0000 (02:42 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Feb 2010 02:42:55 +0000 (02:42 +0000)
a desirable fashion in archive-dump cases, ie you should get the pg_dump
version not the pg_restore version.

src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_db.c

index 1d32b9f..af29036 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *             $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.180 2010/02/23 21:48:32 momjian Exp $
+ *             $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.181 2010/02/24 02:42:54 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -304,15 +304,14 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
 
        if (AH->public.verbose)
        {
-               ahprintf(AH, "--\n-- pg_dump version: %s\n", PG_VERSION);
-               ahprintf(AH, "--\n-- remote database version: %s (%d)\n"
-                       ,AHX->remoteVersionStr
-                       ,AHX->remoteVersion) ;
-               ahprintf(AH, "--\n\n");
-       }
-
-       if (AH->public.verbose)
+               if (AH->archiveRemoteVersion)
+                       ahprintf(AH, "-- Dumped from database version %s\n",
+                                        AH->archiveRemoteVersion);
+               if (AH->archiveDumpVersion)
+                       ahprintf(AH, "-- Dumped by pg_dump version %s\n",
+                                        AH->archiveDumpVersion);
                dumpTimestamp(AH, "Started on", AH->createDate);
+       }
 
        if (ropt->single_txn)
        {
@@ -1860,6 +1859,8 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
        AH->public.exit_on_error = true;
        AH->public.n_errors = 0;
 
+       AH->archiveDumpVersion = PG_VERSION;
+
        AH->createDate = time(NULL);
 
        AH->intSize = sizeof(int);
@@ -3059,7 +3060,6 @@ ReadHead(ArchiveHandle *AH)
                AH->archiveRemoteVersion = ReadStr(AH);
                AH->archiveDumpVersion = ReadStr(AH);
        }
-
 }
 
 
index 1a9ddc9..37e6d20 100644 (file)
@@ -5,7 +5,7 @@
  *     Implements the basic DB functions used by the archiver.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.88 2010/02/18 01:29:10 tgl Exp $
+ *       $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.89 2010/02/24 02:42:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,6 +64,8 @@ _check_database_version(ArchiveHandle *AH)
 
        AH->public.remoteVersionStr = strdup(remoteversion_str);
        AH->public.remoteVersion = remoteversion;
+       if (!AH->archiveRemoteVersion)
+               AH->archiveRemoteVersion = AH->public.remoteVersionStr;
 
        if (myversion != remoteversion
                && (remoteversion < AH->public.minRemoteVersion ||