Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
bd19e8f6
Commit
bd19e8f6
authored
Oct 24, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some places that were unportably assuming struct timeval's tv_sec
field is signed. Clean up casting.
parent
c3086c8f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
33 deletions
+37
-33
src/backend/postmaster/pgstat.c
src/backend/postmaster/pgstat.c
+18
-10
src/backend/tcop/postgres.c
src/backend/tcop/postgres.c
+19
-23
No files found.
src/backend/postmaster/pgstat.c
View file @
bd19e8f6
...
...
@@ -16,7 +16,7 @@
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.3
0 2002/10/21 19:59:14
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.3
1 2002/10/24 23:19:13
tgl Exp $
* ----------
*/
#include "postgres.h"
...
...
@@ -1247,18 +1247,26 @@ pgstat_main(void)
*/
if
(
need_statwrite
)
{
gettimeofday
(
&
timeout
,
NULL
);
timeout
.
tv_usec
=
next_statwrite
.
tv_usec
-
timeout
.
tv_usec
;
timeout
.
tv_sec
=
next_statwrite
.
tv_sec
-
timeout
.
tv_sec
;
struct
timeval
now
;
gettimeofday
(
&
now
,
NULL
);
/* avoid assuming that tv_sec is signed */
if
(
now
.
tv_sec
>
next_statwrite
.
tv_sec
||
(
now
.
tv_sec
==
next_statwrite
.
tv_sec
&&
now
.
tv_usec
>=
next_statwrite
.
tv_usec
))
{
timeout
.
tv_sec
=
0
;
timeout
.
tv_usec
=
0
;
}
else
{
timeout
.
tv_sec
=
next_statwrite
.
tv_sec
-
now
.
tv_sec
;
timeout
.
tv_usec
=
next_statwrite
.
tv_usec
-
now
.
tv_usec
;
if
(
timeout
.
tv_usec
<
0
)
{
timeout
.
tv_sec
-=
1
;
timeout
.
tv_sec
--
;
timeout
.
tv_usec
+=
1000000
;
}
if
(
timeout
.
tv_sec
<
0
)
{
timeout
.
tv_sec
=
0
;
timeout
.
tv_usec
=
0
;
}
}
...
...
src/backend/tcop/postgres.c
View file @
bd19e8f6
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.30
5 2002/10/19 20:15:09
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.30
6 2002/10/24 23:19:13
tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
...
...
@@ -559,7 +559,6 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
MemoryContext
oldcontext
;
List
*
parsetree_list
,
*
parsetree_item
;
struct
timezone
tz
;
struct
timeval
start_t
,
stop_t
;
bool
save_Log_duration
=
Log_duration
;
...
...
@@ -571,7 +570,7 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
* report incorrect time because gettimeofday() wasn't called.
*/
if
(
save_Log_duration
)
gettimeofday
(
&
start_t
,
&
tz
);
gettimeofday
(
&
start_t
,
NULL
);
/*
* Start up a transaction command. All queries generated by the
...
...
@@ -943,15 +942,15 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
if
(
save_Log_duration
)
{
gettimeofday
(
&
stop_t
,
&
tz
);
gettimeofday
(
&
stop_t
,
NULL
);
if
(
stop_t
.
tv_usec
<
start_t
.
tv_usec
)
{
stop_t
.
tv_sec
--
;
stop_t
.
tv_usec
+=
1000000
;
}
elog
(
LOG
,
"duration: %ld.%06ld sec"
,
(
long
int
)
stop_t
.
tv_sec
-
start_t
.
tv_sec
,
(
long
int
)
stop_t
.
tv_usec
-
start_t
.
tv_usec
);
(
long
)
(
stop_t
.
tv_sec
-
start_t
.
tv_sec
)
,
(
long
)
(
stop_t
.
tv_usec
-
start_t
.
tv_usec
)
);
}
debug_query_string
=
NULL
;
...
...
@@ -1783,7 +1782,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if
(
!
IsUnderPostmaster
)
{
puts
(
"
\n
POSTGRES backend interactive interface "
);
puts
(
"$Revision: 1.30
5 $ $Date: 2002/10/19 20:15:09
$
\n
"
);
puts
(
"$Revision: 1.30
6 $ $Date: 2002/10/24 23:19:13
$
\n
"
);
}
/*
...
...
@@ -2081,12 +2080,10 @@ struct timeval Save_t;
void
ResetUsage
(
void
)
{
struct
timezone
tz
;
getrusage
(
RUSAGE_SELF
,
&
Save_r
);
gettimeofday
(
&
Save_t
,
&
tz
);
gettimeofday
(
&
Save_t
,
NULL
);
ResetBufferUsage
();
/*
ResetTupleCount(); */
/*
ResetTupleCount(); */
}
void
...
...
@@ -2096,12 +2093,11 @@ ShowUsage(const char *title)
struct
timeval
user
,
sys
;
struct
timeval
elapse_t
;
struct
timezone
tz
;
struct
rusage
r
;
char
*
bufusage
;
getrusage
(
RUSAGE_SELF
,
&
r
);
gettimeofday
(
&
elapse_t
,
&
tz
);
gettimeofday
(
&
elapse_t
,
NULL
);
memcpy
((
char
*
)
&
user
,
(
char
*
)
&
r
.
ru_utime
,
sizeof
(
user
));
memcpy
((
char
*
)
&
sys
,
(
char
*
)
&
r
.
ru_stime
,
sizeof
(
sys
));
if
(
elapse_t
.
tv_usec
<
Save_t
.
tv_usec
)
...
...
@@ -2133,18 +2129,18 @@ ShowUsage(const char *title)
appendStringInfo
(
&
str
,
"! system usage stats:
\n
"
);
appendStringInfo
(
&
str
,
"!
\t
%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec
\n
"
,
(
long
int
)
elapse_t
.
tv_sec
-
Save_t
.
tv_sec
,
(
long
int
)
elapse_t
.
tv_usec
-
Save_t
.
tv_usec
,
(
long
int
)
r
.
ru_utime
.
tv_sec
-
Save_r
.
ru_utime
.
tv_sec
,
(
long
int
)
r
.
ru_utime
.
tv_usec
-
Save_r
.
ru_utime
.
tv_usec
,
(
long
int
)
r
.
ru_stime
.
tv_sec
-
Save_r
.
ru_stime
.
tv_sec
,
(
long
int
)
r
.
ru_stime
.
tv_usec
-
Save_r
.
ru_stime
.
tv_usec
);
(
long
)
(
elapse_t
.
tv_sec
-
Save_t
.
tv_sec
)
,
(
long
)
(
elapse_t
.
tv_usec
-
Save_t
.
tv_usec
)
,
(
long
)
(
r
.
ru_utime
.
tv_sec
-
Save_r
.
ru_utime
.
tv_sec
)
,
(
long
)
(
r
.
ru_utime
.
tv_usec
-
Save_r
.
ru_utime
.
tv_usec
)
,
(
long
)
(
r
.
ru_stime
.
tv_sec
-
Save_r
.
ru_stime
.
tv_sec
)
,
(
long
)
(
r
.
ru_stime
.
tv_usec
-
Save_r
.
ru_stime
.
tv_usec
)
);
appendStringInfo
(
&
str
,
"!
\t
[%ld.%06ld user %ld.%06ld sys total]
\n
"
,
(
long
int
)
user
.
tv_sec
,
(
long
int
)
user
.
tv_usec
,
(
long
int
)
sys
.
tv_sec
,
(
long
int
)
sys
.
tv_usec
);
(
long
)
user
.
tv_sec
,
(
long
)
user
.
tv_usec
,
(
long
)
sys
.
tv_sec
,
(
long
)
sys
.
tv_usec
);
/* BeOS has rusage but only has some fields, and not these... */
#if defined(HAVE_GETRUSAGE)
appendStringInfo
(
&
str
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment