Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dbfc447

Browse files
committed
Expose new function get_controlfile_by_exact_path().
This works just like get_controlfile(), but expects the path to the control file rather than the path to the data directory that contains the control file. This makes more sense in cases where the caller has already constructed the path to the control file itself. Amul Sul and Robert Haas, reviewed by Michael Paquier
1 parent 97d85be commit dbfc447

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/bin/pg_combinebackup/pg_combinebackup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ check_control_files(int n_backups, char **backup_dirs)
534534

535535
controlpath = psprintf("%s/%s", backup_dirs[i], "global/pg_control");
536536
pg_log_debug("reading \"%s\"", controlpath);
537-
control_file = get_controlfile(backup_dirs[i], &crc_ok);
537+
control_file = get_controlfile_by_exact_path(controlpath, &crc_ok);
538538

539539
/* Control file contents not meaningful if CRC is bad. */
540540
if (!crc_ok)

src/common/controldata_utils.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,25 @@
5050
*/
5151
ControlFileData *
5252
get_controlfile(const char *DataDir, bool *crc_ok_p)
53+
{
54+
char ControlFilePath[MAXPGPATH];
55+
56+
snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
57+
58+
return get_controlfile_by_exact_path(ControlFilePath, crc_ok_p);
59+
}
60+
61+
/*
62+
* get_controlfile_by_exact_path()
63+
*
64+
* As above, but the caller specifies the path to the control file itself,
65+
* rather than the path to the data directory.
66+
*/
67+
ControlFileData *
68+
get_controlfile_by_exact_path(const char *ControlFilePath, bool *crc_ok_p)
5369
{
5470
ControlFileData *ControlFile;
5571
int fd;
56-
char ControlFilePath[MAXPGPATH];
5772
pg_crc32c crc;
5873
int r;
5974
#ifdef FRONTEND
@@ -64,7 +79,6 @@ get_controlfile(const char *DataDir, bool *crc_ok_p)
6479
Assert(crc_ok_p);
6580

6681
ControlFile = palloc_object(ControlFileData);
67-
snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
6882

6983
#ifdef FRONTEND
7084
INIT_CRC32C(last_crc);

src/include/common/controldata_utils.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "catalog/pg_control.h"
1414

1515
extern ControlFileData *get_controlfile(const char *DataDir, bool *crc_ok_p);
16+
extern ControlFileData *get_controlfile_by_exact_path(const char *ControlFilePath,
17+
bool *crc_ok_p);
1618
extern void update_controlfile(const char *DataDir,
1719
ControlFileData *ControlFile, bool do_sync);
1820

0 commit comments

Comments
 (0)