Skip to content

Commit db5d7cc

Browse files
committed
It would also be handy if users could see their own pg_stat_activity
queries while the rest remain blank. Kevin Brown
1 parent bd18c50 commit db5d7cc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.16 2003/03/20 03:34:55 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.17 2003/03/20 18:51:16 momjian Exp $
33
-->
44

55
<chapter id="monitoring">
@@ -212,9 +212,10 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
212212
data on the current query are only available if the
213213
<varname>STATS_COMMAND_STRING</varname> configuration option has
214214
been enabled. Furthermore, these columns can only be accessed by
215-
superusers; to other users, they always appear NULL. (Note that
216-
because of the collector's reporting delay, current query will
217-
only be up-to-date for long-running queries.)</entry>
215+
superusers; or when the user examining the view is the same as the user
216+
in the row; for others it reads as null. (Note that because of the
217+
collector's reporting delay, current query will only be up-to-date for
218+
long-running queries.)</entry>
218219
</row>
219220

220221
<row>
@@ -534,7 +535,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
534535
<entry><type>text</type></entry>
535536
<entry>
536537
Current query of backend process (NULL if caller is not
537-
superuser, or <varname>STATS_COMMAND_STRING</varname> is not enabled)
538+
superuser, or is the same user as that of the backend being queried,
539+
or <varname>STATS_COMMAND_STRING</varname> is not enabled)
538540
</entry>
539541
</row>
540542

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@ pg_stat_get_backend_activity(PG_FUNCTION_ARGS)
284284
int len;
285285
text *result;
286286

287-
if (!superuser())
288-
PG_RETURN_NULL();
289-
290287
beid = PG_GETARG_INT32(0);
291288

292289
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
293290
PG_RETURN_NULL();
294291

292+
if (!superuser() && beentry->userid != GetUserId())
293+
PG_RETURN_NULL();
294+
295295
len = strlen(beentry->activity);
296296
result = palloc(VARHDRSZ + len);
297297
VARATT_SIZEP(result) = VARHDRSZ + len;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy