Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
b5aad11a
Commit
b5aad11a
authored
19 years ago
by
Neil Conway
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup for log_disconnections(). Patch from Qingqing Zhou,
fixes by Neil Conway.
parent
8c6f3450
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/tcop/postgres.c
+14
-42
14 additions, 42 deletions
src/backend/tcop/postgres.c
with
14 additions
and
42 deletions
src/backend/tcop/postgres.c
+
14
−
42
View file @
b5aad11a
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.46
3
2005/
09/26 15:51:12 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.46
4
2005/
10/05 23:46:06 neilc
Exp $
*
*
* NOTES
* NOTES
* this is the "main" module of the postgres backend and
* this is the "main" module of the postgres backend and
...
@@ -3526,29 +3526,13 @@ ShowUsage(const char *title)
...
@@ -3526,29 +3526,13 @@ ShowUsage(const char *title)
static
void
static
void
log_disconnections
(
int
code
,
Datum
arg
)
log_disconnections
(
int
code
,
Datum
arg
)
{
{
Port
*
port
=
MyProcPort
;
Port
*
port
=
MyProcPort
;
struct
timeval
end
;
struct
timeval
end
;
int
hours
,
int
hours
,
minutes
,
minutes
,
seconds
;
seconds
;
char
session_time
[
20
];
char
uname
[
6
+
NAMEDATALEN
];
char
dbname
[
10
+
NAMEDATALEN
];
char
remote_host
[
7
+
NI_MAXHOST
];
char
remote_port
[
7
+
NI_MAXSERV
];
snprintf
(
uname
,
sizeof
(
uname
),
" user=%s"
,
port
->
user_name
);
snprintf
(
dbname
,
sizeof
(
dbname
),
" database=%s"
,
port
->
database_name
);
snprintf
(
remote_host
,
sizeof
(
remote_host
),
" host=%s"
,
port
->
remote_host
);
if
(
port
->
remote_port
[
0
])
snprintf
(
remote_port
,
sizeof
(
remote_port
),
" port=%s"
,
port
->
remote_port
);
else
remote_port
[
0
]
=
'\0'
;
gettimeofday
(
&
end
,
NULL
);
gettimeofday
(
&
end
,
NULL
);
if
(
end
.
tv_usec
<
port
->
session_start
.
tv_usec
)
if
(
end
.
tv_usec
<
port
->
session_start
.
tv_usec
)
{
{
end
.
tv_sec
--
;
end
.
tv_sec
--
;
...
@@ -3557,28 +3541,16 @@ log_disconnections(int code, Datum arg)
...
@@ -3557,28 +3541,16 @@ log_disconnections(int code, Datum arg)
end
.
tv_sec
-=
port
->
session_start
.
tv_sec
;
end
.
tv_sec
-=
port
->
session_start
.
tv_sec
;
end
.
tv_usec
-=
port
->
session_start
.
tv_usec
;
end
.
tv_usec
-=
port
->
session_start
.
tv_usec
;
/* for stricter accuracy here we could round - this is close enough */
hours
=
end
.
tv_sec
/
SECS_PER_HOUR
;
hours
=
end
.
tv_sec
/
SECS_PER_HOUR
;
end
.
tv_sec
%=
SECS_PER_HOUR
;
end
.
tv_sec
%=
SECS_PER_HOUR
;
minutes
=
end
.
tv_sec
/
SECS_PER_MINUTE
;
minutes
=
end
.
tv_sec
/
SECS_PER_MINUTE
;
seconds
=
end
.
tv_sec
%
SECS_PER_MINUTE
;
seconds
=
end
.
tv_sec
%
SECS_PER_MINUTE
;
/* if time has gone backwards for some reason say so, or print time */
ereport
(
LOG
,
(
errmsg
(
"disconnection: session time: %d:%02d:%02d.%02d "
if
(
end
.
tv_sec
<
0
)
"user=%s database=%s host=%s%s%s"
,
snprintf
(
session_time
,
sizeof
(
session_time
),
"negative!"
);
hours
,
minutes
,
seconds
,
(
int
)
(
end
.
tv_usec
/
10000
),
else
port
->
user_name
,
port
->
database_name
,
port
->
remote_host
,
port
->
remote_port
[
0
]
?
" port="
:
""
,
port
->
remote_port
)));
/*
* for stricter accuracy here we could round - this is close
* enough
*/
snprintf
(
session_time
,
sizeof
(
session_time
),
"%d:%02d:%02d.%02d"
,
hours
,
minutes
,
seconds
,
(
int
)
(
end
.
tv_usec
/
10000
));
ereport
(
LOG
,
(
errmsg
(
"disconnection: session time: %s%s%s%s%s"
,
session_time
,
uname
,
dbname
,
remote_host
,
remote_port
)));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment