diff options
author | Bruce Momjian <bruce@momjian.us> | 2003-03-20 18:51:16 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2003-03-20 18:51:16 +0000 |
commit | db5d7ccac99e4b1f3ea0d09f7fc1b6f0682f336d (patch) | |
tree | eb785027752bc54f832cac19480789f80f4f50ca | |
parent | bd18c50ba87f12d1dc0aa65c1ff0507b2d1c5c41 (diff) | |
download | postgresql-db5d7ccac99e4b1f3ea0d09f7fc1b6f0682f336d.tar.gz postgresql-db5d7ccac99e4b1f3ea0d09f7fc1b6f0682f336d.zip |
It would also be handy if users could see their own pg_stat_activity
queries while the rest remain blank.
Kevin Brown
-rw-r--r-- | doc/src/sgml/monitoring.sgml | 12 | ||||
-rw-r--r-- | src/backend/utils/adt/pgstatfuncs.c | 6 |
2 files changed, 10 insertions, 8 deletions
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 002134c9acd..48bbe9561bb 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.16 2003/03/20 03:34:55 momjian Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.17 2003/03/20 18:51:16 momjian Exp $ --> <chapter id="monitoring"> @@ -212,9 +212,10 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re data on the current query are only available if the <varname>STATS_COMMAND_STRING</varname> configuration option has been enabled. Furthermore, these columns can only be accessed by - superusers; to other users, they always appear NULL. (Note that - because of the collector's reporting delay, current query will - only be up-to-date for long-running queries.)</entry> + 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.)</entry> </row> <row> @@ -534,7 +535,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re <entry><type>text</type></entry> <entry> Current query of backend process (NULL if caller is not - superuser, or <varname>STATS_COMMAND_STRING</varname> is not enabled) + superuser, or is the same user as that of the backend being queried, + or <varname>STATS_COMMAND_STRING</varname> is not enabled) </entry> </row> diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 455da1c2aa9..c2f0ea2c829 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -284,14 +284,14 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS) 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); result = palloc(VARHDRSZ + len); VARATT_SIZEP(result) = VARHDRSZ + len; |