diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-08-19 01:36:34 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-08-19 01:36:34 +0000 |
commit | 9bf760f7dec703aa34d9bd68aaa982943d24411e (patch) | |
tree | f36eed206a58dce384a76c27f77213a6444aaef7 /src/backend/postmaster/pgstat.c | |
parent | 1be439084a380bc3f1576e2a2834839e508122dd (diff) |
Add a 'waiting' column to pg_stat_activity to carry the same information
that ps_status provides by appending 'waiting' to the PS display. This
completes the project of making it feasible to turn off process title
updates and instead rely on pg_stat_activity. Per my suggestion a few
weeks ago.
Diffstat (limited to 'src/backend/postmaster/pgstat.c')
-rw-r--r-- | src/backend/postmaster/pgstat.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index c971c06704a..a37d9fa349f 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -13,7 +13,7 @@ * * Copyright (c) 2001-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.136 2006/07/16 18:17:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.137 2006/08/19 01:36:24 tgl Exp $ * ---------- */ #include "postgres.h" @@ -1358,6 +1358,7 @@ pgstat_bestart(void) beentry->st_databaseid = MyDatabaseId; beentry->st_userid = userid; beentry->st_clientaddr = clientaddr; + beentry->st_waiting = false; beentry->st_activity[0] = '\0'; /* Also make sure the last byte in the string area is always 0 */ beentry->st_activity[PGBE_ACTIVITY_SIZE - 1] = '\0'; @@ -1446,6 +1447,31 @@ pgstat_report_activity(const char *cmd_str) /* ---------- + * pgstat_report_waiting() - + * + * Called from lock manager to report beginning or end of a lock wait. + * ---------- + */ +void +pgstat_report_waiting(bool waiting) +{ + volatile PgBackendStatus *beentry; + + if (!pgstat_collect_querystring) + return; + + /* + * Since this is a single-byte field in a struct that only this process + * may modify, there seems no need to bother with the st_changecount + * protocol. The update must appear atomic in any case. + */ + beentry = MyBEEntry; + + beentry->st_waiting = waiting; +} + + +/* ---------- * pgstat_read_current_status() - * * Copy the current contents of the PgBackendStatus array to local memory, |