Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYwA3-00066T-Fu for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Oct 2013 10:59:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VYwA2-00032d-Er for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Oct 2013 10:59:34 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYwA1-00032W-2y for pgsql-bugs@postgresql.org; Wed, 23 Oct 2013 10:59:33 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYw9w-0006vE-IM for pgsql-bugs@postgresql.org; Wed, 23 Oct 2013 10:59:31 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 35AD5980F5; Wed, 23 Oct 2013 03:59:27 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 317F64045C; Wed, 23 Oct 2013 03:59:27 -0700 (PDT) Received: from zcs-prod-ext-mta-2.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 9FA63C0054; Wed, 23 Oct 2013 03:59:41 -0700 (PDT) Received: from [192.168.1.90] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA; Wed, 23 Oct 2013 03:59:34 -0700 (PDT) Message-ID: <5267AC01.1030203@vmware.com> Date: Wed, 23 Oct 2013 13:59:13 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Honza Horak CC: pgsql-bugs@postgresql.org Subject: Re: random() generates collisions too early References: <5261219D.3060205@redhat.com> <526537ED.2010607@vmware.com> <526667BF.3040601@redhat.com> In-Reply-To: <526667BF.3040601@redhat.com> Content-Type: multipart/mixed; boundary="------------030606080307040709060003" X-Pg-Spam-Score: -7.3 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------030606080307040709060003 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 22.10.2013 14:55, Honza Horak wrote: > On 10/21/2013 04:19 PM, Heikki Linnakangas wrote: >> On 18.10.2013 14:55, Honza Horak wrote: >>> Also, I'd suggest to state explicitly in the doc, that random() >>> shouldn't be taken as CSPRNG, since I can imagine people blindly >>> believing that random() can be good enough for such use cases, just >>> because they see how many possible values they get from double-precision >>> type: >>> http://www.postgresql.org/docs/9.3/static/functions-math.html >> >> Yeah, that seems like a good idea. A patch would be welcome. > > I don't think we need to tell some long stories here, so what about this > one: > "pseudo-random value in the range 0.0 < x < 1.0 (characteristic of > randomness depends on the system implementation and is usually limited, > thus not considered as a CSPRNG in any case)" I had to look up what CSPRNG stands for, so we probably should spell it out. Also not sure what it means for the characteristic of the randomness to be limited. How about something like: > random value in the range 0.0 <= x < 1.0 (the characteristics of the > returned values depends on the system implementation. This function > is not suitable for cryptographic applications; use pgcrypto > instead.) Or perhaps it would be even better to move random() and setseed to a separate table. They are somewhat different from the rest of the functions listed in the table of Mathematical Functions, and it would be nice to list them together; currently the round() functions fall between them in the alphabetically ordered table. What do you think of the attached? - Heikki --------------030606080307040709060003 Content-Type: text/x-diff; name="random-doc-1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="random-doc-1.patch" diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index e397386..b53145a 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -831,19 +831,6 @@ - random - - random() - - dp - random value in the range 0.0 <= x < 1.0 - random() - - - - - - round round(dp or numeric) @@ -865,20 +852,6 @@ - setseed - - setseed(dp) - - void - set seed for subsequent random() calls (value between -1.0 and - 1.0, inclusive) - setseed(0.54823) - - - - - - sign sign(dp or numeric) @@ -952,6 +925,56 @@ + shows functions for + generating random numbers. + + + + Random Functions + + + + + Function + Return Type + Description + + + + + + + random + + random() + + dp + random value in the range 0.0 <= x < 1.0 + + + + + + setseed + + setseed(dp) + + void + set seed for subsequent random() calls (value between -1.0 and + 1.0, inclusive) + + + +
+ + + The characteristics of the values returned by + random() depends + on the system implementation. It is not suitable for cryptographic + applications; see module for an alternative. + + + Finally, shows the available trigonometric functions. All trigonometric functions take arguments and return values of type double --------------030606080307040709060003 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --------------030606080307040709060003--