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

Commitb5aad11

Browse files
author
Neil Conway
committed
Code cleanup for log_disconnections(). Patch from Qingqing Zhou,
fixes by Neil Conway.
1 parent8c6f345 commitb5aad11

File tree

1 file changed

+14
-42
lines changed

1 file changed

+14
-42
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 14 additions & 42 deletions
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.463 2005/09/26 15:51:12 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.464 2005/10/05 23:46:06 neilc Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -3526,29 +3526,13 @@ ShowUsage(const char *title)
35263526
staticvoid
35273527
log_disconnections(intcode,Datumarg)
35283528
{
3529-
Port*port=MyProcPort;
3530-
structtimevalend;
3531-
inthours,
3532-
minutes,
3533-
seconds;
3534-
3535-
charsession_time[20];
3536-
charuname[6+NAMEDATALEN];
3537-
chardbname[10+NAMEDATALEN];
3538-
charremote_host[7+NI_MAXHOST];
3539-
charremote_port[7+NI_MAXSERV];
3540-
3541-
snprintf(uname,sizeof(uname)," user=%s",port->user_name);
3542-
snprintf(dbname,sizeof(dbname)," database=%s",port->database_name);
3543-
snprintf(remote_host,sizeof(remote_host)," host=%s",
3544-
port->remote_host);
3545-
if (port->remote_port[0])
3546-
snprintf(remote_port,sizeof(remote_port)," port=%s",port->remote_port);
3547-
else
3548-
remote_port[0]='\0';
3549-
3550-
gettimeofday(&end,NULL);
3529+
Port*port=MyProcPort;
3530+
structtimevalend;
3531+
inthours,
3532+
minutes,
3533+
seconds;
35513534

3535+
gettimeofday(&end,NULL);
35523536
if (end.tv_usec<port->session_start.tv_usec)
35533537
{
35543538
end.tv_sec--;
@@ -3557,28 +3541,16 @@ log_disconnections(int code, Datum arg)
35573541
end.tv_sec-=port->session_start.tv_sec;
35583542
end.tv_usec-=port->session_start.tv_usec;
35593543

3544+
/* for stricter accuracy here we could round - this is close enough */
35603545
hours=end.tv_sec /SECS_PER_HOUR;
35613546
end.tv_sec %=SECS_PER_HOUR;
35623547
minutes=end.tv_sec /SECS_PER_MINUTE;
35633548
seconds=end.tv_sec %SECS_PER_MINUTE;
35643549

3565-
/* if time has gone backwards for some reason say so, or print time */
3566-
3567-
if (end.tv_sec<0)
3568-
snprintf(session_time,sizeof(session_time),"negative!");
3569-
else
3570-
3571-
/*
3572-
* for stricter accuracy here we could round - this is close
3573-
* enough
3574-
*/
3575-
snprintf(session_time,sizeof(session_time),
3576-
"%d:%02d:%02d.%02d",
3577-
hours,minutes,seconds, (int) (end.tv_usec /10000));
3578-
3579-
ereport(
3580-
LOG,
3581-
(errmsg("disconnection: session time: %s%s%s%s%s",
3582-
session_time,uname,dbname,remote_host,remote_port)));
3583-
3550+
ereport(LOG,
3551+
(errmsg("disconnection: session time: %d:%02d:%02d.%02d "
3552+
"user=%s database=%s host=%s%s%s",
3553+
hours,minutes,seconds, (int) (end.tv_usec /10000),
3554+
port->user_name,port->database_name,port->remote_host,
3555+
port->remote_port[0] ?" port=" :"",port->remote_port)));
35843556
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp