aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/backend_progress.h
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2021-04-03 11:42:52 -0700
committerAndres Freund <andres@anarazel.de>2021-04-03 11:42:52 -0700
commite1025044cd4e7f33f7304aed54d5778b8a82cd5d (patch)
tree2f35b9816d3d9040a4629f3899a137a7179565e8 /src/include/utils/backend_progress.h
parent8d3a4c3eae5367fba60ab77c159814defba784fe (diff)
downloadpostgresql-e1025044cd4e7f33f7304aed54d5778b8a82cd5d.tar.gz
postgresql-e1025044cd4e7f33f7304aed54d5778b8a82cd5d.zip
Split backend status and progress related functionality out of pgstat.c.
Backend status (supporting pg_stat_activity) and command progress (supporting pg_stat_progress*) related code is largely independent from the rest of pgstat.[ch] (supporting views like pg_stat_all_tables that accumulate data over time). See also a333476b925. This commit doesn't rename the function names to make the distinction from the rest of pgstat_ clearer - that'd be more invasive and not clearly beneficial. If we were to decide to do such a rename at some point, it's better done separately from moving the code as well. Robert's review was of an earlier version. Reviewed-By: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/20210316195440.twxmlov24rr2nxrg@alap3.anarazel.de
Diffstat (limited to 'src/include/utils/backend_progress.h')
-rw-r--r--src/include/utils/backend_progress.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/include/utils/backend_progress.h b/src/include/utils/backend_progress.h
new file mode 100644
index 00000000000..1714fa09c16
--- /dev/null
+++ b/src/include/utils/backend_progress.h
@@ -0,0 +1,44 @@
+/* ----------
+ * backend_progress.h
+ * Command progress reporting definition.
+ *
+ * Note that this file provides the infrastructure for storing a single
+ * backend's command progress counters, without ascribing meaning to the
+ * individual fields. See commands/progress.h and system_views.sql for that.
+ *
+ * Copyright (c) 2001-2021, PostgreSQL Global Development Group
+ *
+ * src/include/utils/backend_progress.h
+ * ----------
+ */
+#ifndef BACKEND_PROGRESS_H
+#define BACKEND_PROGRESS_H
+
+
+/* ----------
+ * Command type for progress reporting purposes
+ * ----------
+ */
+typedef enum ProgressCommandType
+{
+ PROGRESS_COMMAND_INVALID,
+ PROGRESS_COMMAND_VACUUM,
+ PROGRESS_COMMAND_ANALYZE,
+ PROGRESS_COMMAND_CLUSTER,
+ PROGRESS_COMMAND_CREATE_INDEX,
+ PROGRESS_COMMAND_BASEBACKUP,
+ PROGRESS_COMMAND_COPY
+} ProgressCommandType;
+
+#define PGSTAT_NUM_PROGRESS_PARAM 20
+
+
+extern void pgstat_progress_start_command(ProgressCommandType cmdtype,
+ Oid relid);
+extern void pgstat_progress_update_param(int index, int64 val);
+extern void pgstat_progress_update_multi_param(int nparam, const int *index,
+ const int64 *val);
+extern void pgstat_progress_end_command(void);
+
+
+#endif /* BACKEND_PROGRESS_H */