Skip to content

Commit 7889caf

Browse files
author
itagaki.takahiro
committed
Don't write invalid fields to ini files.
git-svn-id: http://pg-rman.googlecode.com/svn/trunk@31 182aca00-e38e-11de-a668-6fd11605f5ce
1 parent 2b4c33e commit 7889caf

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

catalog.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,30 @@ pgBackupWriteResultSection(FILE *out, pgBackup *backup)
356356
backup->start_lsn.xrecoff);
357357
fprintf(out, "STOP_LSN=%x/%08x\n", backup->stop_lsn.xlogid,
358358
backup->stop_lsn.xrecoff);
359+
359360
time2iso(timestamp, lengthof(timestamp), backup->start_time);
360361
fprintf(out, "START_TIME='%s'\n", timestamp);
361-
time2iso(timestamp, lengthof(timestamp), backup->end_time);
362-
fprintf(out, "END_TIME='%s'\n", timestamp);
363-
fprintf(out, "TOTAL_DATA_BYTES=" INT64_FORMAT "\n", backup->total_data_bytes);
364-
fprintf(out, "READ_DATA_BYTES=" INT64_FORMAT "\n", backup->read_data_bytes);
365-
fprintf(out, "READ_ARCLOG_BYTES=" INT64_FORMAT "\n", backup->read_arclog_bytes);
366-
fprintf(out, "READ_SRVLOG_BYTES=" INT64_FORMAT "\n", backup->read_srvlog_bytes);
367-
fprintf(out, "WRITE_BYTES=" INT64_FORMAT "\n", backup->write_bytes);
362+
if (backup->end_time > 0)
363+
{
364+
time2iso(timestamp, lengthof(timestamp), backup->end_time);
365+
fprintf(out, "END_TIME='%s'\n", timestamp);
366+
}
367+
368+
if (backup->total_data_bytes != BYTES_INVALID)
369+
fprintf(out, "TOTAL_DATA_BYTES=" INT64_FORMAT "\n",
370+
backup->total_data_bytes);
371+
if (backup->read_data_bytes != BYTES_INVALID)
372+
fprintf(out, "READ_DATA_BYTES=" INT64_FORMAT "\n",
373+
backup->read_data_bytes);
374+
if (backup->read_arclog_bytes != BYTES_INVALID)
375+
fprintf(out, "READ_ARCLOG_BYTES=" INT64_FORMAT "\n",
376+
backup->read_arclog_bytes);
377+
if (backup->read_srvlog_bytes != BYTES_INVALID)
378+
fprintf(out, "READ_SRVLOG_BYTES=" INT64_FORMAT "\n",
379+
backup->read_srvlog_bytes);
380+
if (backup->write_bytes != BYTES_INVALID)
381+
fprintf(out, "WRITE_BYTES=" INT64_FORMAT "\n",
382+
backup->write_bytes);
368383

369384
fprintf(out, "BLOCK_SIZE=%u\n", backup->block_size);
370385
fprintf(out, "XLOG_BLOCK_SIZE=%u\n", backup->wal_block_size);

util.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ time2iso(char *buf, size_t len, time_t time)
1919
{
2020
struct tm *tm = localtime(&time);
2121

22-
if (time == (time_t) 0)
23-
strncpy(buf,"****-**-** **:**:**", len);
24-
else
25-
strftime(buf, len, "%Y-%m-%d %H:%M:%S", tm);
22+
strftime(buf, len, "%Y-%m-%d %H:%M:%S", tm);
2623
}
2724

2825
const char *

0 commit comments

Comments
 (0)