Re: pg_stat_activity

From: Kevin Brown <kevin(at)sysexperts(dot)com>
To: pgsql-hackers list <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stat_activity
Date: 2003-07-07 22:48:06
Message-ID: 20030707224806.GH16911@filer
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

ivan wrote:
>
> You can create function with security definer as super user
> sth like this
> create or replace function func () returns setof pg_stat_activity as '
> select * from pg_stat_activity ; ' language SQL SECURITY DEFINER;
>
> and if you want to se only query of session user you need to replace
> * to columns from view pg_stat_activity , and to column query
> you need to use CASE , when username == SESSION_USER : cur_query,
> else null;

This won't work for what he's asking for. The problem is that
pg_stat_activity is actually a view that uses an internal function to
retrieve the command list. The problem is that the internal function
itself is what contains the logic that decides whether or not to show the
command based on whether or not the user issuing the query is superuser.

I created a patch to address this (so that users can see their own
commands), and 7.4 incorporates the patch. You can probably retrieve
it by searching the pgsql-patches archives, but I can also email the
patch to whomever's interested.

--
Kevin Brown kevin(at)sysexperts(dot)com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2003-07-08 01:14:23 Re: [HACKERS] again: Bug #943: Server-Encoding from EUC_TW
Previous Message Dmitry Tkach 2003-07-07 21:58:53 Re: Backwards index scan