Skip to content

Commit 348f856

Browse files
committed
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.
1 parent 3fa7901 commit 348f856

File tree

2 files changed

+32
-53
lines changed

2 files changed

+32
-53
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.106 2005/03/18 17:32:55 tgl Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.107 2005/04/15 16:40:36 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -73,6 +73,8 @@ static void _die_horribly(ArchiveHandle *AH, const char *modulename, const char
7373
static int _canRestoreBlobs(ArchiveHandle *AH);
7474
static int _restoringToDB(ArchiveHandle *AH);
7575

76+
static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim);
77+
7678

7779
/*
7880
* Wrapper functions.
@@ -129,7 +131,7 @@ void
129131
RestoreArchive(Archive *AHX, RestoreOptions *ropt)
130132
{
131133
ArchiveHandle *AH = (ArchiveHandle *) AHX;
132-
TocEntry *te = AH->toc->next;
134+
TocEntry *te;
133135
teReqs reqs;
134136
OutputContext sav;
135137
bool defnDumped;
@@ -210,6 +212,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
210212

211213
ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");
212214

215+
if (AH->public.verbose)
216+
dumpTimestamp(AH, "Started on", AH->createDate);
217+
213218
/*
214219
* Establish important parameter values right away.
215220
*/
@@ -222,11 +227,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
222227
*/
223228
if (ropt->dropSchema)
224229
{
225-
te = AH->toc->prev;
226-
AH->currentTE = te;
227-
228-
while (te != AH->toc)
230+
for (te = AH->toc->prev; te != AH->toc; te = te->prev)
229231
{
232+
AH->currentTE = te;
233+
230234
reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */);
231235
if (((reqs & REQ_SCHEMA) != 0) && te->dropStmt)
232236
{
@@ -238,15 +242,13 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
238242
/* Drop it */
239243
ahprintf(AH, "%s", te->dropStmt);
240244
}
241-
te = te->prev;
242245
}
243246
}
244247

245248
/*
246249
* Now process each non-ACL TOC entry
247250
*/
248-
te = AH->toc->next;
249-
while (te != AH->toc)
251+
for (te = AH->toc->next; te != AH->toc; te = te->next)
250252
{
251253
AH->currentTE = te;
252254

@@ -376,14 +378,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
376378
_printTocEntry(AH, te, ropt, false, false);
377379
}
378380
}
379-
te = te->next;
380381
} /* end loop over TOC entries */
381382

382383
/*
383384
* Scan TOC again to output ownership commands and ACLs
384385
*/
385-
te = AH->toc->next;
386-
while (te != AH->toc)
386+
for (te = AH->toc->next; te != AH->toc; te = te->next)
387387
{
388388
AH->currentTE = te;
389389

@@ -396,10 +396,11 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
396396
te->desc, te->tag);
397397
_printTocEntry(AH, te, ropt, false, true);
398398
}
399-
400-
te = te->next;
401399
}
402400

401+
if (AH->public.verbose)
402+
dumpTimestamp(AH, "Completed on", time(NULL));
403+
403404
ahprintf(AH, "--\n-- PostgreSQL database dump complete\n--\n\n");
404405

405406
/*
@@ -1275,7 +1276,8 @@ warn_or_die_horribly(ArchiveHandle *AH,
12751276
}
12761277
if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE)
12771278
{
1278-
write_msg(modulename, "Error from TOC entry %d; %u %u %s %s %s\n", AH->currentTE->dumpId,
1279+
write_msg(modulename, "Error from TOC entry %d; %u %u %s %s %s\n",
1280+
AH->currentTE->dumpId,
12791281
AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
12801282
AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
12811283
}
@@ -2766,3 +2768,16 @@ checkSeek(FILE *fp)
27662768
else
27672769
return true;
27682770
}
2771+
2772+
2773+
/*
2774+
* dumpTimestamp
2775+
*/
2776+
static void
2777+
dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)
2778+
{
2779+
char buf[256];
2780+
2781+
if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&tim)) != 0)
2782+
ahprintf(AH, "-- %s %s\n\n", msg, buf);
2783+
}

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.406 2005/04/12 04:26:27 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.407 2005/04/15 16:40:36 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -32,7 +32,6 @@
3232
#ifdef HAVE_TERMIOS_H
3333
#include <termios.h>
3434
#endif
35-
#include <time.h>
3635

3736
#ifndef HAVE_STRDUP
3837
#include "strdup.h"
@@ -166,7 +165,6 @@ static char *myFormatType(const char *typname, int32 typmod);
166165
static const char *fmtQualifiedId(const char *schema, const char *id);
167166
static int dumpBlobs(Archive *AH, void *arg);
168167
static void dumpDatabase(Archive *AH);
169-
static void dumpTimestamp(Archive *AH, char *msg);
170168
static void dumpEncoding(Archive *AH);
171169
static const char *getAttrName(int attrnum, TableInfo *tblInfo);
172170
static const char *fmtCopyColumnList(const TableInfo *ti);
@@ -603,9 +601,6 @@ main(int argc, char **argv)
603601
* safe order.
604602
*/
605603

606-
if (g_fout->verbose)
607-
dumpTimestamp(g_fout, "Started on");
608-
609604
/* First the special encoding entry. */
610605
dumpEncoding(g_fout);
611606

@@ -621,9 +616,6 @@ main(int argc, char **argv)
621616
for (i = 0; i < numObjs; i++)
622617
dumpDumpableObject(g_fout, dobjs[i]);
623618

624-
if (g_fout->verbose)
625-
dumpTimestamp(g_fout, "Completed on");
626-
627619
/*
628620
* And finally we can do the actual output.
629621
*/
@@ -638,6 +630,7 @@ main(int argc, char **argv)
638630
ropt->noOwner = outputNoOwner;
639631
ropt->disable_triggers = disable_triggers;
640632
ropt->use_setsessauth = use_setsessauth;
633+
ropt->dataOnly = dataOnly;
641634

642635
if (compressLevel == -1)
643636
ropt->compression = 0;
@@ -1300,35 +1293,6 @@ dumpDatabase(Archive *AH)
13001293
}
13011294

13021295

1303-
/*
1304-
* dumpTimestamp
1305-
*/
1306-
static void
1307-
dumpTimestamp(Archive *AH, char *msg)
1308-
{
1309-
char buf[256];
1310-
time_t now = time(NULL);
1311-
1312-
if (strftime(buf, 256, "%Y-%m-%d %H:%M:%S %Z", localtime(&now)) != 0)
1313-
{
1314-
PQExpBuffer qry = createPQExpBuffer();
1315-
1316-
appendPQExpBuffer(qry, "-- ");
1317-
appendPQExpBuffer(qry, msg);
1318-
appendPQExpBuffer(qry, " ");
1319-
appendPQExpBuffer(qry, buf);
1320-
appendPQExpBuffer(qry, "\n");
1321-
1322-
ArchiveEntry(AH, nilCatalogId, createDumpId(),
1323-
"DUMP TIMESTAMP", NULL, NULL, "",
1324-
false, "DUMP TIMESTAMP", qry->data, "", NULL,
1325-
NULL, 0,
1326-
NULL, NULL);
1327-
destroyPQExpBuffer(qry);
1328-
}
1329-
}
1330-
1331-
13321296
/*
13331297
* dumpEncoding: put the correct encoding into the archive
13341298
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy