From 6c349a565abf1e5ddf68971c62afff14947bcfa2 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas <heikki.linnakangas@iki.fi> Date: Sat, 14 Jul 2012 14:17:43 +0300 Subject: [PATCH] Print the name of the WAL file containing latest REDO ptr in pg_controldata. This makes it easier to determine how far back you need to keep archived WAL files, to restore from a backup. Fujii Masao --- src/bin/pg_controldata/pg_controldata.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index 298f836504f..129c4d0dda3 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -24,6 +24,7 @@ #include <fcntl.h> #include "access/xlog.h" +#include "access/xlog_internal.h" #include "catalog/pg_control.h" @@ -95,6 +96,8 @@ main(int argc, char *argv[]) char sysident_str[32]; const char *strftime_fmt = "%c"; const char *progname; + XLogSegNo segno; + char xlogfilename[MAXFNAMELEN]; set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_controldata")); @@ -170,6 +173,13 @@ main(int argc, char *argv[]) strftime(ckpttime_str, sizeof(ckpttime_str), strftime_fmt, localtime(&time_tmp)); + /* + * Calculate name of the WAL file containing the latest checkpoint's REDO + * start point. + */ + XLByteToSeg(ControlFile.checkPointCopy.redo, segno); + XLogFileName(xlogfilename, ControlFile.checkPointCopy.ThisTimeLineID, segno); + /* * Format system_identifier separately to keep platform-dependent format * code out of the translatable message string. @@ -201,6 +211,8 @@ main(int argc, char *argv[]) printf(_("Latest checkpoint's REDO location: %X/%X\n"), (uint32) (ControlFile.checkPointCopy.redo >> 32), (uint32) ControlFile.checkPointCopy.redo); + printf(_("Latest checkpoint's REDO WAL file: %s\n"), + xlogfilename); printf(_("Latest checkpoint's TimeLineID: %u\n"), ControlFile.checkPointCopy.ThisTimeLineID); printf(_("Latest checkpoint's full_page_writes: %s\n"), -- GitLab