OK, renamed to backend_pid() to match the libpq name. I was unsure
about merging it into the stats stuff myself.
setest=> select backend_pid();
backend_pid
-------------
12996
(1 row)
Where does the mention belong in the docs? I have it in the monitoring
section in the stats section right now.
---------------------------------------------------------------------------
Neil Conway wrote:
> On Tue, Jul 30, 2002 at 08:40:13PM -0400, Bruce Momjian wrote:
> > I have implemented this TODO item:
> >
> > * Add getpid() function to backend
> >
> > There were a large number of pg_stat functions that access pids and
> > backends slots so I added it there:
> >
> > test=> select pg_stat_get_backend_mypid();
>
> If we're going to add it to pg_stat_*, why is 'backend' part of the
> name? All the existing backend_* function fetch some piece of data
> about a given backend -- whereas this function does not (it takes
> no arguments).
>
> IMHO, a better name would be something like 'backend_process_id()',
> or 'unix_pid', or 'backend_pid()'.
>
> Also, can you add some documentation on this?
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <[EMAIL PROTECTED]>
> PGP Key ID: DB3C29FC
>
--
Bruce Momjian | http://candle.pha.pa.us
[EMAIL PROTECTED] | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Index: doc/src/sgml/monitoring.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/monitoring.sgml,v
retrieving revision 1.7
diff -c -r1.7 monitoring.sgml
*** doc/src/sgml/monitoring.sgml 22 Mar 2002 19:20:14 -0000 1.7
--- doc/src/sgml/monitoring.sgml 31 Jul 2002 01:42:11 -0000
***************
*** 481,490 ****
</row>
<row>
<entry><function>pg_stat_get_backend_pid</function>(<type>integer</type>)</entry>
<entry><type>integer</type></entry>
<entry>
! PID of backend process
</entry>
</row>
--- 481,498 ----
</row>
<row>
+ <entry><function>backend_pid</function>()</entry>
+ <entry><type>integer</type></entry>
+ <entry>
+ Process ID of current backend
+ </entry>
+ </row>
+
+ <row>
<entry><function>pg_stat_get_backend_pid</function>(<type>integer</type>)</entry>
<entry><type>integer</type></entry>
<entry>
! Process ID of all backend processes
</entry>
</row>
Index: src/backend/utils/adt/pgstatfuncs.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/pgstatfuncs.c,v
retrieving revision 1.5
diff -c -r1.5 pgstatfuncs.c
*** src/backend/utils/adt/pgstatfuncs.c 31 Jul 2002 00:40:40 -0000 1.5
--- src/backend/utils/adt/pgstatfuncs.c 31 Jul 2002 01:42:12 -0000
***************
*** 19,25 ****
extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS);
! extern Datum pg_stat_get_backend_mypid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
--- 19,25 ----
extern Datum pg_stat_get_blocks_hit(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS);
! extern Datum backend_pid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_pid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_dbid(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_backend_userid(PG_FUNCTION_ARGS);
***************
*** 213,219 ****
Datum
! pg_stat_get_backend_mypid(PG_FUNCTION_ARGS)
{
PG_RETURN_INT32(MyProcPid);
}
--- 213,219 ----
Datum
! backend_pid(PG_FUNCTION_ARGS)
{
PG_RETURN_INT32(MyProcPid);
}
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/catalog/pg_proc.h,v
retrieving revision 1.247
diff -c -r1.247 pg_proc.h
*** src/include/catalog/pg_proc.h 31 Jul 2002 00:40:40 -0000 1.247
--- src/include/catalog/pg_proc.h 31 Jul 2002 01:42:20 -0000
***************
*** 2703,2710 ****
DESCR("Statistics: Number of blocks found in cache");
DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGNSP PGUID 12 f f t t
s 0 23 "" pg_stat_get_backend_idset - _null_ ));
DESCR("Statistics: Currently active backend IDs");
! DATA(insert OID = 2026 ( pg_stat_get_backend_mypid PGNSP PGUID 12 f f t f
s 0 23 "" pg_stat_get_backend_mypid - _null_ ));
! DESCR("Statistics: My backend ID");
DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGNSP PGUID 12 f f t f
s 1 23 "23" pg_stat_get_backend_pid - _null_ ));
DESCR("Statistics: PID of backend");
DATA(insert OID = 1938 ( pg_stat_get_backend_dbid PGNSP PGUID 12 f f t f
s 1 26 "23" pg_stat_get_backend_dbid - _null_ ));
--- 2703,2710 ----
DESCR("Statistics: Number of blocks found in cache");
DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGNSP PGUID 12 f f t t
s 0 23 "" pg_stat_get_backend_idset - _null_ ));
DESCR("Statistics: Currently active backend IDs");
! DATA(insert OID = 2026 ( backend_pid PGNSP PGUID 12
f f t f s 0 23 "" backend_pid - _null_ ));
! DESCR("Statistics: Current backend ID");
DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGNSP PGUID 12 f f t f
s 1 23 "23" pg_stat_get_backend_pid - _null_ ));
DESCR("Statistics: PID of backend");
DATA(insert OID = 1938 ( pg_stat_get_backend_dbid PGNSP PGUID 12 f f t f
s 1 26 "23" pg_stat_get_backend_dbid - _null_ ));
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]