Thread: Re: [HACKERS] stats_command_string default?

Re: [HACKERS] stats_command_string default?

From
Kevin Brown
Date:
Tom Lane wrote:
> Kevin Brown <kevin@sysexperts.com> writes:

[...]

> > It would also be handy if users could see their own queries while the
> > rest remain blank.  That would require changing
> > pg_stat_get_backend_activity() so that it returns a value if the user
> > is the superuser or if the user asking for the answer is the same as
> > the user who owns the backend entry being looked up.  Are there any
> > pitfalls to implementing that?
>
> Seems reasonable offhand ...

Here's the patch to make this happen.  The first is against 7.2.4, the
second is against CVS tip.


If I got it wrong and need to use something other than GetUserId(),
please let me know.



--
Kevin Brown                          kevin@sysexperts.com

Attachment

Re: [HACKERS] stats_command_string default?

From
Tom Lane
Date:
Kevin Brown <kevin@sysexperts.com> writes:
>>> It would also be handy if users could see their own queries while the
>>> rest remain blank.
>>
>> Seems reasonable offhand ...

> Here's the patch to make this happen.  The first is against 7.2.4, the
> second is against CVS tip.

You forgot documentation fixes.  Certainly the entry in
http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/monitoring-stats.html#MONITORING-STATS-VIEWS
needs to change; not sure if there are any other places, but that's your
task to look...

Also, submitting a patch against two revs back is a waste of time.  Only
*very* critical bug fixes would get applied against 7.2.* at this point.
This isn't likely to get into 7.3.* either.

The code itself looks fine though ;-)

            regards, tom lane

Re: [HACKERS] stats_command_string default?

From
Kevin Brown
Date:
Tom Lane wrote:
> Kevin Brown <kevin@sysexperts.com> writes:
> >>> It would also be handy if users could see their own queries while the
> >>> rest remain blank.
> >>
> >> Seems reasonable offhand ...
>
> > Here's the patch to make this happen.  The first is against 7.2.4, the
> > second is against CVS tip.
>
> You forgot documentation fixes.  Certainly the entry in
> http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/monitoring-stats.html#MONITORING-STATS-VIEWS
> needs to change; not sure if there are any other places, but that's your
> task to look...

Ooops.  Okay, the attached patch attached fixes that as well.  The
only references to pg_stat_get_backend_activity(), pg_stat_activity,
or stats_command_string that needed to be changed were those in
doc/src/monitoring.sgml.  If I missed something let me know.

So: the following patch fixes doc/src/monitoring.sgml and
src/backend/utils/adt/pgstatfuncs.c to make it possible to see your
own queries when looking at pg_stat_activity or when using the
pg_stat_get_backend_activity function.  The patch is against the
current (as of now :-) CVS tip.

--
Kevin Brown                          kevin@sysexperts.com

Attachment

Re: [HACKERS] stats_command_string default?

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Kevin Brown wrote:
> Tom Lane wrote:
> > Kevin Brown <kevin@sysexperts.com> writes:
> > >>> It would also be handy if users could see their own queries while the
> > >>> rest remain blank.
> > >>
> > >> Seems reasonable offhand ...
> >
> > > Here's the patch to make this happen.  The first is against 7.2.4, the
> > > second is against CVS tip.
> >
> > You forgot documentation fixes.  Certainly the entry in
> > http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/monitoring-stats.html#MONITORING-STATS-VIEWS
> > needs to change; not sure if there are any other places, but that's your
> > task to look...
>
> Ooops.  Okay, the attached patch attached fixes that as well.  The
> only references to pg_stat_get_backend_activity(), pg_stat_activity,
> or stats_command_string that needed to be changed were those in
> doc/src/monitoring.sgml.  If I missed something let me know.
>
> So: the following patch fixes doc/src/monitoring.sgml and
> src/backend/utils/adt/pgstatfuncs.c to make it possible to see your
> own queries when looking at pg_stat_activity or when using the
> pg_stat_get_backend_activity function.  The patch is against the
> current (as of now :-) CVS tip.
>
> --
> Kevin Brown                          kevin@sysexperts.com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] stats_command_string default?

From
Bruce Momjian
Date:
Patch applied.  Thanks.

I merge the SGML in around recent additions.

---------------------------------------------------------------------------



Kevin Brown wrote:
> Tom Lane wrote:
> > Kevin Brown <kevin@sysexperts.com> writes:
> > >>> It would also be handy if users could see their own queries while the
> > >>> rest remain blank.
> > >>
> > >> Seems reasonable offhand ...
> >
> > > Here's the patch to make this happen.  The first is against 7.2.4, the
> > > second is against CVS tip.
> >
> > You forgot documentation fixes.  Certainly the entry in
> > http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/monitoring-stats.html#MONITORING-STATS-VIEWS
> > needs to change; not sure if there are any other places, but that's your
> > task to look...
>
> Ooops.  Okay, the attached patch attached fixes that as well.  The
> only references to pg_stat_get_backend_activity(), pg_stat_activity,
> or stats_command_string that needed to be changed were those in
> doc/src/monitoring.sgml.  If I missed something let me know.
>
> So: the following patch fixes doc/src/monitoring.sgml and
> src/backend/utils/adt/pgstatfuncs.c to make it possible to see your
> own queries when looking at pg_stat_activity or when using the
> pg_stat_get_backend_activity function.  The patch is against the
> current (as of now :-) CVS tip.
>
> --
> Kevin Brown                          kevin@sysexperts.com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073