Re: What seed does random() use if setseed() is not called first?
Carl Sopchak <carl@sopchak.me>
From: Carl Sopchak <carl@sopchak.me>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@lists.postgresql.org
Date: 2022-07-23T21:55:40Z
Lists: pgsql-sql
Attachments
- (unnamed) (text/html)
<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 <???> 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.1658612839@sss.pgh.pa.us">
<pre class="moz-quote-pre" wrap="">Carl Sopchak <a class="moz-txt-link-rfc2396E" href="mailto:carl@sopchak.me"><carl@sopchak.me></a> writes:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap=""> <p>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?</p>
</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>
Commits
-
Doc: improve documentation about random().
- 6955bba0ede4 16.0 landed
- bd6cfbf338e5 15.0 landed
- 4c9e5162f56d 13.8 landed
- 31d5354cb148 14.5 landed
- 042554d55d85 12.12 landed