Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6387260

Browse files
committed
Move session_start out of MyProcPort stucture and make it a global called MyStartTime,
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 nowunnecessary session-only restriction on the %s and %c escapes in log_line_prefix.
1 parentb349034 commit6387260

File tree

12 files changed

+45
-24
lines changed

12 files changed

+45
-24
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.134 2007/08/01 22:45:07 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.135 2007/08/02 23:39:43 adunstan Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -2900,7 +2900,7 @@ SELECT * FROM parent WHERE key = 2400;
29002900
<row>
29012901
<entry><literal>%c</literal></entry>
29022902
<entry>Session ID: see below</entry>
2903-
<entry>yes</entry>
2903+
<entry>no</entry>
29042904
</row>
29052905
<row>
29062906
<entry><literal>%l</literal></entry>
@@ -2910,7 +2910,7 @@ SELECT * FROM parent WHERE key = 2400;
29102910
<row>
29112911
<entry><literal>%s</literal></entry>
29122912
<entry>Session start time stamp</entry>
2913-
<entry>yes</entry>
2913+
<entry>no</entry>
29142914
</row>
29152915
<row>
29162916
<entry><literal>%x</literal></entry>

‎src/backend/bootstrap/bootstrap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.235 2007/07/24 04:54:09 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.236 2007/08/02 23:39:44 adunstan Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -213,6 +213,8 @@ AuxiliaryProcessMain(int argc, char *argv[])
213213
*/
214214
MyProcPid=getpid();
215215

216+
MyStartTime=time(NULL);
217+
216218
/*
217219
* Fire up essential subsystems: error and memory management
218220
*

‎src/backend/postmaster/autovacuum.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.55 2007/07/01 18:30:54 tgl Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.56 2007/08/02 23:39:44 adunstan Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -385,6 +385,9 @@ AutoVacLauncherMain(int argc, char *argv[])
385385
/* reset MyProcPid */
386386
MyProcPid=getpid();
387387

388+
/* record Start Time for logging */
389+
MyStartTime=time(NULL);
390+
388391
/* Identify myself via ps */
389392
init_ps_display("autovacuum launcher process","","","");
390393

@@ -1403,6 +1406,9 @@ AutoVacWorkerMain(int argc, char *argv[])
14031406
/* reset MyProcPid */
14041407
MyProcPid=getpid();
14051408

1409+
/* record Start Time for logging */
1410+
MyStartTime=time(NULL);
1411+
14061412
/* Identify myself via ps */
14071413
init_ps_display("autovacuum worker process","","","");
14081414

‎src/backend/postmaster/pgarch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.29 2007/02/10 14:58:54 petere Exp $
22+
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.30 2007/08/02 23:39:44 adunstan Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -223,6 +223,8 @@ PgArchiverMain(int argc, char *argv[])
223223

224224
MyProcPid=getpid();/* reset MyProcPid */
225225

226+
MyStartTime=time(NULL);/* record Start Time for logging */
227+
226228
/*
227229
* If possible, make this process a group leader, so that the postmaster
228230
* can signal any child processes too.

‎src/backend/postmaster/pgstat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2007, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.161 2007/07/08 22:23:16 tgl Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.162 2007/08/0223:39:44 adunstan Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -2168,6 +2168,8 @@ PgstatCollectorMain(int argc, char *argv[])
21682168

21692169
MyProcPid=getpid();/* reset MyProcPid */
21702170

2171+
MyStartTime=time(NULL);/* record Start Time for logging */
2172+
21712173
/*
21722174
* If possible, make this process a group leader, so that the postmaster
21732175
* can signal any child processes too. (pgstat probably never has

‎src/backend/postmaster/postmaster.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.536 2007/08/02 23:15:26 adunstan Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.537 2007/08/02 23:39:44 adunstan Exp $
4141
*
4242
* NOTES
4343
*
@@ -386,6 +386,8 @@ PostmasterMain(int argc, char *argv[])
386386

387387
MyProcPid=PostmasterPid=getpid();
388388

389+
MyStartTime=time(NULL);
390+
389391
IsPostmasterEnvironment= true;
390392

391393
/*
@@ -1103,6 +1105,8 @@ pmdaemonize(void)
11031105

11041106
MyProcPid=PostmasterPid=getpid();/* reset PID vars to child */
11051107

1108+
MyStartTime=time(NULL);
1109+
11061110
/* GH: If there's no setsid(), we hopefully don't need silent mode.
11071111
* Until there's a better solution.
11081112
*/
@@ -2661,6 +2665,8 @@ BackendStartup(Port *port)
26612665

26622666
MyProcPid=getpid();/* reset MyProcPid */
26632667

2668+
MyStartTime=time(NULL);
2669+
26642670
/* We don't want the postmaster's proc_exit() handlers */
26652671
on_exit_reset();
26662672

@@ -2803,7 +2809,7 @@ BackendInitialize(Port *port)
28032809

