diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 6528113628..069c388510 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -700,6 +700,7 @@ main(int argc, char **argv)
 	XLogRecPtr	first_record;
 	char	   *waldir = NULL;
 	char	   *errormsg;
+	bool		beginread = false;
 
 	static struct option long_options[] = {
 		{"bkp-details", no_argument, NULL, 'b'},
@@ -719,6 +720,7 @@ main(int argc, char **argv)
 		{"xid", required_argument, NULL, 'x'},
 		{"version", no_argument, NULL, 'V'},
 		{"stats", optional_argument, NULL, 'z'},
+		{"beginread", no_argument, NULL, 'X'},
 		{NULL, 0, NULL, 0}
 	};
 
@@ -927,6 +929,9 @@ main(int argc, char **argv)
 				}
 				config.filter_by_xid_enabled = true;
 				break;
+			case 'X':
+				beginread = true;
+				break;
 			case 'z':
 				config.stats = true;
 				config.stats_per_record = false;
@@ -1073,6 +1078,15 @@ main(int argc, char **argv)
 	if (!xlogreader_state)
 		pg_fatal("out of memory while allocating a WAL reading processor");
 
+	if (beginread)
+	{
+		XLogBeginRead(xlogreader_state, private.startptr);
+		first_record = private.startptr;
+	}
+	else
+	{
+	/* NOT REINDENTED - THIS PATCH IS JUST FOR DEBUGGING */
+
 	/* first find a valid recptr to start from */
 	first_record = XLogFindNextRecord(xlogreader_state, private.startptr);
 
@@ -1094,6 +1108,9 @@ main(int argc, char **argv)
 			   LSN_FORMAT_ARGS(first_record),
 			   (uint32) (first_record - private.startptr));
 
+	/* NOT REINDENTED - THIS PATCH IS JUST FOR DEBUGGING */
+	}
+
 	if (config.stats == true && !config.quiet)
 		stats.startptr = first_record;
 
