mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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.
This commit is contained in:
parent
8cde7f4948
commit
1a75c1d0c5
@ -5019,16 +5019,19 @@ set_random_seed(const char *seed)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* parse seed unsigned int value */
|
/* parse unsigned-int seed value */
|
||||||
|
unsigned long ulseed;
|
||||||
char garbage;
|
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,
|
fprintf(stderr,
|
||||||
"unrecognized random seed option \"%s\": expecting an unsigned integer, \"time\" or \"rand\"\n",
|
"unrecognized random seed option \"%s\": expecting an unsigned integer, \"time\" or \"rand\"\n",
|
||||||
seed);
|
seed);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
iseed = (uint64) ulseed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seed != NULL)
|
if (seed != NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user