diff options
author | Robert Haas <rhaas@postgresql.org> | 2024-03-13 12:06:44 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2024-03-13 12:06:44 -0400 |
commit | dbfc44716596073b99e093a04e29e774a518f520 (patch) | |
tree | 54633322a838768f020053bea59f391e313422ec /src/common/controldata_utils.c | |
parent | 97d85be365443eb4bf84373a7468624762382059 (diff) | |
download | postgresql-dbfc44716596073b99e093a04e29e774a518f520.tar.gz postgresql-dbfc44716596073b99e093a04e29e774a518f520.zip |
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
Diffstat (limited to 'src/common/controldata_utils.c')
-rw-r--r-- | src/common/controldata_utils.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/common/controldata_utils.c b/src/common/controldata_utils.c index 92e8fed6b2e..82309b25107 100644 --- a/src/common/controldata_utils.c +++ b/src/common/controldata_utils.c @@ -51,9 +51,24 @@ 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 @@ -64,7 +79,6 @@ get_controlfile(const char *DataDir, bool *crc_ok_p) Assert(crc_ok_p); ControlFile = palloc_object(ControlFileData); - snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir); #ifdef FRONTEND INIT_CRC32C(last_crc); |