diff options
author | Magnus Hagander | 2012-01-19 13:19:20 +0000 |
---|---|---|
committer | Magnus Hagander | 2012-01-19 13:19:20 +0000 |
commit | 4f42b546fd87a80be30c53a0f2c897acb826ad52 (patch) | |
tree | e0831a3ac1373da87d1dd7e8c75071448e797141 /src/include/pgstat.h | |
parent | fa352d662e57fa150158b9cb0a8f127250f8c97f (diff) |
Separate state from query string in pg_stat_activity
This separates the state (running/idle/idleintransaction etc) into
it's own field ("state"), and leaves the query field containing just
query text.
The query text will now mean "current query" when a query is running
and "last query" in other states. Accordingly,the field has been
renamed from current_query to query.
Since backwards compatibility was broken anyway to make that, the procpid
field has also been renamed to pid - along with the same field in
pg_stat_replication for consistency.
Scott Mead and Magnus Hagander, review work from Greg Smith
Diffstat (limited to 'src/include/pgstat.h')
-rw-r--r-- | src/include/pgstat.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/include/pgstat.h b/src/include/pgstat.h index b8c6d82d0ea..fa52447048d 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -589,10 +589,25 @@ typedef struct PgStat_GlobalStats /* ---------- + * Backend states + * ---------- + */ +typedef enum BackendState { + STATE_UNDEFINED, + STATE_IDLE, + STATE_RUNNING, + STATE_IDLEINTRANSACTION, + STATE_FASTPATH, + STATE_IDLEINTRANSACTION_ABORTED, + STATE_DISABLED, +} BackendState; + +/* ---------- * Shared-memory data structures * ---------- */ + /* ---------- * PgBackendStatus * @@ -622,6 +637,7 @@ typedef struct PgBackendStatus TimestampTz st_proc_start_timestamp; TimestampTz st_xact_start_timestamp; TimestampTz st_activity_start_timestamp; + TimestampTz st_state_start_timestamp; /* Database OID, owning user's OID, connection client address */ Oid st_databaseid; @@ -632,6 +648,9 @@ typedef struct PgBackendStatus /* Is backend currently waiting on an lmgr lock? */ bool st_waiting; + /* current state */ + BackendState st_state; + /* application name; MUST be null-terminated */ char *st_appname; @@ -715,7 +734,7 @@ extern void pgstat_report_recovery_conflict(int reason); extern void pgstat_initialize(void); extern void pgstat_bestart(void); -extern void pgstat_report_activity(const char *cmd_str); +extern void pgstat_report_activity(BackendState state, const char *cmd_str); extern void pgstat_report_appname(const char *appname); extern void pgstat_report_xact_timestamp(TimestampTz tstamp); extern void pgstat_report_waiting(bool waiting); |