<!--
-$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.254 2005/06/13 02:40:04 neilc Exp $
+$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.255 2005/06/14 21:04:38 momjian Exp $
PostgreSQL documentation
-->
<entry>session user name</entry>
</row>
+ <row>
+ <entry><function>pg_postmaster_start_time()</function></entry>
+ <entry><type>timestamp with time zone</type></entry>
+ <entry><command>postmaster</> start time</entry>
+ </row>
+
<row>
<entry><function>user</function></entry>
<entry><type>name</type></entry>
Unix-domain socket.
</para>
+ <indexterm zone="functions-info">
+ <primary>pg_postmaster_start_time</primary>
+ </indexterm>
+
+ <para>
+ <function>pg_postmaster_start_time()</function> returns the timestamp with time zone
+ when the <command>postmaster</> started.
+ </para>
+
<indexterm zone="functions-info">
<primary>version</primary>
</indexterm>
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.452 2005/06/09 22:01:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.453 2005/06/14 21:04:39 momjian Exp $
*
* NOTES
*
bool ClientAuthInProgress = false; /* T during new-client
* authentication */
+/* Backend startup time */
+TimestampTz StartTime;
+
/*
* State for assigning random salts and cancel keys.
* Also, the global MyCancelKey passes the cancel key assigned to a given
InheritableSocket pgStatPipe0;
InheritableSocket pgStatPipe1;
pid_t PostmasterPid;
+ TimestampTz StartTime;
#ifdef WIN32
HANDLE PostmasterHandle;
HANDLE initial_signal_pipe;
char *userDoption = NULL;
int i;
+ AbsoluteTime StartTimeSec; /* integer part */
+ int StartTimeUSec; /* microsecond part */
+
/* This will call exit() if strdup() fails. */
progname = get_progname(argv[0]);
*/
StartupPID = StartupDataBase();
+ /*
+ * Get start up time
+ */
+ StartTimeSec = GetCurrentAbsoluteTimeUsec(&StartTimeUSec);
+ StartTime = AbsoluteTimeUsecToTimestampTz(StartTimeSec, StartTimeUSec);
+
status = ServerLoop();
/*
write_inheritable_socket(¶m->pgStatPipe1, pgStatPipe[1], childPid);
param->PostmasterPid = PostmasterPid;
+ param->StartTime = StartTime;
#ifdef WIN32
param->PostmasterHandle = PostmasterHandle;
read_inheritable_socket(&pgStatPipe[1], ¶m->pgStatPipe1);
PostmasterPid = param->PostmasterPid;
+ StartTime = param->StartTime;
#ifdef WIN32
PostmasterHandle = param->PostmasterHandle;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.447 2005/06/03 23:05:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.448 2005/06/14 21:04:40 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
#endif /* TCOP_DONTUSENEWLINE */
+/* Backend startup time */
+TimestampTz StartTime;
+
/* ----------------------------------------------------------------
* decls for routines only used in this file
* ----------------------------------------------------------------
sigjmp_buf local_sigjmp_buf;
volatile bool send_rfq = true;
+ AbsoluteTime StartTimeSec; /* integer part */
+ int StartTimeUSec; /* microsecond part */
+
#define PendingConfigOption(name,val) \
(guc_names = lappend(guc_names, pstrdup(name)), \
guc_values = lappend(guc_values, pstrdup(val)))
*/
pgstat_bestart();
+ /*
+ * Get stand-alone backend startup time
+ */
+ if (!IsUnderPostmaster)
+ {
+ StartTimeSec = GetCurrentAbsoluteTimeUsec(&StartTimeUSec);
+ StartTime = AbsoluteTimeUsecToTimestampTz(StartTimeSec, StartTimeUSec);
+ }
+
/*
* POSTGRES main processing loop begins here
*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.124 2005/05/26 02:04:13 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.125 2005/06/14 21:04:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
PG_RETURN_TIMESTAMPTZ(result);
}
+Datum
+pgsql_postmaster_start_time(PG_FUNCTION_ARGS)
+{
+ PG_RETURN_TIMESTAMPTZ(StartTime);
+}
+
void
dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
{
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.366 2005/06/13 02:26:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.367 2005/06/14 21:04:41 momjian Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
DATA(insert OID = 2559 ( lastval PGNSP PGUID 12 f f t f v 0 20 "" _null_ _null_ _null_ lastval - _null_ ));
DESCR("current value from last used sequence");
+/* start time function */
+DATA(insert OID = 2560 ( pg_postmaster_start_time PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ pgsql_postmaster_start_time - _null_ ));
+DESCR("postmaster start time");
+
/*
* Symbolic values for provolatile column: these indicate whether the result
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.43 2005/05/25 21:40:42 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.44 2005/06/14 21:04:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern Datum now(PG_FUNCTION_ARGS);
+extern Datum pgsql_postmaster_start_time(PG_FUNCTION_ARGS);
+
+extern TimestampTz StartTime;
+
/* Internal routines (not fmgr-callable) */
extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt);