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

Commit9136613

Browse files
committed
Add start/stop times for pg_dump/pg_dumpall when verbose output is used.
1 parente25a6e1 commit9136613

File tree

4 files changed

+66
-7
lines changed

4 files changed

+66
-7
lines changed

‎doc/src/sgml/ref/pg_dump.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.70 2004/05/31 13:37:52 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.71 2004/06/07 20:35:57 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -403,7 +403,8 @@ PostgreSQL documentation
403403
<para>
404404
Specifies verbose mode. This will cause
405405
<application>pg_dump</application> to output detailed object
406-
comments in the dump file, and progress messages to standard error.
406+
comments and start/stop times to the dump file, and progress
407+
messages to standard error.
407408
</para>
408409
</listitem>
409410
</varlistentry>

‎doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.43 2003/11/29 19:51:39 pgsql Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.44 2004/06/07 20:35:57 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -192,8 +192,9 @@ PostgreSQL documentation
192192
<listitem>
193193
<para>
194194
Specifies verbose mode. This will cause
195-
<application>pg_dumpall</application> to print progress
196-
messages to standard error.
195+
<application>pg_dumpall</application> to output start/stop
196+
times to the dump file, and progress messages to standard error.
197+
It will also enable verbose output in <application>pg_dump</>.
197198
</para>
198199
</listitem>
199200
</varlistentry>

‎src/bin/pg_dump/pg_dump.c

Lines changed: 38 additions & 1 deletion
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.373 2004/06/03 00:07:36 momjian Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.374 2004/06/07 20:35:57 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -32,6 +32,7 @@
3232
#ifdefHAVE_TERMIOS_H
3333
#include<termios.h>
3434
#endif
35+
#include<time.h>
3536

3637
#ifndefHAVE_STRDUP
3738
#include"strdup.h"
@@ -163,6 +164,7 @@ static char *myFormatType(const char *typname, int32 typmod);
163164
staticconstchar*fmtQualifiedId(constchar*schema,constchar*id);
164165
staticintdumpBlobs(Archive*AH,void*arg);
165166
staticvoiddumpDatabase(Archive*AH);
167+
staticvoiddumpTimestamp(Archive*AH,char*msg);
166168
staticvoiddumpEncoding(Archive*AH);
167169
staticconstchar*getAttrName(intattrnum,TableInfo*tblInfo);
168170
staticconstchar*fmtCopyColumnList(constTableInfo*ti);
@@ -598,6 +600,9 @@ main(int argc, char **argv)
598600
* in a safe order.
599601
*/
600602

603+
if (g_fout->verbose)
604+
dumpTimestamp(g_fout,"Started on");
605+
601606
/* First the special encoding entry. */
602607
dumpEncoding(g_fout);
603608

@@ -615,6 +620,9 @@ main(int argc, char **argv)
615620
dumpDumpableObject(g_fout,dobjs[i]);
616621
}
617622

623+
if (g_fout->verbose)
624+
dumpTimestamp(g_fout,"Completed on");
625+
618626
/*
619627
* And finally we can do the actual output.
620628
*/
@@ -1283,6 +1291,35 @@ dumpDatabase(Archive *AH)
12831291
}
12841292

12851293

1294+
/*
1295+
* dumpTimestamp
1296+
*/
1297+
staticvoid
1298+
dumpTimestamp(Archive*AH,char*msg)
1299+
{
1300+
charbuf[256];
1301+
time_tnow=time(NULL);
1302+
1303+
if (strftime(buf,256,"%Y-%m-%d %H:%M:%S %Z",localtime(&now))!=0)
1304+
{
1305+
PQExpBufferqry=createPQExpBuffer();
1306+
1307+
appendPQExpBuffer(qry,"-- ");
1308+
appendPQExpBuffer(qry,msg);
1309+
appendPQExpBuffer(qry," ");
1310+
appendPQExpBuffer(qry,buf);
1311+
appendPQExpBuffer(qry,"\n");
1312+
1313+
ArchiveEntry(AH,nilCatalogId,createDumpId(),
1314+
"DUMP TIMESTAMP",NULL,"",
1315+
false,"DUMP TIMESTAMP",qry->data,"",NULL,
1316+
NULL,0,
1317+
NULL,NULL);
1318+
destroyPQExpBuffer(qry);
1319+
}
1320+
}
1321+
1322+
12861323
/*
12871324
* dumpEncoding: put the correct encoding into the archive
12881325
*/

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.37 2004/06/05 04:27:48 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.38 2004/06/07 20:35:57 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -50,6 +50,7 @@ static void dumpDatabaseConfig(PGconn *conn, const char *dbname);
5050
staticvoiddumpUserConfig(PGconn*conn,constchar*username);
5151
staticvoidmakeAlterConfigCommand(constchar*arrayitem,constchar*type,constchar*name);
5252
staticvoiddumpDatabases(PGconn*conn);
53+
staticvoiddumpTimestamp(char*msg);
5354

5455
staticintrunPgDump(constchar*dbname);
5556
staticPGconn*connectDatabase(constchar*dbname,constchar*pghost,constchar*pgport,
@@ -220,6 +221,9 @@ main(int argc, char *argv[])
220221
conn=connectDatabase("template1",pghost,pgport,pguser,force_password);
221222

222223
printf("--\n-- PostgreSQL database cluster dump\n--\n\n");
224+
if (verbose)
225+
dumpTimestamp("Started on");
226+
223227
printf("\\connect \"template1\"\n\n");
224228

225229
if (!data_only)
@@ -237,6 +241,8 @@ main(int argc, char *argv[])
237241

238242
PQfinish(conn);
239243

244+
if (verbose)
245+
dumpTimestamp("Completed on");
240246
printf("--\n-- PostgreSQL database cluster dump complete\n--\n\n");
241247

242248
exit(0);
@@ -808,3 +814,17 @@ executeQuery(PGconn *conn, const char *query)
808814

809815
returnres;
810816
}
817+
818+
819+
/*
820+
* dumpTimestamp
821+
*/
822+
staticvoid
823+
dumpTimestamp(char*msg)
824+
{
825+
charbuf[256];
826+
time_tnow=time(NULL);
827+
828+
if (strftime(buf,256,"%Y-%m-%d %H:%M:%S %Z",localtime(&now))!=0)
829+
printf("-- %s %s\n\n",msg,buf);
830+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp