Thomas Swan <tswan(at)olemiss(dot)edu> writes:
>> I suspect we have a good chance at getting burned no matter what we use
>> :-(. But RAND_MAX is definitely the wrong thing.
> Is it possible to test (during configure phase) and then go from there...
> or does it need to be the same for all platforms?
I thought about that last night. We could do a configure test. Since
it'd be probing random() results there'd be a small probability of
failure, but if we wire in an assumption that the max value must be
2^(15 + n*16)-1 for some n, ten or so probes would give us a failure
probability on the order of 2^-160, which ought to satisfy anyone.
However, in the absence of any hard evidence that there are platforms
where the value is different from 2^31-1, it's probably just a waste of
configuration cycles at the moment.
I suggest we add a config.h constant like
/* The local random() function yields values 0 .. MAX_RANDOM_VALUE */
#define MAX_RANDOM_VALUE <2^31-1>
and use that in the code. Then, if we ever find a platform where
random() does actually produce 64-bit results, it'll be time enough
to crank up a real configure test to set the value.
regards, tom lane
In response to
pgsql-hackers by date
|Next:||From: Roland Roberts||Date: 2000-08-03 15:18:34|
|Subject: Re: [HACKERS] random() function produces wrong range|
|Previous:||From: Tom Lane||Date: 2000-08-03 14:40:24|
|Subject: Re: comparing rows |
pgsql-general by date
|Next:||From: Tom Lane||Date: 2000-08-03 15:07:56|
|Subject: Re: Functional indices with const params. |
|Previous:||From: Guillaume Perréal||Date: 2000-08-03 14:37:35|
|Subject: Re: Can't copy from file into table|