postgrespro.git / summary / log / commit / refs
commit 1a75c1d0c5d967ea2adcd7129092687cded4e7bf
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed Apr 17 21:30:29 2019 +0000
Fix unportable code in pgbench.
The buildfarm points out that UINT64_FORMAT might not work with sscanf;
it's calibrated for our printf implementation, which might not agree
with the platform-supplied sscanf. Fall back to just accepting an
unsigned long, which is already more than the documentation promises.
Oversight in e6c3ba7fb; back-patch to v11, as that was.
src/bin/pgbench/pgbench.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index e0ac131a0e..a03ab281a5 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -5019,16 +5019,19 @@ set_random_seed(const char *seed)
}
else
{
- /* parse seed unsigned int value */
+ /* parse unsigned-int seed value */
+ unsigned long ulseed;
char garbage;
- if (sscanf(seed, UINT64_FORMAT "%c", &iseed, &garbage) != 1)
+ /* Don't try to use UINT64_FORMAT here; it might not work for sscanf */
+ if (sscanf(seed, "%lu%c", &ulseed, &garbage) != 1)
{
fprintf(stderr,
"unrecognized random seed option \"%s\": expecting an unsigned integer, \"time\" or \"rand\"\n",
seed);
return false;
}
+ iseed = (uint64) ulseed;
}
if (seed != NULL)
[parent: 8cde7f49483d]