From 9bf760f7dec703aa34d9bd68aaa982943d24411e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 19 Aug 2006 01:36:34 +0000 Subject: 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. --- src/backend/postmaster/pgstat.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/backend/postmaster/pgstat.c') 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'; @@ -1445,6 +1446,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() - * -- cgit v1.2.3