*** a/doc/src/sgml/ref/pg_resetxlog.sgml
--- b/doc/src/sgml/ref/pg_resetxlog.sgml
***************
*** 180,185 **** PostgreSQL documentation
--- 180,188 ----
     <filename>pg_control</> and then exit without modifying anything.
     This is mainly a debugging tool, but can be useful as a sanity check
     before allowing <command>pg_resetxlog</command> to proceed for real.
+    Also if any of the other parameter given along with -n, then it will print values
+    in two sections. In first section it will print all original values and in next section
+    all values which will be on reset.
    </para>
  
    <para>
*** a/src/bin/pg_resetxlog/pg_resetxlog.c
--- b/src/bin/pg_resetxlog/pg_resetxlog.c
***************
*** 56,61 ****
--- 56,69 ----
  #include "catalog/pg_control.h"
  #include "common/fe_memutils.h"
  
+  /* Indicate which control file parameter going to be changed*/
+ #define DISPLAY_XIDEPOCH	1
+ #define DISPLAY_XLOGFILE	2
+ #define DISPLAY_MXID		4
+ #define DISPLAY_OID			8
+ #define DISPLAY_OFFSET		16
+ #define DISPLAY_XID			32
+ 
  extern int	optind;
  extern char *optarg;
  
***************
*** 68,73 **** static const char *progname;
--- 76,82 ----
  static bool ReadControlFile(void);
  static void GuessControlValues(void);
  static void PrintControlValues(bool guessed);
+ static void PrintNewControlValues(int changedParam);
  static void RewriteControlFile(void);
  static void FindEndOfXLOG(void);
  static void KillExistingXLOG(void);
***************
*** 94,99 **** main(int argc, char *argv[])
--- 103,109 ----
  	char	   *endptr2;
  	char	   *DataDir;
  	int			fd;
+ 	int			changedParam = 0;
  
  	set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_resetxlog"));
  
***************
*** 128,133 **** main(int argc, char *argv[])
--- 138,144 ----
  
  			case 'e':
  				set_xid_epoch = strtoul(optarg, &endptr, 0);
