1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Clean up bogosities in use of random(3) and srandom(3) --- do not assume

that RAND_MAX applies to them, since it doesn't.  Instead add a
config.h parameter MAX_RANDOM_VALUE.  This is currently set at 2^31-1
but could be auto-configured if that ever proves necessary.  Also fix
some outright bugs like calling srand() where srandom() is appropriate.
This commit is contained in:
Tom Lane
2000-08-07 00:51:42 +00:00
parent 259489bab7
commit 9426047021
8 changed files with 47 additions and 25 deletions

View File

@ -171,6 +171,18 @@
<entry>convert floating point to integer</entry>
<entry>integer(2.0)</entry>
</row>
<row>
<entry>random()</entry>
<entry>float8</entry>
<entry>random value in the range 0.0 to 1.0</entry>
<entry>random()</entry>
</row>
<row>
<entry>setseed(float8)</entry>
<entry>int</entry>
<entry>set seed for subsequent random() calls</entry>
<entry>setseed(0.54823)</entry>
</row>
</tbody>
</tgroup>
</table>

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.46 2000/07/14 15:27:14 thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.47 2000/08/07 00:51:18 tgl Exp $
Postgres documentation
-->
@ -194,9 +194,9 @@ SET TIME ZONE { '<replaceable class="PARAMETER">timezone</replaceable>' | LOCAL
<listitem>
<para>
The value for the seed to be used by the
<function>random</function> catalog function. Significant
<function>random</function> function. Allowed
values are floating point numbers between 0 and 1, which
are then multiplied by RAND_MAX. This product will
are then multiplied by 2^31-1. This product will
silently overflow if a number outside the range is used.
</para>