Index: doc/src/sgml/monitoring.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/monitoring.sgml,v
retrieving revision 1.15
diff -u -d -r1.15 monitoring.sgml
--- doc/src/sgml/monitoring.sgml 2002/11/11 20:14:03 1.15
+++ doc/src/sgml/monitoring.sgml 2003/03/07 06:58:05
@@ -204,12 +204,16 @@
- pg_stat_activity>
- One row per server process, showing process ID>, database,
- user, and current query. The current query column is only available
- to superusers; for others it reads as null. (Note that because of
- the collector's reporting delay, current query will only be up-to-date
- for long-running queries.)
+ pg_stat_activity> One row
+ per server process, showing process ID>, database,
+ user, and current query. Values in the current query column are
+ only available to superusers, or when the user examining the
+ view is the same as the user in the row; for others it reads as
+ null. (Note that because of the collector's reporting delay,
+ current query will only be up-to-date for long-running
+ queries.). STATS_COMMAND_STRING must be
+ enabled for anything to show in the current query
+ column.
@@ -518,7 +522,8 @@
pg_stat_get_backend_activity(integer)
text
- Current query of backend process (NULL if caller is not superuser)
+ Current query of backend process (NULL unless caller is
+ superuser or is the same user as that of the backend being queried)
Index: src/backend/utils/adt/pgstatfuncs.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/adt/pgstatfuncs.c,v
retrieving revision 1.9
diff -u -d -r1.9 pgstatfuncs.c
--- src/backend/utils/adt/pgstatfuncs.c 2002/12/04 05:18:34 1.9
+++ src/backend/utils/adt/pgstatfuncs.c 2003/03/07 06:58:05
@@ -284,12 +284,12 @@
int len;
text *result;
- if (!superuser())
- PG_RETURN_NULL();
-
beid = PG_GETARG_INT32(0);
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
+ PG_RETURN_NULL();
+
+ if (!superuser() && beentry->userid != GetUserId())
PG_RETURN_NULL();
len = strlen(beentry->activity);