8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
* NOTES
14
14
* this is the "main" module of the postgres backend and
@@ -3526,29 +3526,13 @@ ShowUsage(const char *title)
3526
3526
static void
3527
3527
log_disconnections (int code , Datum arg )
3528
3528
{
3529
- Port * port = MyProcPort ;
3530
- struct timeval end ;
3531
- int hours ,
3532
- minutes ,
3533
- seconds ;
3534
-
3535
- char session_time [20 ];
3536
- char uname [6 + NAMEDATALEN ];
3537
- char dbname [10 + NAMEDATALEN ];
3538
- char remote_host [7 + NI_MAXHOST ];
3539
- char remote_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
+ struct timeval end ;
3531
+ int hours ,
3532
+ minutes ,
3533
+ seconds ;
3551
3534
3535
+ gettimeofday (& end , NULL );
3552
3536
if (end .tv_usec < port -> session_start .tv_usec )
3553
3537
{
3554
3538
end .tv_sec -- ;
@@ -3557,28 +3541,16 @@ log_disconnections(int code, Datum arg)
3557
3541
end .tv_sec -= port -> session_start .tv_sec ;
3558
3542
end .tv_usec -= port -> session_start .tv_usec ;
3559
3543
3544
+ /* for stricter accuracy here we could round - this is close enough */
3560
3545
hours = end .tv_sec / SECS_PER_HOUR ;
3561
3546
end .tv_sec %= SECS_PER_HOUR ;
3562
3547
minutes = end .tv_sec / SECS_PER_MINUTE ;
3563
3548
seconds = end .tv_sec % SECS_PER_MINUTE ;
3564
3549
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 )));
3584
3556
}
0 commit comments