git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a74a4aa)
Report timezone offset in pg_dump/pg_dumpall
Fri, 5 Sep 2014 23:22:31 +0000 (19:22 -0400)
Fri, 5 Sep 2014 23:22:31 +0000 (19:22 -0400)
Use consistent format for all such displays.

Report by Gavin Flower


diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 00187200ffa3bceae4991fdb74f670edf7b97a61..ded9135c36066ce1fed915702a121cd18746fe9a 100644 (file)
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -964,12 +964,15 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
teSection curSection;
OutputContext sav;
const char *fmtName;
+ struct tm *tm = localtime(&AH->createDate);
+ char stamp_str[64];
sav = SaveOutput(AH);
if (ropt->filename)
SetOutput(AH, ropt->filename, 0 /* no compression */ );
- ahprintf(AH, ";\n; Archive created at %s", ctime(&AH->createDate));
+ strftime(stamp_str, sizeof(stamp_str), "%Y-%m-%d %H:%M:%S %z", tm);
+ ahprintf(AH, ";\n; Archive created at %s\n", stamp_str);
ahprintf(AH, "; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n",
AH->archdbname, AH->tocCount, AH->compression);
@@ -3455,21 +3458,9 @@ checkSeek(FILE *fp)
static void
dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)
{
- char buf[256];
+ char buf[64];
- /*
- * We don't print the timezone on Win32, because the names are long and
- * localized, which means they may contain characters in various random
- * encodings; this has been seen to cause encoding errors when reading the
- * dump script.
- */
- if (strftime(buf, sizeof(buf),
-#ifndef WIN32
- "%Y-%m-%d %H:%M:%S %Z",
-#else
- "%Y-%m-%d %H:%M:%S",
-#endif
- localtime(&tim)) != 0)
+ if (strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %z", localtime(&tim)) != 0)
ahprintf(AH, "-- %s %s\n\n", msg, buf);
}
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 405009158d5a3d2e60c1bf737e6c3e261630a7c4..b2b3e6feb74d5d577dfee4101b1997a33cc15a60 100644 (file)
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -2039,22 +2039,10 @@ executeCommand(PGconn *conn, const char *query)
static void
dumpTimestamp(char *msg)
{
- char buf[256];
+ char buf[64];
time_t now = time(NULL);
- /*
- * We don't print the timezone on Win32, because the names are long and
- * localized, which means they may contain characters in various random
- * encodings; this has been seen to cause encoding errors when reading the
- * dump script.
- */
- if (strftime(buf, sizeof(buf),
-#ifndef WIN32
- "%Y-%m-%d %H:%M:%S %Z",
-#else
- "%Y-%m-%d %H:%M:%S",
-#endif
- localtime(&now)) != 0)
+ if (strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %z", localtime(&now)) != 0)
fprintf(OPF, "-- %s %s\n\n", msg, buf);
}
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /