@@ -64,10 +64,18 @@ static ControlFileData ControlFile; /* pg_control values */
6464static XLogSegNo newXlogSegNo ; /* new XLOG segment # */
6565static bool guessed = false; /* T if we had to guess at any values */
6666static const char * progname ;
67+ static uint32 set_xid_epoch = (uint32 ) - 1 ;
68+ static TransactionId set_xid = 0 ;
69+ static Oid set_oid = 0 ;
70+ static MultiXactId set_mxid = 0 ;
71+ static MultiXactOffset set_mxoff = (MultiXactOffset ) - 1 ;
72+ static uint32 minXlogTli = 0 ;
73+ static XLogSegNo minXlogSegNo = 0 ;
6774
6875static bool ReadControlFile (void );
6976static void GuessControlValues (void );
7077static void PrintControlValues (bool guessed );
78+ static void PrintNewControlValues (void );
7179static void RewriteControlFile (void );
7280static void FindEndOfXLOG (void );
7381static void KillExistingXLOG (void );
@@ -82,14 +90,7 @@ main(int argc, char *argv[])
8290 int c ;
8391 bool force = false;
8492 bool noupdate = false;
85- uint32 set_xid_epoch = (uint32 ) - 1 ;
86- TransactionId set_xid = 0 ;
87- Oid set_oid = 0 ;
88- MultiXactId set_mxid = 0 ;
8993 MultiXactId set_oldestmxid = 0 ;
90- MultiXactOffset set_mxoff = (MultiXactOffset ) - 1 ;
91- uint32 minXlogTli = 0 ;
92- XLogSegNo minXlogSegNo = 0 ;
9394 char * endptr ;
9495 char * endptr2 ;
9596 char * DataDir ;
@@ -301,6 +302,13 @@ main(int argc, char *argv[])
301302 */
302303 FindEndOfXLOG ();
303304
305+ /*
306+ * If we're not going to proceed with the reset, print the current control
307+ * file parameters.
308+ */
309+ if ((guessed && !force ) || noupdate )
310+ PrintControlValues (guessed );
311+
304312 /*
305313 * Adjust fields if required by switches. (Do this now so that printout,
306314 * if any, includes these values.)
@@ -356,7 +364,7 @@ main(int argc, char *argv[])
356364 */
357365 if ((guessed && !force ) || noupdate )
358366 {
359- PrintControlValues ( guessed );
367+ PrintNewControlValues ( );
360368 if (!noupdate )
361369 {
362370 printf (_ ("\nIf these values seem acceptable, use -f to force reset.\n" ));
@@ -556,12 +564,11 @@ static void
556564PrintControlValues (bool guessed )
557565{
558566 char sysident_str [32 ];
559- char fname [MAXFNAMELEN ];
560567
561568 if (guessed )
562569 printf (_ ("Guessed pg_control values:\n\n" ));
563570 else
564- printf (_ ("pg_control values:\n\n" ));
571+ printf (_ ("Current pg_control values:\n\n" ));
565572
566573 /*
567574 * Format system_identifier separately to keep platform-dependent format
@@ -570,10 +577,6 @@ PrintControlValues(bool guessed)
570577 snprintf (sysident_str , sizeof (sysident_str ), UINT64_FORMAT ,
571578 ControlFile .system_identifier );
572579
573- XLogFileName (fname , ControlFile .checkPointCopy .ThisTimeLineID , newXlogSegNo );
574-
575- printf (_ ("First log segment after reset: %s\n" ),
576- fname );
577580 printf (_ ("pg_control version number: %u\n" ),
578581 ControlFile .pg_control_version );
579582 printf (_ ("Catalog version number: %u\n" ),
@@ -631,6 +634,60 @@ PrintControlValues(bool guessed)
631634}
632635
633636
637+ /*
638+ * Print the values to be changed.
639+ */
640+ static void
641+ PrintNewControlValues ()
642+ {
643+ char fname [MAXFNAMELEN ];
644+
645+ /* This will be always printed in order to keep format same. */
646+ printf (_ ("\n\nValues to be changed:\n\n" ));
647+
648+ XLogFileName (fname , ControlFile .checkPointCopy .ThisTimeLineID , newXlogSegNo );
649+ printf (_ ("First log segment after reset: %s\n" ), fname );
650+
651+ if (set_mxid != 0 )
652+ {
653+ printf (_ ("NextMultiXactId: %u\n" ),
654+ ControlFile .checkPointCopy .nextMulti );
655+ printf (_ ("OldestMultiXid: %u\n" ),
656+ ControlFile .checkPointCopy .oldestMulti );
657+ printf (_ ("OldestMulti's DB: %u\n" ),
658+ ControlFile .checkPointCopy .oldestMultiDB );
659+ }
660+
661+ if (set_mxoff != -1 )
662+ {
663+ printf (_ ("NextMultiOffset: %u\n" ),
664+ ControlFile .checkPointCopy .nextMultiOffset );
665+ }
666+
667+ if (set_oid != 0 )
668+ {
669+ printf (_ ("NextOID: %u\n" ),
670+ ControlFile .checkPointCopy .nextOid );
671+ }
672+
673+ if (set_xid != 0 )
674+ {
675+ printf (_ ("NextXID: %u\n" ),
676+ ControlFile .checkPointCopy .nextXid );
677+ printf (_ ("OldestXID: %u\n" ),
678+ ControlFile .checkPointCopy .oldestXid );
679+ printf (_ ("OldestXID's DB: %u\n" ),
680+ ControlFile .checkPointCopy .oldestXidDB );
681+ }
682+
683+ if (set_xid_epoch != -1 )
684+ {
685+ printf (_ ("NextXID Epoch: %u\n" ),
686+ ControlFile .checkPointCopy .nextXidEpoch );
687+ }
688+ }
689+
690+
634691/*
635692 * Write out the new pg_control file.
636693 */
@@ -1039,7 +1096,7 @@ usage(void)
10391096 printf (_ (" -f force update to be done\n" ));
10401097 printf (_ (" -l XLOGFILE force minimum WAL starting location for new transaction log\n" ));
10411098 printf (_ (" -m MXID,MXID set next and oldest multitransaction ID\n" ));
1042- printf (_ (" -n no update, just show extracted control values (for testing)\n" ));
1099+ printf (_ (" -n no update, just show what would be done (for testing)\n" ));
10431100 printf (_ (" -o OID set next OID\n" ));
10441101 printf (_ (" -O OFFSET set next multitransaction offset\n" ));
10451102 printf (_ (" -V, --version output version information, then exit\n" ));
0 commit comments