+ 				changedParam |= DISPLAY_XIDEPOCH;
  				if (endptr == optarg || *endptr != '\0')
  				{
  					fprintf(stderr, _("%s: invalid argument for option -e\n"), progname);
***************
*** 143,148 **** main(int argc, char *argv[])
--- 154,160 ----
  
  			case 'x':
  				set_xid = strtoul(optarg, &endptr, 0);
+ 				changedParam |= DISPLAY_XID;
  				if (endptr == optarg || *endptr != '\0')
  				{
  					fprintf(stderr, _("%s: invalid argument for option -x\n"), progname);
***************
*** 158,163 **** main(int argc, char *argv[])
--- 170,176 ----
  
  			case 'o':
  				set_oid = strtoul(optarg, &endptr, 0);
+ 				changedParam |= DISPLAY_OID;
  				if (endptr == optarg || *endptr != '\0')
  				{
  					fprintf(stderr, _("%s: invalid argument for option -o\n"), progname);
***************
*** 173,178 **** main(int argc, char *argv[])
--- 186,192 ----
  
  			case 'm':
  				set_mxid = strtoul(optarg, &endptr, 0);
+ 				changedParam |= DISPLAY_MXID;
  				if (endptr == optarg || *endptr != ',')
  				{
  					fprintf(stderr, _("%s: invalid argument for option -m\n"), progname);
***************
*** 207,212 **** main(int argc, char *argv[])
--- 221,227 ----
  
  			case 'O':
  				set_mxoff = strtoul(optarg, &endptr, 0);
+ 				changedParam |= DISPLAY_OFFSET;
  				if (endptr == optarg || *endptr != '\0')
  				{
  					fprintf(stderr, _("%s: invalid argument for option -O\n"), progname);
***************
*** 228,233 **** main(int argc, char *argv[])
--- 243,249 ----
  					exit(1);
  				}
  				XLogFromFileName(optarg, &minXlogTli, &minXlogSegNo);
+ 				changedParam |= DISPLAY_XLOGFILE;
  				break;
  
  			default:
***************
*** 301,306 **** main(int argc, char *argv[])
--- 317,326 ----
  	 */
  	FindEndOfXLOG();
  
+  	/* print current control file parameter value if -n is given*/
+ 	if (noupdate)
+ 		PrintControlValues(guessed);	
+ 
  	/*
  	 * Adjust fields if required by switches.  (Do this now so that printout,
  	 * if any, includes these values.)
***************
*** 350,360 **** main(int argc, char *argv[])
  	if (minXlogSegNo > newXlogSegNo)
  		newXlogSegNo = minXlogSegNo;
  
  	/*
  	 * If we had to guess anything, and -f was not given, just print the
! 	 * guessed values and exit.  Also print if -n is given.
  	 */
! 	if ((guessed && !force) || noupdate)
  	{
  		PrintControlValues(guessed);
  		if (!noupdate)
--- 370,387 ----
  	if (minXlogSegNo > newXlogSegNo)
  		newXlogSegNo = minXlogSegNo;
  
+ 	/* Print only new values to be reset if -n is given*/
+  	if (noupdate)
+ 	{
+ 		PrintNewControlValues(changedParam);
+ 		exit(0);
+ 	}	
+ 
  	/*
  	 * If we had to guess anything, and -f was not given, just print the
! 	 * guessed values and exit.
  	 */
! 	if (guessed && !force)
  	{
  		PrintControlValues(guessed);
  		if (!noupdate)
***************
*** 561,567 **** PrintControlValues(bool guessed)
  	if (guessed)
  		printf(_("Guessed pg_control values:\n\n"));
  	else
! 		printf(_("pg_control values:\n\n"));
  
  	/*
  	 * Format system_identifier separately to keep platform-dependent format
--- 588,594 ----
  	if (guessed)
  		printf(_("Guessed pg_control values:\n\n"));
  	else
! 		printf(_("Current pg_control values:\n\n"));
  
  	/*
  	 * Format system_identifier separately to keep platform-dependent format
***************
*** 631,636 **** PrintControlValues(bool guessed)
--- 658,721 ----
  }
  
  
+  /*
+   * Print the values to be changed after pg_resetxlog.
+   *
+   * NB: this display should be just for those fields that are 
+   * going to change after reset.
+   */
+ static void
+ PrintNewControlValues(int changedParam)
+ {
+  	if (changedParam)
+ 	 	printf(_("\n\nValues to be used after reset:\n\n"));
+  
+  	if (changedParam & DISPLAY_XLOGFILE)
+  	{	
+  		printf(_("First log file ID:                    %u\n"),
+  			   (uint32) ((newXlogSegNo) / XLogSegmentsPerXLogId));
+  		printf(_("First log file segment:               %u\n"),
+  			   (uint32) ((newXlogSegNo) % XLogSegmentsPerXLogId));
+  		printf(_("TimeLineID:                           %u\n"),
+  			   ControlFile.checkPointCopy.ThisTimeLineID);	
+  	}
+  
+  	if (changedParam & DISPLAY_MXID)
+  	{
+  		printf(_("NextMultiXactId:                      %u\n"),
+  			   ControlFile.checkPointCopy.nextMulti);		
+  		printf(_("oldestMultiXid:                       %u\n"),
+  		   ControlFile.checkPointCopy.oldestMulti);
+  	}
+  
+  	if (changedParam & DISPLAY_OFFSET)
+  	{
+  		printf(_("NextMultiOffset:                      %u\n"),
+  			   ControlFile.checkPointCopy.nextMultiOffset);	
+  	}
+  
+  	if (changedParam & DISPLAY_OID)
+  	{
+  		printf(_("NextOID:                              %u\n"),
+  			   ControlFile.checkPointCopy.nextOid);	
+  	}
+  
+  	if (changedParam & DISPLAY_XID)
+  	{
+  		printf(_("NextXID:                              %u\n"),
+  		   ControlFile.checkPointCopy.nextXid);
+  		printf(_("oldestXID:                            %u\n"),
+  		   ControlFile.checkPointCopy.oldestXid);
+  	}
+  
+  	if (changedParam & DISPLAY_XIDEPOCH)
+  	{
+  		printf(_("NextXID Epoch:                        %u\n"),
+  		   ControlFile.checkPointCopy.nextXidEpoch);
+  	}
+ }
+  
+ 
  /*
   * Write out the new pg_control file.
   */
***************
*** 1039,1045 **** usage(void)
  	printf(_("  -f               force update to be done\n"));
  	printf(_("  -l XLOGFILE      force minimum WAL starting location for new transaction log\n"));
  	printf(_("  -m MXID,MXID     set next and oldest multitransaction ID\n"));
! 	printf(_("  -n               no update, just show extracted control values (for testing)\n"));
  	printf(_("  -o OID           set next OID\n"));
  	printf(_("  -O OFFSET        set next multitransaction offset\n"));
  	printf(_("  -V, --version    output version information, then exit\n"));
--- 1124,1130 ----
  	printf(_("  -f               force update to be done\n"));
  	printf(_("  -l XLOGFILE      force minimum WAL starting location for new transaction log\n"));
  	printf(_("  -m MXID,MXID     set next and oldest multitransaction ID\n"));
! 	printf(_("  -n               no update, just show extracted control values (for testing) and to be reset values of parameters(if given)\n"));
  	printf(_("  -o OID           set next OID\n"));
  	printf(_("  -O OFFSET        set next multitransaction offset\n"));
  	printf(_("  -V, --version    output version information, then exit\n"));
