mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Add start/stop times for pg_dump/pg_dumpall when verbose output is used.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* by PostgreSQL
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.373 2004/06/03 00:07:36 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.374 2004/06/07 20:35:57 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -32,6 +32,7 @@
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
#include "strdup.h"
|
||||
@@ -163,6 +164,7 @@ 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);
|
||||
@@ -598,6 +600,9 @@ main(int argc, char **argv)
|
||||
* in a safe order.
|
||||
*/
|
||||
|
||||
if (g_fout->verbose)
|
||||
dumpTimestamp(g_fout, "Started on");
|
||||
|
||||
/* First the special encoding entry. */
|
||||
dumpEncoding(g_fout);
|
||||
|
||||
@@ -615,6 +620,9 @@ main(int argc, char **argv)
|
||||
dumpDumpableObject(g_fout, dobjs[i]);
|
||||
}
|
||||
|
||||
if (g_fout->verbose)
|
||||
dumpTimestamp(g_fout, "Completed on");
|
||||
|
||||
/*
|
||||
* And finally we can do the actual output.
|
||||
*/
|
||||
@@ -1283,6 +1291,35 @@ 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, "",
|
||||
false, "DUMP TIMESTAMP", qry->data, "", NULL,
|
||||
NULL, 0,
|
||||
NULL, NULL);
|
||||
destroyPQExpBuffer(qry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* dumpEncoding: put the correct encoding into the archive
|
||||
*/
|
||||
|
Reference in New Issue
Block a user