Re: What seed does random() use if setseed() is not called first?

From: Carl Sopchak <carl(at)sopchak(dot)me>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: What seed does random() use if setseed() is not called first?
Date: 2022-07-23 21:55:40
Message-ID: e3248816-94aa-a983-054f-260ad93bd950@sopchak.me
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Thank you for the quick reply!  But I wouldn't have bothered you
if the documentation stated something to the effect of "While it's
platform-dependent, if setseed() is not called, the random number
generator is generally seeded by whatever method the operating
system provides as a source of randomness, such as /dev/urandom on
Linux/Unix, or &lt;???&gt; on Windows."</p>
<p>Just a suggestion, hope this helps, and thanks again!</p>
<p>Carl<br>
</p>
<div class="moz-cite-prefix">On 7/23/22 17:47, Tom Lane wrote:<br>
</div>
<blockquote type="cite" cite="mid:1220338(dot)1658612839(at)sss(dot)pgh(dot)pa(dot)us">
<pre class="moz-quote-pre" wrap="">Carl Sopchak <a class="moz-txt-link-rfc2396E" href="mailto:carl(at)sopchak(dot)me">&lt;carl(at)sopchak(dot)me&gt;</a> writes:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap=""> &lt;p&gt;There is one point about the documentation for random() and
setseed() that is missing.  What is used to seed random() if
setseed() isn't called first?  I assume it's something like
/dev/random or /dev/urandom, but that's just a guess.  Can someone
please enlighten me?&lt;/p&gt;
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
We don't document this because it's platform- and version-dependent,
but yeah, generally /dev/urandom or local equivalent.

regards, tom lane
</pre>
</blockquote>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.5 KB

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2022-07-23 22:06:01 Re: What seed does random() use if setseed() is not called first?
Previous Message Tom Lane 2022-07-23 21:47:19 Re: What seed does random() use if setseed() is not called first?