@@ -630,7 +630,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
630630 if (!ReadRecord (xlogprefetcher , LOG , false,
631631 checkPoint .ThisTimeLineID ))
632632 ereport (FATAL ,
633- (errmsg ("could not find redo location referenced by checkpoint record" ),
633+ (errcode (ERRCODE_DATA_CORRUPTED ),
634+ errmsg ("could not find redo location referenced by checkpoint record" ),
634635 errhint ("If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n"
635636 "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n"
636637 "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup." ,
@@ -640,7 +641,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
640641 else
641642 {
642643 ereport (FATAL ,
643- (errmsg ("could not locate required checkpoint record" ),
644+ (errcode (ERRCODE_DATA_CORRUPTED ),
645+ errmsg ("could not locate required checkpoint record" ),
644646 errhint ("If you are restoring from a backup, touch \"%s/recovery.signal\" or \"%s/standby.signal\" and add required recovery options.\n"
645647 "If you are not restoring from a backup, try removing the file \"%s/backup_label\".\n"
646648 "Be careful: removing \"%s/backup_label\" will result in a corrupt cluster if restoring from a backup." ,
@@ -764,7 +766,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
764766 * simplify processing around checkpoints.
765767 */
766768 ereport (PANIC ,
767- (errmsg ("could not locate a valid checkpoint record" )));
769+ (errcode (ERRCODE_DATA_CORRUPTED ),
770+ errmsg ("could not locate a valid checkpoint record" )));
768771 }
769772 memcpy (& checkPoint , XLogRecGetData (xlogreader ), sizeof (CheckPoint ));
770773 wasShutdown = ((record -> xl_info & ~XLR_INFO_MASK ) == XLOG_CHECKPOINT_SHUTDOWN );
@@ -817,7 +820,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
817820 */
818821 switchpoint = tliSwitchPoint (ControlFile -> checkPointCopy .ThisTimeLineID , expectedTLEs , NULL );
819822 ereport (FATAL ,
820- (errmsg ("requested timeline %u is not a child of this server's history" ,
823+ (errcode (ERRCODE_DATA_CORRUPTED ),
824+ errmsg ("requested timeline %u is not a child of this server's history" ,
821825 recoveryTargetTLI ),
822826 errdetail ("Latest checkpoint is at %X/%X on timeline %u, but in the history of the requested timeline, the server forked off from that timeline at %X/%X." ,
823827 LSN_FORMAT_ARGS (ControlFile -> checkPoint ),
@@ -833,7 +837,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
833837 tliOfPointInHistory (ControlFile -> minRecoveryPoint - 1 , expectedTLEs ) !=
834838 ControlFile -> minRecoveryPointTLI )
835839 ereport (FATAL ,
836- (errmsg ("requested timeline %u does not contain minimum recovery point %X/%X on timeline %u" ,
840+ (errcode (ERRCODE_DATA_CORRUPTED ),
841+ errmsg ("requested timeline %u does not contain minimum recovery point %X/%X on timeline %u" ,
837842 recoveryTargetTLI ,
838843 LSN_FORMAT_ARGS (ControlFile -> minRecoveryPoint ),
839844 ControlFile -> minRecoveryPointTLI )));
@@ -861,12 +866,14 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
861866 checkPoint .newestCommitTsXid )));
862867 if (!TransactionIdIsNormal (XidFromFullTransactionId (checkPoint .nextXid )))
863868 ereport (PANIC ,
864- (errmsg ("invalid next transaction ID" )));
869+ (errcode (ERRCODE_DATA_CORRUPTED ),
870+ errmsg ("invalid next transaction ID" )));
865871
866872 /* sanity check */
867873 if (checkPoint .redo > CheckPointLoc )
868874 ereport (PANIC ,
869- (errmsg ("invalid redo in checkpoint record" )));
875+ (errcode (ERRCODE_DATA_CORRUPTED ),
876+ errmsg ("invalid redo in checkpoint record" )));
870877
871878 /*
872879 * Check whether we need to force recovery from WAL. If it appears to
@@ -877,7 +884,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
877884 {
878885 if (wasShutdown )
879886 ereport (PANIC ,
880- (errmsg ("invalid redo record in shutdown checkpoint" )));
887+ (errcode (ERRCODE_DATA_CORRUPTED ),
888+ errmsg ("invalid redo record in shutdown checkpoint" )));
881889 InRecovery = true;
882890 }
883891 else if (ControlFile -> state != DB_SHUTDOWNED )
@@ -953,7 +961,8 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
953961 if (dbstate_at_startup != DB_IN_ARCHIVE_RECOVERY &&
954962 dbstate_at_startup != DB_SHUTDOWNED_IN_RECOVERY )
955963 ereport (FATAL ,
956- (errmsg ("backup_label contains data inconsistent with control file" ),
964+ (errcode (ERRCODE_DATA_CORRUPTED ),
965+ errmsg ("backup_label contains data inconsistent with control file" ),
957966 errhint ("This means that the backup is corrupted and you will "
958967 "have to use another backup for recovery." )));
959968 ControlFile -> backupEndPoint = ControlFile -> minRecoveryPoint ;
@@ -1664,7 +1673,8 @@ PerformWalRecovery(void)
16641673 if (record -> xl_rmid != RM_XLOG_ID ||
16651674 (record -> xl_info & ~XLR_INFO_MASK ) != XLOG_CHECKPOINT_REDO )
16661675 ereport (FATAL ,
1667- (errmsg ("unexpected record type found at redo point %X/%X" ,
1676+ (errcode (ERRCODE_DATA_CORRUPTED ),
1677+ errmsg ("unexpected record type found at redo point %X/%X" ,
16681678 LSN_FORMAT_ARGS (xlogreader -> ReadRecPtr ))));
16691679 }
16701680 else
@@ -1792,7 +1802,8 @@ PerformWalRecovery(void)
17921802 {
17931803 if (!reachedConsistency )
17941804 ereport (FATAL ,
1795- (errmsg ("requested recovery stop point is before consistent recovery point" )));
1805+ (errcode (ERRCODE_DATA_CORRUPTED ),
1806+ errmsg ("requested recovery stop point is before consistent recovery point" )));
17961807
17971808 /*
17981809 * This is the last point where we can restart recovery with a new
@@ -1850,7 +1861,8 @@ PerformWalRecovery(void)
18501861 recoveryTarget != RECOVERY_TARGET_UNSET &&
18511862 !reachedRecoveryTarget )
18521863 ereport (FATAL ,
1853- (errmsg ("recovery ended before configured recovery target was reached" )));
1864+ (errcode (ERRCODE_DATA_CORRUPTED ),
1865+ errmsg ("recovery ended before configured recovery target was reached" )));
18541866}
18551867
18561868/*
@@ -2324,7 +2336,8 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI,
23242336 /* Check that the record agrees on what the current (old) timeline is */
23252337 if (prevTLI != replayTLI )
23262338 ereport (PANIC ,
2327- (errmsg ("unexpected previous timeline ID %u (current timeline ID %u) in checkpoint record" ,
2339+ (errcode (ERRCODE_DATA_CORRUPTED ),
2340+ errmsg ("unexpected previous timeline ID %u (current timeline ID %u) in checkpoint record" ,
23282341 prevTLI , replayTLI )));
23292342
23302343 /*
@@ -2333,7 +2346,8 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI,
23332346 */
23342347 if (newTLI < replayTLI || !tliInHistory (newTLI , expectedTLEs ))
23352348 ereport (PANIC ,
2336- (errmsg ("unexpected timeline ID %u (after %u) in checkpoint record" ,
2349+ (errcode (ERRCODE_DATA_CORRUPTED ),
2350+ errmsg ("unexpected timeline ID %u (after %u) in checkpoint record" ,
23372351 newTLI , replayTLI )));
23382352
23392353 /*
@@ -2349,7 +2363,8 @@ checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI, TimeLineID prevTLI,
23492363 lsn < minRecoveryPoint &&
23502364 newTLI > minRecoveryPointTLI )
23512365 ereport (PANIC ,
2352- (errmsg ("unexpected timeline ID %u in checkpoint record, before reaching minimum recovery point %X/%X on timeline %u" ,
2366+ (errcode (ERRCODE_DATA_CORRUPTED ),
2367+ errmsg ("unexpected timeline ID %u in checkpoint record, before reaching minimum recovery point %X/%X on timeline %u" ,
23532368 newTLI ,
23542369 LSN_FORMAT_ARGS (minRecoveryPoint ),
23552370 minRecoveryPointTLI )));
0 commit comments