@@ -565,7 +565,7 @@ RestoreControlValues(int mode)
565565{
566566 struct timeval tv ;
567567 char * localeptr ;
568- bool successed = true;
568+ bool successed = true;
569569
570570 /*
571571 * Set up a completely default set of pg_control values.
@@ -579,27 +579,30 @@ RestoreControlValues(int mode)
579579 * update the checkpoint value in control file,by searching
580580 * xlog segment file, or just guessing it.
581581 */
582- if (mode == WAL )
583- {
582+ if (mode == WAL )
583+ {
584584 int result = SearchLastCheckpoint ();
585- if ( result > 0 ) /* The last checkpoint had been found. */
585+
586+ if (result > 0 ) /* The last checkpoint had been found. */
586587 {
587588 ControlFile .checkPointCopy = lastcheckpoint ;
589+ ControlFile .checkPointCopy .ThisTimeLineID = LastXLogFile -> tli ;
588590 ControlFile .checkPoint = lastchkp ;
589591 ControlFile .prevCheckPoint = prevchkp ;
592+
590593 ControlFile .logId = LastXLogFile -> logid ;
591594 ControlFile .logSeg = LastXLogFile -> seg + 1 ;
592- ControlFile .checkPointCopy .ThisTimeLineID = LastXLogFile -> tli ;
593595 ControlFile .state = state ;
594- } else successed = false;
596+ }
597+ else
598+ successed = false;
595599
596600 /* Clean up the list. */
597601 CleanUpList (xlogfilelist );
598-
599- }
600-
601- if (mode == GUESS )
602+ }
603+ else /* GUESS */
602604 {
605+ ControlFile .checkPointCopy .ThisTimeLineID = 2 ;
603606 ControlFile .checkPointCopy .redo .xlogid = 0 ;
604607 ControlFile .checkPointCopy .redo .xrecoff = SizeOfXLogLongPHD ;
605608 ControlFile .checkPointCopy .undo = ControlFile .checkPointCopy .redo ;
@@ -609,6 +612,7 @@ RestoreControlValues(int mode)
609612 ControlFile .checkPointCopy .nextMultiOffset = 0 ;
610613 ControlFile .checkPointCopy .time = time (NULL );
611614 ControlFile .checkPoint = ControlFile .checkPointCopy .redo ;
615+
612616 /*
613617 * Create a new unique installation identifier, since we can no longer
614618 * use any old XLOG records. See notes in xlog.c about the algorithm.
@@ -644,6 +648,7 @@ RestoreControlValues(int mode)
644648 exit (1 );
645649 }
646650 StrNCpy (ControlFile .lc_collate , localeptr , LOCALE_NAME_BUFLEN );
651+
647652 localeptr = setlocale (LC_CTYPE , "" );
648653 if (!localeptr )
649654 {
0 commit comments