summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut2020-03-11 15:36:40 +0000
committerPeter Eisentraut2020-03-13 13:01:10 +0000
commit8e8a0becb335529c66a9f82f88e1419e49b458ae (patch)
tree20eb3ec548fcf2d37ae150f44c1c7949ee9fda5a /src/include
parent1cc9c2412cc9a2fbe6a381170097d315fd40ccca (diff)
Unify several ways to tracking backend type
Add a new global variable MyBackendType that uses the same BackendType enum that was previously only used by the stats collector. That way several duplicate ways of checking what type a particular process is can be simplified. Since it's no longer just for stats, move to miscinit.c and rename existing functions to match the expanded purpose. Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Reviewed-by: Kuntal Ghosh <kuntalghosh.2007@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/flat/c65e5196-4f04-4ead-9353-6088c19615a3@2ndquadrant.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/miscadmin.h22
-rw-r--r--src/include/pgstat.h21
2 files changed, 23 insertions, 20 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 6b9093733fb..14fa127ab11 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -306,6 +306,28 @@ extern void InitStandaloneProcess(const char *argv0);
extern void SwitchToSharedLatch(void);
extern void SwitchBackToLocalLatch(void);
+typedef enum BackendType
+{
+ B_INVALID = 0,
+ B_AUTOVAC_LAUNCHER,
+ B_AUTOVAC_WORKER,
+ B_BACKEND,
+ B_BG_WORKER,
+ B_BG_WRITER,
+ B_CHECKPOINTER,
+ B_STARTUP,
+ B_WAL_RECEIVER,
+ B_WAL_SENDER,
+ B_WAL_WRITER,
+ B_ARCHIVER,
+ B_STATS_COLLECTOR,
+ B_LOGGER,
+} BackendType;
+
+extern BackendType MyBackendType;
+
+extern const char *GetBackendTypeDesc(BackendType backendType);
+
extern void SetDatabasePath(const char *path);
extern void checkDataDir(void);
extern void SetDataDir(const char *dir);
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 7bc36c65838..1a19921f803 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -13,6 +13,7 @@
#include "datatype/timestamp.h"
#include "libpq/pqcomm.h"
+#include "miscadmin.h"
#include "port/atomics.h"
#include "portability/instr_time.h"
#include "postmaster/pgarch.h"
@@ -713,25 +714,6 @@ typedef struct PgStat_GlobalStats
/* ----------
- * Backend types
- * ----------
- */
-typedef enum BackendType
-{
- B_AUTOVAC_LAUNCHER,
- B_AUTOVAC_WORKER,
- B_BACKEND,
- B_BG_WORKER,
- B_BG_WRITER,
- B_CHECKPOINTER,
- B_STARTUP,
- B_WAL_RECEIVER,
- B_WAL_SENDER,
- B_WAL_WRITER
-} BackendType;
-
-
-/* ----------
* Backend states
* ----------
*/
@@ -1286,7 +1268,6 @@ extern const char *pgstat_get_wait_event_type(uint32 wait_event_info);
extern const char *pgstat_get_backend_current_activity(int pid, bool checkUser);
extern const char *pgstat_get_crashed_backend_activity(int pid, char *buffer,
int buflen);
-extern const char *pgstat_get_backend_desc(BackendType backendType);
extern void pgstat_progress_start_command(ProgressCommandType cmdtype,
Oid relid);