controlpath = psprintf("%s/%s", backup_dirs[i], "global/pg_control");
pg_log_debug("reading \"%s\"", controlpath);
- control_file = get_controlfile(backup_dirs[i], &crc_ok);
+ control_file = get_controlfile_by_exact_path(controlpath, &crc_ok);
/* Control file contents not meaningful if CRC is bad. */
if (!crc_ok)
*/
ControlFileData *
get_controlfile(const char *DataDir, bool *crc_ok_p)
+{
+ char ControlFilePath[MAXPGPATH];
+
+ snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
+
+ return get_controlfile_by_exact_path(ControlFilePath, crc_ok_p);
+}
+
+/*
+ * get_controlfile_by_exact_path()
+ *
+ * As above, but the caller specifies the path to the control file itself,
+ * rather than the path to the data directory.
+ */
+ControlFileData *
+get_controlfile_by_exact_path(const char *ControlFilePath, bool *crc_ok_p)
{
ControlFileData *ControlFile;
int fd;
- char ControlFilePath[MAXPGPATH];
pg_crc32c crc;
int r;
#ifdef FRONTEND
Assert(crc_ok_p);
ControlFile = palloc_object(ControlFileData);
- snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
#ifdef FRONTEND
INIT_CRC32C(last_crc);
#include "catalog/pg_control.h"
extern ControlFileData *get_controlfile(const char *DataDir, bool *crc_ok_p);
+extern ControlFileData *get_controlfile_by_exact_path(const char *ControlFilePath,
+ bool *crc_ok_p);
extern void update_controlfile(const char *DataDir,
ControlFileData *ControlFile, bool do_sync);