23
23
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
24
24
* Portions Copyright (c) 1994, Regents of the University of California
25
25
*
26
- * $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.11 2002/01/1017:51:52 momjian Exp $
26
+ * $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.12 2002/01/1018:08:29 momjian Exp $
27
27
*
28
28
*-------------------------------------------------------------------------
29
29
*/
@@ -714,32 +714,30 @@ RewriteControlFile(TransactionId set_xid)
714
714
int fd ;
715
715
char buffer [BLCKSZ ];/* need not be aligned */
716
716
717
- if (set_xid == 0 )
718
- {
719
- /*
720
- * Adjust fields as needed to force an empty XLOG starting at the next
721
- * available segment.
722
- */
723
- newXlogId = ControlFile .logId ;
724
- newXlogSeg = ControlFile .logSeg ;
725
- /* be sure we wrap around correctly at end of a logfile */
726
- NextLogSeg (newXlogId ,newXlogSeg );
727
-
728
- ControlFile .checkPointCopy .redo .xlogid = newXlogId ;
729
- ControlFile .checkPointCopy .redo .xrecoff =
730
- newXlogSeg * XLogSegSize + SizeOfXLogPHD ;
731
- ControlFile .checkPointCopy .undo = ControlFile .checkPointCopy .redo ;
732
- ControlFile .checkPointCopy .time = time (NULL );
733
-
734
- ControlFile .state = DB_SHUTDOWNED ;
735
- ControlFile .time = time (NULL );
736
- ControlFile .logId = newXlogId ;
737
- ControlFile .logSeg = newXlogSeg + 1 ;
738
- ControlFile .checkPoint = ControlFile .checkPointCopy .redo ;
739
- ControlFile .prevCheckPoint .xlogid = 0 ;
740
- ControlFile .prevCheckPoint .xrecoff = 0 ;
741
- }
742
- else
717
+ /*
718
+ * Adjust fields as needed to force an empty XLOG starting at the next
719
+ * available segment.
720
+ */
721
+ newXlogId = ControlFile .logId ;
722
+ newXlogSeg = ControlFile .logSeg ;
723
+ /* be sure we wrap around correctly at end of a logfile */
724
+ NextLogSeg (newXlogId ,newXlogSeg );
725
+
726
+ ControlFile .checkPointCopy .redo .xlogid = newXlogId ;
727
+ ControlFile .checkPointCopy .redo .xrecoff =
728
+ newXlogSeg * XLogSegSize + SizeOfXLogPHD ;
729
+ ControlFile .checkPointCopy .undo = ControlFile .checkPointCopy .redo ;
730
+ ControlFile .checkPointCopy .time = time (NULL );
731
+
732
+ ControlFile .state = DB_SHUTDOWNED ;
733
+ ControlFile .time = time (NULL );
734
+ ControlFile .logId = newXlogId ;
735
+ ControlFile .logSeg = newXlogSeg + 1 ;
736
+ ControlFile .checkPoint = ControlFile .checkPointCopy .redo ;
737
+ ControlFile .prevCheckPoint .xlogid = 0 ;
738
+ ControlFile .prevCheckPoint .xrecoff = 0 ;
739
+
740
+ if (set_xid != 0 )
743
741
ControlFile .checkPointCopy .nextXid = set_xid ;
744
742
745
743
/* Contents are protected with a CRC */
@@ -1011,20 +1009,6 @@ main(int argc, char **argv)
1011
1009
if (!ReadControlFile ())
1012
1010
GuessControlValues ();
1013
1011
1014
- /*
1015
- * Set XID in pg_control and exit
1016
- */
1017
- if (set_xid )
1018
- {
1019
- if (guessed )
1020
- {
1021
- printf ("\npg_control appears corrupt. Can not update XID.\n" );
1022
- exit (1 );
1023
- }
1024
- RewriteControlFile (set_xid );
1025
- exit (0 );
1026
- }
1027
-
1028
1012
/*
1029
1013
* If we had to guess anything, and -f was not given, just print the
1030
1014
* guessed values and exit. Also print if -n is given.
@@ -1051,7 +1035,7 @@ main(int argc, char **argv)
1051
1035
/*
1052
1036
* Else, do the dirty deed.
1053
1037
*/
1054
- RewriteControlFile (0 );
1038
+ RewriteControlFile (set_xid );
1055
1039
KillExistingXLOG ();
1056
1040
WriteEmptyXLOG ();
1057
1041