Commit 348f856d authored by Tom Lane's avatar Tom Lane

Revert addition of poorly-thought-out DUMP TIMESTAMP archive entry,

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.
parent 3fa79010
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.106 2005/03/18 17:32:55 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.107 2005/04/15 16:40:36 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -73,6 +73,8 @@ static void _die_horribly(ArchiveHandle *AH, const char *modulename, const char ...@@ -73,6 +73,8 @@ static void _die_horribly(ArchiveHandle *AH, const char *modulename, const char
static int _canRestoreBlobs(ArchiveHandle *AH); static int _canRestoreBlobs(ArchiveHandle *AH);
static int _restoringToDB(ArchiveHandle *AH); static int _restoringToDB(ArchiveHandle *AH);
static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim);
/* /*
* Wrapper functions. * Wrapper functions.
...@@ -129,7 +131,7 @@ void ...@@ -129,7 +131,7 @@ void
RestoreArchive(Archive *AHX, RestoreOptions *ropt) RestoreArchive(Archive *AHX, RestoreOptions *ropt)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
TocEntry *te = AH->toc->next; TocEntry *te;
teReqs reqs; teReqs reqs;
OutputContext sav; OutputContext sav;
bool defnDumped; bool defnDumped;
...@@ -210,6 +212,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -210,6 +212,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n"); 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. * Establish important parameter values right away.
*/ */
...@@ -222,11 +227,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -222,11 +227,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
*/ */
if (ropt->dropSchema) if (ropt->dropSchema)
{ {
te = AH->toc->prev; for (te = AH->toc->prev; te != AH->toc; te = te->prev)
{
AH->currentTE = te; AH->currentTE = te;
while (te != AH->toc)
{
reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */); reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */);
if (((reqs & REQ_SCHEMA) != 0) && te->dropStmt) if (((reqs & REQ_SCHEMA) != 0) && te->dropStmt)
{ {
...@@ -238,15 +242,13 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -238,15 +242,13 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/* Drop it */ /* Drop it */
ahprintf(AH, "%s", te->dropStmt); ahprintf(AH, "%s", te->dropStmt);
} }
te = te->prev;
} }
} }
/* /*
* Now process each non-ACL TOC entry * Now process each non-ACL TOC entry
*/ */
te = AH->toc->next; for (te = AH->toc->next; te != AH->toc; te = te->next)
while (te != AH->toc)
{ {
AH->currentTE = te; AH->currentTE = te;
...@@ -376,14 +378,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -376,14 +378,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
_printTocEntry(AH, te, ropt, false, false); _printTocEntry(AH, te, ropt, false, false);
} }
} }
te = te->next;
} /* end loop over TOC entries */ } /* end loop over TOC entries */
/* /*
* Scan TOC again to output ownership commands and ACLs * Scan TOC again to output ownership commands and ACLs
*/ */
te = AH->toc->next; for (te = AH->toc->next; te != AH->toc; te = te->next)
while (te != AH->toc)
{ {
AH->currentTE = te; AH->currentTE = te;
...@@ -396,10 +396,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -396,10 +396,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
te->desc, te->tag); te->desc, te->tag);
_printTocEntry(AH, te, ropt, false, true); _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"); ahprintf(AH, "--\n-- PostgreSQL database dump complete\n--\n\n");
/* /*
...@@ -1275,7 +1276,8 @@ warn_or_die_horribly(ArchiveHandle *AH, ...@@ -1275,7 +1276,8 @@ warn_or_die_horribly(ArchiveHandle *AH,
} }
if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE) 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->catalogId.tableoid, AH->currentTE->catalogId.oid,
AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner); AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
} }
...@@ -2766,3 +2768,16 @@ checkSeek(FILE *fp) ...@@ -2766,3 +2768,16 @@ checkSeek(FILE *fp)
else else
return true; 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);
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.406 2005/04/12 04:26:27 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.407 2005/04/15 16:40:36 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
#include <termios.h> #include <termios.h>
#endif #endif
#include <time.h>
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
#include "strdup.h" #include "strdup.h"
...@@ -166,7 +165,6 @@ static char *myFormatType(const char *typname, int32 typmod); ...@@ -166,7 +165,6 @@ static char *myFormatType(const char *typname, int32 typmod);
static const char *fmtQualifiedId(const char *schema, const char *id); static const char *fmtQualifiedId(const char *schema, const char *id);
static int dumpBlobs(Archive *AH, void *arg); static int dumpBlobs(Archive *AH, void *arg);
static void dumpDatabase(Archive *AH); static void dumpDatabase(Archive *AH);
static void dumpTimestamp(Archive *AH, char *msg);
static void dumpEncoding(Archive *AH); static void dumpEncoding(Archive *AH);
static const char *getAttrName(int attrnum, TableInfo *tblInfo); static const char *getAttrName(int attrnum, TableInfo *tblInfo);
static const char *fmtCopyColumnList(const TableInfo *ti); static const char *fmtCopyColumnList(const TableInfo *ti);
...@@ -603,9 +601,6 @@ main(int argc, char **argv) ...@@ -603,9 +601,6 @@ main(int argc, char **argv)
* safe order. * safe order.
*/ */
if (g_fout->verbose)
dumpTimestamp(g_fout, "Started on");
/* First the special encoding entry. */ /* First the special encoding entry. */
dumpEncoding(g_fout); dumpEncoding(g_fout);
...@@ -621,9 +616,6 @@ main(int argc, char **argv) ...@@ -621,9 +616,6 @@ main(int argc, char **argv)
for (i = 0; i < numObjs; i++) for (i = 0; i < numObjs; i++)
dumpDumpableObject(g_fout, dobjs[i]); dumpDumpableObject(g_fout, dobjs[i]);
if (g_fout->verbose)
dumpTimestamp(g_fout, "Completed on");
/* /*
* And finally we can do the actual output. * And finally we can do the actual output.
*/ */
...@@ -638,6 +630,7 @@ main(int argc, char **argv) ...@@ -638,6 +630,7 @@ main(int argc, char **argv)
ropt->noOwner = outputNoOwner; ropt->noOwner = outputNoOwner;
ropt->disable_triggers = disable_triggers; ropt->disable_triggers = disable_triggers;
ropt->use_setsessauth = use_setsessauth; ropt->use_setsessauth = use_setsessauth;
ropt->dataOnly = dataOnly;
if (compressLevel == -1) if (compressLevel == -1)
ropt->compression = 0; ropt->compression = 0;
...@@ -1300,35 +1293,6 @@ dumpDatabase(Archive *AH) ...@@ -1300,35 +1293,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 * dumpEncoding: put the correct encoding into the archive
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment