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

Commit9c26980

Browse files
committed
Replace unportable and overflow-prone use of 'long long' with safer
'double' arithmetic, per recent discussion.
1 parent80af69c commit9c26980

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

‎contrib/pg_autovacuum/pg_autovacuum.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ main(int argc, char *argv[])
978978
db_info*dbs;
979979
tbl_info*tbl;
980980
PGresult*res=NULL;
981-
long longdiff=0;
981+
doublediff;
982982
structtimevalnow,
983983
then;
984984

@@ -1151,14 +1151,14 @@ main(int argc, char *argv[])
11511151

11521152
/* Figure out how long to sleep etc ... */
11531153
gettimeofday(&now,0);
1154-
diff= (now.tv_sec-then.tv_sec)*1000000+ (now.tv_usec-then.tv_usec);
1154+
diff= (int) (now.tv_sec-then.tv_sec)*1000000.0+ (int) (now.tv_usec-then.tv_usec);
11551155

1156-
sleep_secs=args->sleep_base_value+args->sleep_scaling_factor*diff /1000000;
1156+
sleep_secs=args->sleep_base_value+args->sleep_scaling_factor*diff /1000000.0;
11571157
loops++;
11581158
if (args->debug >=2)
11591159
{
11601160
sprintf(logbuffer,
1161-
"%i All DBs checked in: %lld usec, will sleep for %i secs.",
1161+
"%i All DBs checked in: %.0f usec, will sleep for %i secs.",
11621162
loops,diff,sleep_secs);
11631163
log_entry(logbuffer);
11641164
}

‎contrib/pgbench/pgbench.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.29 2003/11/29 19:51:35 pgsql Exp $
2+
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.30 2003/12/07 19:55:58 tgl Exp $
33
*
44
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -261,14 +261,14 @@ doOne(CState * state, int n, int debug, int ttype)
261261
*/
262262
if (use_log)
263263
{
264-
long longdiff;
264+
doublediff;
265265
structtimevalnow;
266266

267267
gettimeofday(&now,0);
268-
diff= (now.tv_sec-st->txn_begin.tv_sec)*1000000+
269-
(now.tv_usec-st->txn_begin.tv_usec);
268+
diff= (int) (now.tv_sec-st->txn_begin.tv_sec)*1000000.0+
269+
(int) (now.tv_usec-st->txn_begin.tv_usec);
270270

271-
fprintf(LOGFILE,"%d %d %lld\n",st->id,st->cnt,diff);
271+
fprintf(LOGFILE,"%d %d %.0f\n",st->id,st->cnt,diff);
272272
}
273273

274274
res=PQgetResult(st->con);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp