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();
         pg_stat_get_backend_mypid 
        ---------------------------
                              2757
        (1 row)

Applied.

-- 
  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: src/backend/utils/adt/pgstatfuncs.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/pgstatfuncs.c,v
retrieving revision 1.4
diff -c -r1.4 pgstatfuncs.c
*** src/backend/utils/adt/pgstatfuncs.c 25 Oct 2001 05:49:45 -0000      1.4
--- src/backend/utils/adt/pgstatfuncs.c 31 Jul 2002 00:36:27 -0000
***************
*** 19,24 ****
--- 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);
***************
*** 208,213 ****
--- 209,221 ----
  
        ((ReturnSetInfo *) (fcinfo->resultinfo))->isDone = ExprMultipleResult;
        PG_RETURN_INT32(result);
+ }
+ 
+ 
+ Datum
+ pg_stat_get_backend_mypid(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.246
diff -c -r1.246 pg_proc.h
*** src/include/catalog/pg_proc.h       24 Jul 2002 19:11:13 -0000      1.246
--- src/include/catalog/pg_proc.h       31 Jul 2002 00:36:36 -0000
***************
*** 2703,2708 ****
--- 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_ ));

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to