]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Revert addition of poorly-thought-out DUMP TIMESTAMP archive entry,
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 Apr 2005 16:40:59 +0000 (16:40 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 Apr 2005 16:40:59 +0000 (16:40 +0000)
which induced bug #1597 in addition to having several other misbehaviors
(like labeling the dump with a completion time having nothing to do with
reality).  Instead just print out the desired strings where RestoreArchive
was already emitting the 'PostgreSQL database dump' and
'PostgreSQL database dump complete' strings.

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

index 32ed1eac76714e4e84f6c9ec615c8853e4e671f6..efa810fdf1ace681971dba3bc4bb7644f1022a46 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *             $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101.4.4 2005/03/18 17:33:03 tgl Exp $
+ *             $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101.4.5 2005/04/15 16:40:59 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -73,6 +73,8 @@ static void _die_horribly(ArchiveHandle *AH, const char *modulename, const char
 static int     _canRestoreBlobs(ArchiveHandle *AH);
 static int     _restoringToDB(ArchiveHandle *AH);
 
+static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim);
+
 
 /*
  *     Wrapper functions.
@@ -129,7 +131,7 @@ void
 RestoreArchive(Archive *AHX, RestoreOptions *ropt)
 {
        ArchiveHandle *AH = (ArchiveHandle *) AHX;
-       TocEntry   *te = AH->toc->next;
+       TocEntry   *te;
        teReqs          reqs;
        OutputContext sav;
        bool            defnDumped;
@@ -210,6 +212,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
 
        ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");
 
+       if (AH->public.verbose)
+               dumpTimestamp(AH, "Started on", AH->createDate);
+
        /*
         * Establish important parameter values right away.
         */
@@ -222,11 +227,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
         */
        if (ropt->dropSchema)
        {
-               te = AH->toc->prev;
-               AH->currentTE = te;
-
-               while (te != AH->toc)
+               for (te = AH->toc->prev; te != AH->toc; te = te->prev)
                {
+                       AH->currentTE = te;
+
                        reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */);
                        if (((reqs & REQ_SCHEMA) != 0) && te->dropStmt)
                        {
@@ -238,15 +242,13 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
                                /* Drop it */
                                ahprintf(AH, "%s", te->dropStmt);
                        }
-                       te = te->prev;
                }
        }
 
        /*
         * Now process each non-ACL TOC entry
         */
-       te = AH->toc->next;
-       while (te != AH->toc)
+       for (te = AH->toc->next; te != AH->toc; te = te->next)
        {
                AH->currentTE = te;
 
@@ -376,14 +378,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
                                _printTocEntry(AH, te, ropt, false, false);
                        }
                }
-               te = te->next;
        }                                                       /* end loop over TOC entries */
 
        /*
         * Scan TOC again to output ownership commands and ACLs
         */
-       te = AH->toc->next;
-       while (te != AH->toc)
+       for (te = AH->toc->next; te != AH->toc; te = te->next)
        {
                AH->currentTE = te;
 
@@ -396,10 +396,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
                                  te->desc, te->tag);
                        _printTocEntry(AH, te, ropt, false, true);
                }
-
-               te = te->next;
        }
 
+       if (AH->public.verbose)
+               dumpTimestamp(AH, "Completed on", time(NULL));
+
        ahprintf(AH, "--\n-- PostgreSQL database dump complete\n--\n\n");
 
        /*
@@ -1275,7 +1276,8 @@ warn_or_die_horribly(ArchiveHandle *AH,
        }
        if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE)
        {
-               write_msg(modulename, "Error from TOC entry %d; %u %u %s %s %s\n", AH->currentTE->dumpId,
+               write_msg(modulename, "Error from TOC entry %d; %u %u %s %s %s\n",
+                                 AH->currentTE->dumpId,
                 AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
                  AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
        }
@@ -2766,3 +2768,16 @@ checkSeek(FILE *fp)
        else
                return true;
 }
+
+
+/*
+ * dumpTimestamp
+ */
+static void
+dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)
+{
+       char            buf[256];
+
+       if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&tim)) != 0)
+               ahprintf(AH, "-- %s %s\n\n", msg, buf);
+}
index d28e235e61985fb5371c18caa05aed90045d948e..0f088a7ec1d77a81c391c0742f3448449415f572 100644 (file)
@@ -12,7 +12,7 @@
  *     by PostgreSQL
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.400.4.2 2005/01/26 21:24:27 tgl Exp $
+ *       $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.400.4.3 2005/04/15 16:40:59 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,7 +32,6 @@
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #endif
-#include <time.h>
 
 #ifndef HAVE_STRDUP
 #include "strdup.h"
@@ -165,7 +164,6 @@ static char *myFormatType(const char *typname, int32 typmod);
 static const char *fmtQualifiedId(const char *schema, const char *id);
 static int     dumpBlobs(Archive *AH, void *arg);
 static void dumpDatabase(Archive *AH);
-static void dumpTimestamp(Archive *AH, char *msg);
 static void dumpEncoding(Archive *AH);
 static const char *getAttrName(int attrnum, TableInfo *tblInfo);
 static const char *fmtCopyColumnList(const TableInfo *ti);
@@ -602,9 +600,6 @@ main(int argc, char **argv)
         * safe order.
         */
 
-       if (g_fout->verbose)
-               dumpTimestamp(g_fout, "Started on");
-
        /* First the special encoding entry. */
        dumpEncoding(g_fout);
 
@@ -620,9 +615,6 @@ main(int argc, char **argv)
        for (i = 0; i < numObjs; i++)
                dumpDumpableObject(g_fout, dobjs[i]);
 
-       if (g_fout->verbose)
-               dumpTimestamp(g_fout, "Completed on");
-
        /*
         * And finally we can do the actual output.
         */
@@ -637,6 +629,7 @@ main(int argc, char **argv)
                ropt->noOwner = outputNoOwner;
                ropt->disable_triggers = disable_triggers;
                ropt->use_setsessauth = use_setsessauth;
+               ropt->dataOnly = dataOnly;
 
                if (compressLevel == -1)
                        ropt->compression = 0;
@@ -1299,35 +1292,6 @@ dumpDatabase(Archive *AH)
 }
 
 
-/*
- * dumpTimestamp
- */
-static void
-dumpTimestamp(Archive *AH, char *msg)
-{
-       char            buf[256];
-       time_t          now = time(NULL);
-
-       if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
-       {
-               PQExpBuffer qry = createPQExpBuffer();
-
-               appendPQExpBuffer(qry, "-- ");
-               appendPQExpBuffer(qry, msg);
-               appendPQExpBuffer(qry, " ");
-               appendPQExpBuffer(qry, buf);
-               appendPQExpBuffer(qry, "\n");
-
-               ArchiveEntry(AH, nilCatalogId, createDumpId(),
-                                        "DUMP TIMESTAMP", NULL, NULL, "",
-                                        false, "DUMP TIMESTAMP", qry->data, "", NULL,
-                                        NULL, 0,
-                                        NULL, NULL);
-               destroyPQExpBuffer(qry);
-       }
-}
-
-
 /*
  * dumpEncoding: put the correct encoding into the archive
  */