aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-04-17 17:30:29 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-04-17 17:30:29 -0400
commit7e5569fdee0c2173de564a1b0649cb4d4cc5b890 (patch)
treedae8aa5f9a31ea9822fb22874fbbdd270ab41cf3
parent76097b42ae03019784465c29d779c7324bc877fe (diff)
downloadpostgresql-7e5569fdee0c2173de564a1b0649cb4d4cc5b890.tar.gz
postgresql-7e5569fdee0c2173de564a1b0649cb4d4cc5b890.zip
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.
-rw-r--r--src/bin/pgbench/pgbench.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 9eaa1922391..255717bfd22 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -4742,16 +4742,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)