so that we will be able to create a cookie for all processes for CSVlogs.
It is set wherever MyProcPid is set. Take the opportunity to remove the now
unnecessary session-only restriction on the %s and %c escapes in log_line_prefix.
-<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.134 2007/08/01 22:45:07 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.135 2007/08/02 23:39:43 adunstan Exp $ -->
<chapter Id="runtime-config">
<title>Server Configuration</title>
<row>
<entry><literal>%c</literal></entry>
<entry>Session ID: see below</entry>
- <entry>yes</entry>
+ <entry>no</entry>
</row>
<row>
<entry><literal>%l</literal></entry>
<row>
<entry><literal>%s</literal></entry>
<entry>Session start time stamp</entry>
- <entry>yes</entry>
+ <entry>no</entry>
</row>
<row>
<entry><literal>%x</literal></entry>
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.235 2007/07/24 04:54:09 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.236 2007/08/02 23:39:44 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
*/
MyProcPid = getpid();
+ MyStartTime = time(NULL);
+
/*
* Fire up essential subsystems: error and memory management
*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.55 2007/07/01 18:30:54 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.56 2007/08/02 23:39:44 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
/* reset MyProcPid */
MyProcPid = getpid();
+ /* record Start Time for logging */
+ MyStartTime = time(NULL);
+
/* Identify myself via ps */
init_ps_display("autovacuum launcher process", "", "", "");
/* reset MyProcPid */
MyProcPid = getpid();
+ /* record Start Time for logging */
+ MyStartTime = time(NULL);
+
/* Identify myself via ps */
init_ps_display("autovacuum worker process", "", "", "");
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.29 2007/02/10 14:58:54 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.30 2007/08/02 23:39:44 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
MyProcPid = getpid(); /* reset MyProcPid */
+ MyStartTime = time(NULL); /* record Start Time for logging */
+
/*
* If possible, make this process a group leader, so that the postmaster
* can signal any child processes too.
*
* Copyright (c) 2001-2007, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.161 2007/07/08 22:23:16 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.162 2007/08/02 23:39:44 adunstan Exp $
* ----------
*/
#include "postgres.h"
MyProcPid = getpid(); /* reset MyProcPid */
+ MyStartTime = time(NULL); /* record Start Time for logging */
+
/*
* If possible, make this process a group leader, so that the postmaster
* can signal any child processes too. (pgstat probably never has
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.536 2007/08/02 23:15:26 adunstan Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.537 2007/08/02 23:39:44 adunstan Exp $
*
* NOTES
*
MyProcPid = PostmasterPid = getpid();
+ MyStartTime = time(NULL);
+
IsPostmasterEnvironment = true;
/*
MyProcPid = PostmasterPid = getpid(); /* reset PID vars to child */
+ MyStartTime = time(NULL);
+
/* GH: If there's no setsid(), we hopefully don't need silent mode.
* Until there's a better solution.
*/
MyProcPid = getpid(); /* reset MyProcPid */
+ MyStartTime = time(NULL);
+
/* We don't want the postmaster's proc_exit() handlers */
on_exit_reset();
/* save process start time */
port->SessionStartTime = GetCurrentTimestamp();
- port->session_start = timestamptz_to_time_t(port->SessionStartTime);
+ MyStartTime = timestamptz_to_time_t(port->SessionStartTime);
/* set these to empty in case they are needed before we set them up */
port->remote_host = "";
MyProcPid = getpid(); /* reset MyProcPid */
+ MyStartTime = time(NULL);
+
/* make sure stderr is in binary mode before anything can
* possibly be written to it, in case it's actually the syslogger pipe,
* so the pipe chunking protocol isn't disturbed. Non-logpipe data
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.34 2007/08/02 23:15:27 adunstan Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.35 2007/08/02 23:39:44 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
MyProcPid = getpid(); /* reset MyProcPid */
+ MyStartTime = time(NULL); /* set our start time in case we call elog */
+
#ifdef EXEC_BACKEND
syslogger_parseArgs(argc, argv);
#endif /* EXEC_BACKEND */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.536 2007/07/09 01:15:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.537 2007/08/02 23:39:44 adunstan Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
*/
MyProcPid = getpid();
+ MyStartTime = time(NULL);
+
/*
* Fire up essential subsystems: error and memory management
*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.190 2007/07/21 22:12:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.191 2007/08/02 23:39:44 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
}
break;
case 'c':
- if (MyProcPort)
- {
- appendStringInfo(buf, "%lx.%x",
- (long) (MyProcPort->session_start),
- MyProcPid);
- }
+ appendStringInfo(buf, "%lx.%x", (long)(MyStartTime),MyProcPid);
break;
case 'p':
appendStringInfo(buf, "%d", MyProcPid);
}
break;
case 's':
- if (MyProcPort)
{
char strfbuf[128];
#else
"%Y-%m-%d %H:%M:%S",
#endif
- localtime(&MyProcPort->session_start));
+ localtime(&MyStartTime));
appendStringInfoString(buf, strfbuf);
}
break;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.101 2007/04/16 18:29:54 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.102 2007/08/02 23:39:44 adunstan Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
volatile uint32 CritSectionCount = 0;
int MyProcPid;
+time_t MyStartTime;
struct Port *MyProcPort;
long MyCancelKey;
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.62 2007/07/23 10:16:54 mha Exp $
+ * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.63 2007/08/02 23:39:45 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
* other members of this struct, we may as well keep it here.
*/
TimestampTz SessionStartTime; /* backend start time */
- time_t session_start; /* same, in time_t format */
/*
* TCP keepalive settings.
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.195 2007/07/25 12:22:53 mha Exp $
+ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.196 2007/08/02 23:39:44 adunstan Exp $
*
* NOTES
* some of the information in this file should be moved to other files.
#ifndef MISCADMIN_H
#define MISCADMIN_H
+#include <time.h> /* for time_t */
+
#define PG_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
extern int MaxConnections;
extern PGDLLIMPORT int MyProcPid;
+extern PGDLLIMPORT time_t MyStartTime;
extern PGDLLIMPORT struct Port *MyProcPort;
extern long MyCancelKey;