mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Code review for pg_stat_get_backend_activity_start patch --- fix
return type, make protection condition agree with recent change to pg_stat_get_backend_activity, clean up documentation.
This commit is contained in:
parent
a385186ff7
commit
3b4ca4c0d9
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.19 2003/03/25 16:15:37 petere Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v 1.20 2003/04/04 03:03:53 tgl Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<chapter id="monitoring">
|
<chapter id="monitoring">
|
||||||
@ -208,9 +208,9 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
|
|||||||
which the current query began execution. The columns that report
|
which the current query began execution. The columns that report
|
||||||
data on the current query are only available if the parameter
|
data on the current query are only available if the parameter
|
||||||
<varname>stats_command_string</varname> has been turned on.
|
<varname>stats_command_string</varname> has been turned on.
|
||||||
Furthermore, these columns can only be accessed by
|
Furthermore, these columns read as null unless the user examining
|
||||||
superusers; or when the user examining the view is the same as the user
|
the view is a superuser or the same as the user owning the process
|
||||||
in the row; for others it reads as null. (Note that because of the
|
being reported on. (Note that because of the
|
||||||
collector's reporting delay, current query will only be up-to-date for
|
collector's reporting delay, current query will only be up-to-date for
|
||||||
long-running queries.)</entry>
|
long-running queries.)</entry>
|
||||||
</row>
|
</row>
|
||||||
@ -540,16 +540,16 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
|
|||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry><literal><function>pg_stat_get_backend_activity_start</function>(<type>integer</type>)</literal></entry>
|
<entry><literal><function>pg_stat_get_backend_activity_start</function>(<type>integer</type>)</literal></entry>
|
||||||
<entry><type>text</type></entry>
|
<entry><type>timestamp with time zone</type></entry>
|
||||||
<entry>
|
<entry>
|
||||||
The time at which the specified backend process' currently
|
The time at which the given backend process' currently
|
||||||
executing query was started (null if the current user is not a
|
executing query was started (null if the
|
||||||
superuser, or <varname>stats_command_string</varname> is not
|
current user is not a superuser nor the same user as that of
|
||||||
on)
|
the session being queried, or
|
||||||
|
<varname>stats_command_string</varname> is not on)
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry><literal><function>pg_stat_reset</function>()</literal></entry>
|
<entry><literal><function>pg_stat_reset</function>()</literal></entry>
|
||||||
<entry><type>boolean</type></entry>
|
<entry><type>boolean</type></entry>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.176 2003/04/03 23:32:47 tgl Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.177 2003/04/04 03:03:53 tgl Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Chapter Id="runtime">
|
<Chapter Id="runtime">
|
||||||
@ -1176,8 +1176,9 @@ SET ENABLE_SEQSCAN TO OFF;
|
|||||||
Enables the collection of statistics on the currently
|
Enables the collection of statistics on the currently
|
||||||
executing command of each session, along with the time at
|
executing command of each session, along with the time at
|
||||||
which that command began execution. This option is off by
|
which that command began execution. This option is off by
|
||||||
default. Note that even when enabled, this information is only
|
default. Note that even when enabled, this information is not
|
||||||
visible to the superuser, so it should not represent a
|
visible to all users, only to superusers and the user owning
|
||||||
|
the session being reported on; so it should not represent a
|
||||||
security risk. This data can be accessed via the
|
security risk. This data can be accessed via the
|
||||||
<structname>pg_stat_activity</structname> system view; refer
|
<structname>pg_stat_activity</structname> system view; refer
|
||||||
to <xref linkend="monitoring"> for more information.
|
to <xref linkend="monitoring"> for more information.
|
||||||
|
@ -308,14 +308,14 @@ pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)
|
|||||||
int32 beid;
|
int32 beid;
|
||||||
AbsoluteTime sec;
|
AbsoluteTime sec;
|
||||||
int usec;
|
int usec;
|
||||||
Timestamp result;
|
TimestampTz result;
|
||||||
|
|
||||||
beid = PG_GETARG_INT32(0);
|
beid = PG_GETARG_INT32(0);
|
||||||
|
|
||||||
if (!superuser())
|
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
if ((beentry = pgstat_fetch_stat_beentry(beid)) == NULL)
|
if (!superuser() && beentry->userid != GetUserId())
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
sec = beentry->activity_start_sec;
|
sec = beentry->activity_start_sec;
|
||||||
@ -341,7 +341,7 @@ pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS)
|
|||||||
date2j(1970, 1, 1)) * 86400));
|
date2j(1970, 1, 1)) * 86400));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PG_RETURN_TIMESTAMP(result);
|
PG_RETURN_TIMESTAMPTZ(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
# Portions Copyright (c) 1994, Regents of the University of California
|
# Portions Copyright (c) 1994, Regents of the University of California
|
||||||
#
|
#
|
||||||
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.187 2003/03/25 16:15:44 petere Exp $
|
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.188 2003/04/04 03:03:53 tgl Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -954,7 +954,7 @@ CREATE VIEW pg_stat_activity AS \
|
|||||||
pg_stat_get_backend_userid(S.backendid) AS usesysid, \
|
pg_stat_get_backend_userid(S.backendid) AS usesysid, \
|
||||||
U.usename AS usename, \
|
U.usename AS usename, \
|
||||||
pg_stat_get_backend_activity(S.backendid) AS current_query, \
|
pg_stat_get_backend_activity(S.backendid) AS current_query, \
|
||||||
pg_stat_get_backend_activity_start(S.backendid) AS query_start \
|
pg_stat_get_backend_activity_start(S.backendid) AS query_start \
|
||||||
FROM pg_database D, \
|
FROM pg_database D, \
|
||||||
(SELECT pg_stat_get_backend_idset() AS backendid) AS S, \
|
(SELECT pg_stat_get_backend_idset() AS backendid) AS S, \
|
||||||
pg_shadow U \
|
pg_shadow U \
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: pg_proc.h,v 1.290 2003/03/21 21:54:29 momjian Exp $
|
* $Id: pg_proc.h,v 1.291 2003/04/04 03:03:54 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* The script catalog/genbki.sh reads this file and generates .bki
|
* The script catalog/genbki.sh reads this file and generates .bki
|
||||||
@ -2745,7 +2745,7 @@ DATA(insert OID = 1939 ( pg_stat_get_backend_userid PGNSP PGUID 12 f f t f s 1
|
|||||||
DESCR("Statistics: User ID of backend");
|
DESCR("Statistics: User ID of backend");
|
||||||
DATA(insert OID = 1940 ( pg_stat_get_backend_activity PGNSP PGUID 12 f f t f s 1 25 "23" pg_stat_get_backend_activity - _null_ ));
|
DATA(insert OID = 1940 ( pg_stat_get_backend_activity PGNSP PGUID 12 f f t f s 1 25 "23" pg_stat_get_backend_activity - _null_ ));
|
||||||
DESCR("Statistics: Current query of backend");
|
DESCR("Statistics: Current query of backend");
|
||||||
DATA(insert OID = 2094 ( pg_stat_get_backend_activity_start PGNSP PGUID 12 f f t f s 1 1114 "23" pg_stat_get_backend_activity_start - _null_));
|
DATA(insert OID = 2094 ( pg_stat_get_backend_activity_start PGNSP PGUID 12 f f t f s 1 1184 "23" pg_stat_get_backend_activity_start - _null_));
|
||||||
DESCR("Statistics: Start time for current query of backend");
|
DESCR("Statistics: Start time for current query of backend");
|
||||||
DATA(insert OID = 1941 ( pg_stat_get_db_numbackends PGNSP PGUID 12 f f t f s 1 23 "26" pg_stat_get_db_numbackends - _null_ ));
|
DATA(insert OID = 1941 ( pg_stat_get_db_numbackends PGNSP PGUID 12 f f t f s 1 23 "26" pg_stat_get_db_numbackends - _null_ ));
|
||||||
DESCR("Statistics: Number of backends in database");
|
DESCR("Statistics: Number of backends in database");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user