aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/miscadmin.h27
-rw-r--r--src/include/port.h3
-rw-r--r--src/include/utils/pidfile.h55
3 files changed, 58 insertions, 27 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 21a77289f86..dad98de98d7 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -28,8 +28,6 @@
#include "pgtime.h" /* for pg_time_t */
-#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
-
#define InvalidPid (-1)
@@ -431,31 +429,6 @@ extern char *session_preload_libraries_string;
extern char *shared_preload_libraries_string;
extern char *local_preload_libraries_string;
-/*
- * As of 9.1, the contents of the data-directory lock file are:
- *
- * line #
- * 1 postmaster PID (or negative of a standalone backend's PID)
- * 2 data directory path
- * 3 postmaster start timestamp (time_t representation)
- * 4 port number
- * 5 first Unix socket directory path (empty if none)
- * 6 first listen_address (IP address or "*"; empty if no TCP port)
- * 7 shared memory key (not present on Windows)
- *
- * Lines 6 and up are added via AddToDataDirLockFile() after initial file
- * creation.
- *
- * The socket lock file, if used, has the same contents as lines 1-5.
- */
-#define LOCK_FILE_LINE_PID 1
-#define LOCK_FILE_LINE_DATA_DIR 2
-#define LOCK_FILE_LINE_START_TIME 3
-#define LOCK_FILE_LINE_PORT 4
-#define LOCK_FILE_LINE_SOCKET_DIR 5
-#define LOCK_FILE_LINE_LISTEN_ADDR 6
-#define LOCK_FILE_LINE_SHMEM_KEY 7
-
extern void CreateDataDirLockFile(bool amPostmaster);
extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster,
const char *socketDir);
diff --git a/src/include/port.h b/src/include/port.h
index c2462167e4c..b1ba645655f 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -98,6 +98,9 @@ extern int find_my_exec(const char *argv0, char *retpath);
extern int find_other_exec(const char *argv0, const char *target,
const char *versionstr, char *retpath);
+/* Doesn't belong here, but this is used with find_other_exec(), so... */
+#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
+
/* Windows security token manipulation (in exec.c) */
#ifdef WIN32
extern BOOL AddUserToTokenDacl(HANDLE hToken);
diff --git a/src/include/utils/pidfile.h b/src/include/utils/pidfile.h
new file mode 100644
index 00000000000..c3db4c46e39
--- /dev/null
+++ b/src/include/utils/pidfile.h
@@ -0,0 +1,55 @@
+/*-------------------------------------------------------------------------
+ *
+ * pidfile.h
+ * Declarations describing the data directory lock file (postmaster.pid)
+ *
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/utils/pidfile.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef UTILS_PIDFILE_H
+#define UTILS_PIDFILE_H
+
+/*
+ * As of Postgres 10, the contents of the data-directory lock file are:
+ *
+ * line #
+ * 1 postmaster PID (or negative of a standalone backend's PID)
+ * 2 data directory path
+ * 3 postmaster start timestamp (time_t representation)
+ * 4 port number
+ * 5 first Unix socket directory path (empty if none)
+ * 6 first listen_address (IP address or "*"; empty if no TCP port)
+ * 7 shared memory key (empty on Windows)
+ * 8 postmaster status (see values below)
+ *
+ * Lines 6 and up are added via AddToDataDirLockFile() after initial file
+ * creation; also, line 5 is initially empty and is changed after the first
+ * Unix socket is opened.
+ *
+ * Socket lock file(s), if used, have the same contents as lines 1-5, with
+ * line 5 being their own directory.
+ */
+#define LOCK_FILE_LINE_PID 1
+#define LOCK_FILE_LINE_DATA_DIR 2
+#define LOCK_FILE_LINE_START_TIME 3
+#define LOCK_FILE_LINE_PORT 4
+#define LOCK_FILE_LINE_SOCKET_DIR 5
+#define LOCK_FILE_LINE_LISTEN_ADDR 6
+#define LOCK_FILE_LINE_SHMEM_KEY 7
+#define LOCK_FILE_LINE_PM_STATUS 8
+
+/*
+ * The PM_STATUS line may contain one of these values. All these strings
+ * must be the same length, per comments for AddToDataDirLockFile().
+ * We pad with spaces as needed to make that true.
+ */
+#define PM_STATUS_STARTING "starting" /* still starting up */
+#define PM_STATUS_STOPPING "stopping" /* in shutdown sequence */
+#define PM_STATUS_READY "ready " /* ready for connections */
+#define PM_STATUS_STANDBY "standby " /* up, won't accept connections */
+
+#endif /* UTILS_PIDFILE_H */