mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Fix CRC check handling in get_controlfile
The previous patch broke this by returning NULL for a failed CRC check, which pg_controldata would then try to read. Fix by returning the result of the CRC check in a separate argument. Michael Paquier and myself
This commit is contained in:
@ -34,6 +34,7 @@ pg_control_system(PG_FUNCTION_ARGS)
|
||||
TupleDesc tupdesc;
|
||||
HeapTuple htup;
|
||||
ControlFileData *ControlFile;
|
||||
bool crc_ok;
|
||||
|
||||
/*
|
||||
* Construct a tuple descriptor for the result row. This must match this
|
||||
@ -51,8 +52,8 @@ pg_control_system(PG_FUNCTION_ARGS)
|
||||
tupdesc = BlessTupleDesc(tupdesc);
|
||||
|
||||
/* read the control file */
|
||||
ControlFile = get_controlfile(DataDir, NULL);
|
||||
if (!ControlFile)
|
||||
ControlFile = get_controlfile(DataDir, NULL, &crc_ok);
|
||||
if (!crc_ok)
|
||||
ereport(ERROR,
|
||||
(errmsg("calculated CRC checksum does not match value stored in file")));
|
||||
|
||||
@ -83,6 +84,7 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
|
||||
ControlFileData *ControlFile;
|
||||
XLogSegNo segno;
|
||||
char xlogfilename[MAXFNAMELEN];
|
||||
bool crc_ok;
|
||||
|
||||
/*
|
||||
* Construct a tuple descriptor for the result row. This must match this
|
||||
@ -130,8 +132,8 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
|
||||
tupdesc = BlessTupleDesc(tupdesc);
|
||||
|
||||
/* Read the control file. */
|
||||
ControlFile = get_controlfile(DataDir, NULL);
|
||||
if (!ControlFile)
|
||||
ControlFile = get_controlfile(DataDir, NULL, &crc_ok);
|
||||
if (!crc_ok)
|
||||
ereport(ERROR,
|
||||
(errmsg("calculated CRC checksum does not match value stored in file")));
|
||||
|
||||
@ -216,6 +218,7 @@ pg_control_recovery(PG_FUNCTION_ARGS)
|
||||
TupleDesc tupdesc;
|
||||
HeapTuple htup;
|
||||
ControlFileData *ControlFile;
|
||||
bool crc_ok;
|
||||
|
||||
/*
|
||||
* Construct a tuple descriptor for the result row. This must match this
|
||||
@ -235,8 +238,8 @@ pg_control_recovery(PG_FUNCTION_ARGS)
|
||||
tupdesc = BlessTupleDesc(tupdesc);
|
||||
|
||||
/* read the control file */
|
||||
ControlFile = get_controlfile(DataDir, NULL);
|
||||
if (!ControlFile)
|
||||
ControlFile = get_controlfile(DataDir, NULL, &crc_ok);
|
||||
if (!crc_ok)
|
||||
ereport(ERROR,
|
||||
(errmsg("calculated CRC checksum does not match value stored in file")));
|
||||
|
||||
@ -268,6 +271,7 @@ pg_control_init(PG_FUNCTION_ARGS)
|
||||
TupleDesc tupdesc;
|
||||
HeapTuple htup;
|
||||
ControlFileData *ControlFile;
|
||||
bool crc_ok;
|
||||
|
||||
/*
|
||||
* Construct a tuple descriptor for the result row. This must match this
|
||||
@ -303,8 +307,8 @@ pg_control_init(PG_FUNCTION_ARGS)
|
||||
tupdesc = BlessTupleDesc(tupdesc);
|
||||
|
||||
/* read the control file */
|
||||
ControlFile = get_controlfile(DataDir, NULL);
|
||||
if (!ControlFile)
|
||||
ControlFile = get_controlfile(DataDir, NULL, &crc_ok);
|
||||
if (!crc_ok)
|
||||
ereport(ERROR,
|
||||
(errmsg("calculated CRC checksum does not match value stored in file")));
|
||||
|
||||
|
Reference in New Issue
Block a user