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

Commit53a2a15

Browse files
committed
pgbench: Make set_random_seed() 64-bit everywhere.
Delete an intermediate variable, a redundant cast, a use of long and ause of long long. scanf() the seed directly into a uint64, now that wecan do that with SCNu64 from <inttypes.h>.The previous coding was from pre-C99 times when %lld might not have beenthere, so it read into an unsigned long. Therefore behavior variedby OS, and --random-seed would accept either 32 or 64 bit seeds. Nowit's the same everywhere.Author: Thomas Munro <thomas.munro@gmail.com>Discussion:https://postgr.es/m/b936d2fb-590d-49c3-a615-92c3a88c6c19%40eisentraut.org
1 parentd70b176 commit53a2a15

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6634,27 +6634,23 @@ set_random_seed(const char *seed)
66346634
}
66356635
else
66366636
{
6637-
/* parse unsigned-int seed value */
6638-
unsigned longulseed;
66396637
chargarbage;
66406638

6641-
/* Don't try to use UINT64_FORMAT here; it might not work for sscanf */
6642-
if (sscanf(seed,"%lu%c",&ulseed,&garbage)!=1)
6639+
if (sscanf(seed,"%"SCNu64"%c",&iseed,&garbage)!=1)
66436640
{
66446641
pg_log_error("unrecognized random seed option \"%s\"",seed);
66456642
pg_log_error_detail("Expecting an unsigned integer, \"time\" or \"rand\".");
66466643
return false;
66476644
}
6648-
iseed= (uint64)ulseed;
66496645
}
66506646

66516647
if (seed!=NULL)
6652-
pg_log_info("setting random seed to %llu", (unsigned long long)iseed);
6648+
pg_log_info("setting random seed to %"PRIu64,iseed);
66536649

66546650
random_seed=iseed;
66556651

66566652
/* Initialize base_random_sequence using seed */
6657-
pg_prng_seed(&base_random_sequence,(uint64)iseed);
6653+
pg_prng_seed(&base_random_sequence,iseed);
66586654

66596655
return true;
66606656
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp