summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorPeter Eisentraut2016-07-26 15:23:43 +0000
committerPeter Eisentraut2016-09-21 16:00:00 +0000
commitc1dc51d4844e2a37412b034c07c1c5a439ba0b9d (patch)
tree5da243eb19c5c9d494958a61165a3fbf87974963 /src/common
parenteb5089a05ba0852cc3eafea53c5d23e7633fca81 (diff)
pg_ctl: Detect current standby state from pg_control
pg_ctl used to determine whether a server was in standby mode by looking for a recovery.conf file. With this change, it instead looks into pg_control, which is potentially more accurate. There are also occasional discussions about removing recovery.conf, so this removes one dependency. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/controldata_utils.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/common/controldata_utils.c b/src/common/controldata_utils.c
index 5592fe7039c..f218d2558c1 100644
--- a/src/common/controldata_utils.c
+++ b/src/common/controldata_utils.c
@@ -33,9 +33,11 @@
*
* Get controlfile values. The caller is responsible
* for pfreeing the result.
+ *
+ * Returns NULL if the CRC did not match.
*/
ControlFileData *
-get_controlfile(char *DataDir, const char *progname)
+get_controlfile(const char *DataDir, const char *progname)
{
ControlFileData *ControlFile;
int fd;
@@ -82,13 +84,10 @@ get_controlfile(char *DataDir, const char *progname)
FIN_CRC32C(crc);
if (!EQ_CRC32C(crc, ControlFile->crc))
-#ifndef FRONTEND
- elog(ERROR, _("calculated CRC checksum does not match value stored in file"));
-#else
- printf(_("WARNING: Calculated CRC checksum does not match value stored in file.\n"
- "Either the file is corrupt, or it has a different layout than this program\n"
- "is expecting. The results below are untrustworthy.\n\n"));
-#endif
+ {
+ pfree(ControlFile);
+ return NULL;
+ }
/* Make sure the control file is valid byte order. */
if (ControlFile->pg_control_version % 65536 == 0 &&