Re: Silly bug in pgbench's random number generator - Mailing list pgsql-patches

From Tom Lane
Subject Re: Silly bug in pgbench's random number generator
Date
Msg-id 17417.1205112226@sss.pgh.pa.us
Whole thread Raw
In response to Re: Silly bug in pgbench's random number generator  (Alexey Klyukin <alexk@commandprompt.com>)
List pgsql-patches
Alexey Klyukin <alexk@commandprompt.com> writes:
> Gregory Stark wrote:
>> pgbench's random number generator was only generating the first and last value
>> in the specified range half as often as other values in the range.

> I think this line should be altered this way:
> return min + (int) (((max - min + 1) * (double) random()) / (MAX_RANDOM_VALUE + 1.0));
> eliminating the result of max + 1 in a corner case when random() equals to
> MAX_RANDOM_VALUE.

Yeah, that looks more correct.  Applied.

            regards, tom lane

pgsql-patches by date:

Previous
From: "Heikki Linnakangas"
Date:
Subject: Re: CopyReadAttributesCSV optimization
Next
From: Tom Lane
Date:
Subject: Re: Reduce the size of PageFreeSpaceInfo on 64bit platform