Skip to content

Commit 6c349a5

Browse files
committed
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
1 parent 8e708e5 commit 6c349a5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bin/pg_controldata/pg_controldata.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <fcntl.h>
2525

2626
#include "access/xlog.h"
27+
#include "access/xlog_internal.h"
2728
#include "catalog/pg_control.h"
2829

2930

@@ -95,6 +96,8 @@ main(int argc, char *argv[])
9596
char sysident_str[32];
9697
const char *strftime_fmt = "%c";
9798
const char *progname;
99+
XLogSegNo segno;
100+
char xlogfilename[MAXFNAMELEN];
98101

99102
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_controldata"));
100103

@@ -170,6 +173,13 @@ main(int argc, char *argv[])
170173
strftime(ckpttime_str, sizeof(ckpttime_str), strftime_fmt,
171174
localtime(&time_tmp));
172175

176+
/*
177+
* Calculate name of the WAL file containing the latest checkpoint's REDO
178+
* start point.
179+
*/
180+
XLByteToSeg(ControlFile.checkPointCopy.redo, segno);
181+
XLogFileName(xlogfilename, ControlFile.checkPointCopy.ThisTimeLineID, segno);
182+
173183
/*
174184
* Format system_identifier separately to keep platform-dependent format
175185
* code out of the translatable message string.
@@ -201,6 +211,8 @@ main(int argc, char *argv[])
201211
printf(_("Latest checkpoint's REDO location: %X/%X\n"),
202212
(uint32) (ControlFile.checkPointCopy.redo >> 32),
203213
(uint32) ControlFile.checkPointCopy.redo);
214+
printf(_("Latest checkpoint's REDO WAL file: %s\n"),
215+
xlogfilename);
204216
printf(_("Latest checkpoint's TimeLineID: %u\n"),
205217
ControlFile.checkPointCopy.ThisTimeLineID);
206218
printf(_("Latest checkpoint's full_page_writes: %s\n"),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy