public inbox for [email protected]  
help / color / mirror / Atom feed
From: Fabien COELHO <[email protected]>
To: Dean Rasheed <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: =?ISO-8859-15?Q?Dagfinn_Ilmari_Manns=E5ker?= <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: random() function documentation
Date: Tue, 12 Apr 2022 10:19:07 +0200 (CEST)
Message-ID: <alpine.DEB.2.22.394.2204120950260.1378296@pseudo> (raw)
In-Reply-To: <CAEZATCVOKJvvjsEhbKLjpFtbNvnGEmf51gXJbG3Y=FV_LQoPbA@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CAEZATCVOKJvvjsEhbKLjpFtbNvnGEmf51gXJbG3Y=FV_LQoPbA@mail.gmail.com>


>>>> How about we just say "uses a linear-feedback shift register algorithm"?
>
> I think it'd be sufficient to just say that it's a deterministic
> pseudorandom number generator. I don't see much value in documenting
> the internal algorithm used.

Hmmm… I'm not so sure. ISTM that people interested in using the random 
user-facing variants (only random?) could like a pointer on the algorithm 
to check for the expected quality of the produced pseudo-random stream?

See attached.

>>> Should we perhaps also add a warning that the same seed is not 
>>> guaranteed to produce the same sequence across different (major?) 
>>> versions?
>>
>> I wouldn't bother, on the grounds that then we'd need such disclaimers
>> in a whole lot of places.  Others might see it differently though.
>
> Agreed,

Agreed.

> though I think when the release notes are written, they ought
> to warn that the sequence will change with this release.

Yes.

-- 
Fabien.

Attachments:

  [text/x-diff] random-algo.patch (1.0K, ../alpine.DEB.2.22.394.2204120950260.1378296@pseudo/2-random-algo.patch)
  download | inline diff:
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 0a5c402640..7492454592 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1832,10 +1832,11 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
    </table>
 
   <para>
-   The <function>random()</function> function uses a simple linear
-   congruential algorithm.  It is fast but not suitable for cryptographic
-   applications; see the <xref linkend="pgcrypto"/> module for a more
-   secure alternative.
+   The <function>random()</function> function uses
+   <ulink url="https://en.wikipedia.org/wiki/Xoroshiro128%2B">xoroshiro128**</ulink>, a
+   linear feedback shift register algorithm.
+   It is fast but not suitable for cryptographic applications;
+   see the <xref linkend="pgcrypto"/> module for a more secure alternative.
    If <function>setseed()</function> is called, the series of results of
    subsequent <function>random()</function> calls in the current session
    can be repeated by re-issuing <function>setseed()</function> with the same


view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: random() function documentation
  In-Reply-To: <alpine.DEB.2.22.394.2204120950260.1378296@pseudo>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox