Commit 31d5354c authored by Tom Lane's avatar Tom Lane

Doc: improve documentation about random().

We didn't explicitly say that random() uses a randomly-chosen seed
if you haven't called setseed().  Do so.

Also, remove ref/set.sgml's no-longer-accurate (and never very
relevant) statement that the seed value is multiplied by 2^31-1.

Back-patch to v12 where set.sgml's claim stopped being true.
The claim that we use a source of random bits as seed was debatable
before 4203842a, too, so v12 seems like a good place to stop.

Per question from Carl Sopchak.

Discussion: https://postgr.es/m/f37bb937-9d99-08f0-4de7-80c91a3cfc2e@sopchak.me
parent fee0165f
...@@ -1840,6 +1840,9 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue> ...@@ -1840,6 +1840,9 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
subsequent <function>random()</function> calls in the current session subsequent <function>random()</function> calls in the current session
can be repeated by re-issuing <function>setseed()</function> with the same can be repeated by re-issuing <function>setseed()</function> with the same
argument. argument.
Without any prior <function>setseed()</function> call in the same
session, the first <function>random()</function> call obtains a seed
from a platform-dependent source of random bits.
</para> </para>
<para> <para>
......
...@@ -175,8 +175,7 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="parameter">timezone</rep ...@@ -175,8 +175,7 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="parameter">timezone</rep
<para> <para>
Sets the internal seed for the random number generator (the Sets the internal seed for the random number generator (the
function <function>random</function>). Allowed values are function <function>random</function>). Allowed values are
floating-point numbers between -1 and 1, which are then floating-point numbers between -1 and 1 inclusive.
multiplied by 2<superscript>31</superscript>-1.
</para> </para>
<para> <para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment