From 147f454d32a6e29c29a3fa24e41304488c93baf1 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 28 Sep 2020 10:43:32 +0900 Subject: [PATCH] Minor sanity check for control file extraction functions If the control file couldn't be parsed for whatever reason, return the default value for the requested parameter. It'd be better to have the caller pass in a pointer to the parameter and have the function return bool so the caller doesn't assume the control file was read successfully. This is important for handling DBState, where no "value unknown" default is available. --- controldata.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/controldata.c b/controldata.c index ce90bd24..e52d605f 100644 --- a/controldata.c +++ b/controldata.c @@ -90,7 +90,9 @@ get_system_identifier(const char *data_directory) uint64 system_identifier = UNKNOWN_SYSTEM_IDENTIFIER; control_file_info = get_controlfile(data_directory); - system_identifier = control_file_info->system_identifier; + + if (control_file_info->control_file_processed == true) + system_identifier = control_file_info->system_identifier; pfree(control_file_info); @@ -122,7 +124,8 @@ get_latest_checkpoint_location(const char *data_directory) control_file_info = get_controlfile(data_directory); - checkPoint = control_file_info->checkPoint; + if (control_file_info->control_file_processed == true) + checkPoint = control_file_info->checkPoint; pfree(control_file_info); @@ -138,7 +141,8 @@ get_data_checksum_version(const char *data_directory) control_file_info = get_controlfile(data_directory); - data_checksum_version = (int) control_file_info->data_checksum_version; + if (control_file_info->control_file_processed == true) + data_checksum_version = (int) control_file_info->data_checksum_version; pfree(control_file_info);