@@ -6231,45 +6231,59 @@ StartupXLOG(void)
62316231 CurrentResourceOwner = AuxProcessResourceOwner ;
62326232
62336233 /*
6234- * Verify XLOG status looks valid.
6234+ * Check that contents look valid.
62356235 */
6236- if (ControlFile -> state < DB_SHUTDOWNED ||
6237- ControlFile -> state > DB_IN_PRODUCTION ||
6238- !XRecOffIsValid (ControlFile -> checkPoint ))
6236+ if (!XRecOffIsValid (ControlFile -> checkPoint ))
62396237 ereport (FATAL ,
6240- (errmsg ("control file contains invalid data " )));
6238+ (errmsg ("control file contains invalid checkpoint location " )));
62416239
6242- if (ControlFile -> state == DB_SHUTDOWNED )
6240+ switch (ControlFile -> state )
62436241 {
6244- /* This is the expected case, so don't be chatty in standalone mode */
6245- ereport (IsPostmasterEnvironment ? LOG : NOTICE ,
6246- (errmsg ("database system was shut down at %s" ,
6247- str_time (ControlFile -> time ))));
6242+ case DB_SHUTDOWNED :
6243+ /* This is the expected case, so don't be chatty in standalone mode */
6244+ ereport (IsPostmasterEnvironment ? LOG : NOTICE ,
6245+ (errmsg ("database system was shut down at %s" ,
6246+ str_time (ControlFile -> time ))));
6247+ break ;
6248+
6249+ case DB_SHUTDOWNED_IN_RECOVERY :
6250+ ereport (LOG ,
6251+ (errmsg ("database system was shut down in recovery at %s" ,
6252+ str_time (ControlFile -> time ))));
6253+ break ;
6254+
6255+ case DB_SHUTDOWNING :
6256+ ereport (LOG ,
6257+ (errmsg ("database system shutdown was interrupted; last known up at %s" ,
6258+ str_time (ControlFile -> time ))));
6259+ break ;
6260+
6261+ case DB_IN_CRASH_RECOVERY :
6262+ ereport (LOG ,
6263+ (errmsg ("database system was interrupted while in recovery at %s" ,
6264+ str_time (ControlFile -> time )),
6265+ errhint ("This probably means that some data is corrupted and"
6266+ " you will have to use the last backup for recovery." )));
6267+ break ;
6268+
6269+ case DB_IN_ARCHIVE_RECOVERY :
6270+ ereport (LOG ,
6271+ (errmsg ("database system was interrupted while in recovery at log time %s" ,
6272+ str_time (ControlFile -> checkPointCopy .time )),
6273+ errhint ("If this has occurred more than once some data might be corrupted"
6274+ " and you might need to choose an earlier recovery target." )));
6275+ break ;
6276+
6277+ case DB_IN_PRODUCTION :
6278+ ereport (LOG ,
6279+ (errmsg ("database system was interrupted; last known up at %s" ,
6280+ str_time (ControlFile -> time ))));
6281+ break ;
6282+
6283+ default :
6284+ ereport (FATAL ,
6285+ (errmsg ("control file contains invalid database cluster state" )));
62486286 }
6249- else if (ControlFile -> state == DB_SHUTDOWNED_IN_RECOVERY )
6250- ereport (LOG ,
6251- (errmsg ("database system was shut down in recovery at %s" ,
6252- str_time (ControlFile -> time ))));
6253- else if (ControlFile -> state == DB_SHUTDOWNING )
6254- ereport (LOG ,
6255- (errmsg ("database system shutdown was interrupted; last known up at %s" ,
6256- str_time (ControlFile -> time ))));
6257- else if (ControlFile -> state == DB_IN_CRASH_RECOVERY )
6258- ereport (LOG ,
6259- (errmsg ("database system was interrupted while in recovery at %s" ,
6260- str_time (ControlFile -> time )),
6261- errhint ("This probably means that some data is corrupted and"
6262- " you will have to use the last backup for recovery." )));
6263- else if (ControlFile -> state == DB_IN_ARCHIVE_RECOVERY )
6264- ereport (LOG ,
6265- (errmsg ("database system was interrupted while in recovery at log time %s" ,
6266- str_time (ControlFile -> checkPointCopy .time )),
6267- errhint ("If this has occurred more than once some data might be corrupted"
6268- " and you might need to choose an earlier recovery target." )));
6269- else if (ControlFile -> state == DB_IN_PRODUCTION )
6270- ereport (LOG ,
6271- (errmsg ("database system was interrupted; last known up at %s" ,
6272- str_time (ControlFile -> time ))));
62736287
62746288 /* This is just to allow attaching to startup process with a debugger */
62756289#ifdef XLOG_REPLAY_DELAY
0 commit comments