@@ -64,10 +64,18 @@ static ControlFileData ControlFile; /* pg_control values */
64
64
static XLogSegNo newXlogSegNo ; /* new XLOG segment # */
65
65
static bool guessed = false; /* T if we had to guess at any values */
66
66
static 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 ;
67
74
68
75
static bool ReadControlFile (void );
69
76
static void GuessControlValues (void );
70
77
static void PrintControlValues (bool guessed );
78
+ static void PrintNewControlValues (void );
71
79
static void RewriteControlFile (void );
72
80
static void FindEndOfXLOG (void );
73
81
static void KillExistingXLOG (void );
@@ -82,14 +90,7 @@ main(int argc, char *argv[])
82
90
int c ;
83
91
bool force = false;
84
92
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 ;
89
93
MultiXactId set_oldestmxid = 0 ;
90
- MultiXactOffset set_mxoff = (MultiXactOffset ) - 1 ;
91
- uint32 minXlogTli = 0 ;
92
- XLogSegNo minXlogSegNo = 0 ;
93
94
char * endptr ;
94
95
char * endptr2 ;
95
96
char * DataDir ;
@@ -301,6 +302,13 @@ main(int argc, char *argv[])
301
302
*/
302
303
FindEndOfXLOG ();
303
304
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
+
304
312
/*
305
313
* Adjust fields if required by switches. (Do this now so that printout,
306
314
* if any, includes these values.)
@@ -356,7 +364,7 @@ main(int argc, char *argv[])
356
364
*/
357
365
if ((guessed && !force ) || noupdate )
358
366
{
359
- PrintControlValues ( guessed );
367
+ PrintNewControlValues ( );
360
368
if (!noupdate )
361
369
{
362
370
printf (_ ("\nIf these values seem acceptable, use -f to force reset.\n" ));
@@ -556,12 +564,11 @@ static void
556
564
PrintControlValues (bool guessed )
557
565
{
558
566
char sysident_str [32 ];
559
- char fname [MAXFNAMELEN ];
560
567
561
568
if (guessed )
562
569
printf (_ ("Guessed pg_control values:\n\n" ));
563
570
else
564
- printf (_ ("pg_control values:\n\n" ));
571
+ printf (_ ("Current pg_control values:\n\n" ));
565
572
566
573
/*
567
574
* Format system_identifier separately to keep platform-dependent format
@@ -570,10 +577,6 @@ PrintControlValues(bool guessed)
570
577
snprintf (sysident_str , sizeof (sysident_str ), UINT64_FORMAT ,
571
578
ControlFile .system_identifier );
572
579
573
- XLogFileName (fname , ControlFile .checkPointCopy .ThisTimeLineID , newXlogSegNo );
574
-
575
- printf (_ ("First log segment after reset: %s\n" ),
576
- fname );
577
580
printf (_ ("pg_control version number: %u\n" ),
578
581
ControlFile .pg_control_version );
579
582
printf (_ ("Catalog version number: %u\n" ),
@@ -631,6 +634,60 @@ PrintControlValues(bool guessed)
631
634
}
632
635
633
636
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
+
634
691
/*
635
692
* Write out the new pg_control file.
636
693
*/
@@ -1039,7 +1096,7 @@ usage(void)
1039
1096
printf (_ (" -f force update to be done\n" ));
1040
1097
printf (_ (" -l XLOGFILE force minimum WAL starting location for new transaction log\n" ));
1041
1098
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" ));
1043
1100
printf (_ (" -o OID set next OID\n" ));
1044
1101
printf (_ (" -O OFFSET set next multitransaction offset\n" ));
1045
1102
printf (_ (" -V, --version output version information, then exit\n" ));
0 commit comments