Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit348f856

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 withreality). Instead just print out the desired strings where RestoreArchivewas already emitting the 'PostgreSQL database dump' and'PostgreSQL database dump complete' strings.
1 parent3fa7901 commit348f856

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
staticint_canRestoreBlobs(ArchiveHandle*AH);
7474
staticint_restoringToDB(ArchiveHandle*AH);
7575

76+
staticvoiddumpTimestamp(ArchiveHandle*AH,constchar*msg,time_ttim);
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
teReqsreqs;
134136
OutputContextsav;
135137
booldefnDumped;
@@ -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
returntrue;
27682770
}
2771+
2772+
2773+
/*
2774+
* dumpTimestamp
2775+
*/
2776+
staticvoid
2777+
dumpTimestamp(ArchiveHandle*AH,constchar*msg,time_ttim)
2778+
{
2779+
charbuf[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
#ifdefHAVE_TERMIOS_H
3333
#include<termios.h>
3434
#endif
35-
#include<time.h>
3635

3736
#ifndefHAVE_STRDUP
3837
#include"strdup.h"
@@ -166,7 +165,6 @@ static char *myFormatType(const char *typname, int32 typmod);
166165
staticconstchar*fmtQualifiedId(constchar*schema,constchar*id);
167166
staticintdumpBlobs(Archive*AH,void*arg);
168167
staticvoiddumpDatabase(Archive*AH);
169-
staticvoiddumpTimestamp(Archive*AH,char*msg);
170168
staticvoiddumpEncoding(Archive*AH);
171169
staticconstchar*getAttrName(intattrnum,TableInfo*tblInfo);
172170
staticconstchar*fmtCopyColumnList(constTableInfo*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-
staticvoid
1307-
dumpTimestamp(Archive*AH,char*msg)
1308-
{
1309-
charbuf[256];
1310-
time_tnow=time(NULL);
1311-
1312-
if (strftime(buf,256,"%Y-%m-%d %H:%M:%S %Z",localtime(&now))!=0)
1313-
{
1314-
PQExpBufferqry=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)

[8]ページ先頭

©2009-2025 Movatter.jp