data on the current query are only available if the
STATS_COMMAND_STRING 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.)
+ 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.)
|
text
Current query of backend process (NULL if caller is not
- superuser, or STATS_COMMAND_STRING is not enabled)
+ superuser, or is the same user as that of the backend being queried,
+ or STATS_COMMAND_STRING is not enabled)
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;