28042810
/* save process start time */
28052811
port->SessionStartTime=GetCurrentTimestamp();
2806-
port->session_start=timestamptz_to_time_t(port->SessionStartTime);
2812+
MyStartTime=timestamptz_to_time_t(port->SessionStartTime);
28072813

28082814
/* set these to empty in case they are needed before we set them up */
28092815
port->remote_host="";
@@ -3385,6 +3391,8 @@ SubPostmasterMain(int argc, char *argv[])
33853391

33863392
MyProcPid=getpid();/* reset MyProcPid */
33873393

3394+
MyStartTime=time(NULL);
3395+
33883396
/* make sure stderr is in binary mode before anything can
33893397
* possibly be written to it, in case it's actually the syslogger pipe,
33903398
* so the pipe chunking protocol isn't disturbed. Non-logpipe data

‎src/backend/postmaster/syslogger.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.34 2007/08/02 23:15:27 adunstan Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.35 2007/08/02 23:39:44 adunstan Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -162,6 +162,8 @@ SysLoggerMain(int argc, char *argv[])
162162

163163
MyProcPid=getpid();/* reset MyProcPid */
164164

165+
MyStartTime=time(NULL);/* set our start time in case we call elog */
166+
165167
#ifdefEXEC_BACKEND
166168
syslogger_parseArgs(argc,argv);
167169
#endif/* EXEC_BACKEND */

‎src/backend/tcop/postgres.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.536 2007/07/09 01:15:14 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.537 2007/08/02 23:39:44 adunstan Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2786,6 +2786,8 @@ PostgresMain(int argc, char *argv[], const char *username)
27862786
*/
27872787
MyProcPid=getpid();
27882788

2789+
MyStartTime=time(NULL);
2790+
27892791
/*
27902792
* Fire up essential subsystems: error and memory management
27912793
*

‎src/backend/utils/error/elog.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
*
4444
* IDENTIFICATION
45-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.190 2007/07/21 22:12:04 tgl Exp $
45+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.191 2007/08/02 23:39:44 adunstan Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1485,12 +1485,7 @@ log_line_prefix(StringInfo buf)
14851485
}
14861486
break;
14871487
case'c':
1488-
if (MyProcPort)
1489-
{
1490-
appendStringInfo(buf,"%lx.%x",
1491-
(long) (MyProcPort->session_start),
1492-
MyProcPid);
1493-
}
1488+
appendStringInfo(buf,"%lx.%x", (long)(MyStartTime),MyProcPid);
14941489
break;
14951490
case'p':
14961491
appendStringInfo(buf,"%d",MyProcPid);
@@ -1552,7 +1547,6 @@ log_line_prefix(StringInfo buf)
15521547
}
15531548
break;
15541549
case's':
1555-
if (MyProcPort)
15561550
{
15571551
charstrfbuf[128];
15581552

@@ -1563,7 +1557,7 @@ log_line_prefix(StringInfo buf)
15631557
#else
15641558
"%Y-%m-%d %H:%M:%S",
15651559
#endif
1566-
localtime(&MyProcPort->session_start));
1560+
localtime(&MyStartTime));
15671561
appendStringInfoString(buf,strfbuf);
15681562
}
15691563
break;

‎src/backend/utils/init/globals.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.101 2007/04/16 18:29:54 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.102 2007/08/02 23:39:44 adunstan Exp $
1212
*
1313
* NOTES
1414
* Globals used all over the place should be declared here and not
@@ -33,6 +33,7 @@ volatile uint32 InterruptHoldoffCount = 0;
3333
volatileuint32CritSectionCount=0;
3434

3535
intMyProcPid;
36+
time_tMyStartTime;
3637
structPort*MyProcPort;
3738
longMyCancelKey;
3839

‎src/include/libpq/libpq-be.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.62 2007/07/23 10:16:54 mha Exp $
14+
* $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.63 2007/08/02 23:39:45 adunstan Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -130,7 +130,6 @@ typedef struct Port
130130
* other members of this struct, we may as well keep it here.
131131
*/
132132
TimestampTzSessionStartTime;/* backend start time */
133-
time_tsession_start;/* same, in time_t format */
134133

135134
/*
136135
* TCP keepalive settings.

‎src/include/miscadmin.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
16-
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.195 2007/07/25 12:22:53 mha Exp $
16+
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.196 2007/08/02 23:39:44 adunstan Exp $
1717
*
1818
* NOTES
1919
* some of the information in this file should be moved to other files.
@@ -23,6 +23,8 @@
2323
#ifndefMISCADMIN_H
2424
#defineMISCADMIN_H
2525

26+
#include<time.h>/* for time_t */
27+
2628

2729
#definePG_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
2830

@@ -132,6 +134,7 @@ extern intMaxBackends;
132134
externintMaxConnections;
133135

134136
externPGDLLIMPORTintMyProcPid;
137+
externPGDLLIMPORTtime_tMyStartTime;
135138
externPGDLLIMPORTstructPort*MyProcPort;
136139
externlongMyCancelKey;
137140

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp