Re: setseed() doc

Lists: pgsql-hackerspgsql-patches
From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: pgsql-patches(at)postgresql(dot)org
Subject: setseed() doc
Date: 2006-09-04 18:30:27
Message-ID: 44FC70C3.6020801@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

The doc doesn't state in what range the argument to setseed() should be.

Some tests suggest that only values in the range -1.0 to 1.0 work as a
seed and values outside of that give the same sequence of random numbers.

I've attached a trivial one line patch (this is the patch list after
all), but feel free to document it in any way that is appropriate.

setseed() also return an integer, but I have no clue of what it is. The
doc doesn't say anything about it.

The doc say that some functions here depend on the libc that is used,
but such things as the range of the argument and what the return value
is should be in the doc, shouldn't it?

/Dennis

Attachment Content-Type Size
setseed.txt text/plain 791 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org, Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: setseed() doc
Date: 2006-09-04 18:53:02
Message-ID: 10625.1157395982@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org> writes:
> <entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
> <entry><type>int</type></entry>
> - <entry>set seed for subsequent <literal>random()</literal> calls</entry>
> + <entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and 1.0)</entry>

Looking at the code, it would appear that the intended range is 0 to 1.

regards, tom lane


From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: setseed() doc
Date: 2006-09-04 19:05:55
Message-ID: 44FC7913.1090705@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane skrev:

>> <entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
>> <entry><type>int</type></entry>
>> - <entry>set seed for subsequent <literal>random()</literal> calls</entry>
>> + <entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and 1.0)</entry>
>
> Looking at the code, it would appear that the intended range is 0 to 1.

Ok.

What about the return value? The doc didn't say anything about it.

/Dennis


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: setseed() doc
Date: 2006-09-04 19:19:44
Message-ID: 10847.1157397584@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org> writes:
> What about the return value? The doc didn't say anything about it.

AFAICT it's just junk. It happens to be the input times
MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
change the function to return VOID ... that option wasn't available
when it was coded originally, else it'd probably have been done that
way.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>, pgsql-patches(at)postgresql(dot)org
Subject: Re: setseed() doc
Date: 2006-09-04 21:47:51
Message-ID: 200609042147.k84LlpK05094@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org> writes:
> > <entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
> > <entry><type>int</type></entry>
> > - <entry>set seed for subsequent <literal>random()</literal> calls</entry>
> > + <entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and 1.0)</entry>
>
> Looking at the code, it would appear that the intended range is 0 to 1.

Docs updated.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
/bjm/diff text/x-diff 1.1 KB

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: setseed() doc
Date: 2006-09-20 15:10:15
Message-ID: 1158765015.5151.1.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

On Mon, 2006-09-04 at 15:19 -0400, Tom Lane wrote:
> AFAICT it's just junk. It happens to be the input times
> MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
> change the function to return VOID

I agree. Given how soon we want to get an 8.2 beta out the door, perhaps
this change would be best postponed to 8.3 (unless there's another
outstanding 8.2 patch that requires initdb?).

-Neil


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] setseed() doc
Date: 2006-09-20 15:47:39
Message-ID: 3830.1158767259@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Neil Conway <neilc(at)samurai(dot)com> writes:
> On Mon, 2006-09-04 at 15:19 -0400, Tom Lane wrote:
>> AFAICT it's just junk. It happens to be the input times
>> MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
>> change the function to return VOID

> I agree. Given how soon we want to get an 8.2 beta out the door, perhaps
> this change would be best postponed to 8.3 (unless there's another
> outstanding 8.2 patch that requires initdb?).

Nothing outstanding at the moment.

Although this is surely a small change, it's also pretty low-priority,
so I'd counsel leaving it for 8.3 rather than trying to cram it in now.
We have more important things to be worrying about ...

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Neil Conway <neilc(at)samurai(dot)com>, Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] [PATCHES] setseed() doc
Date: 2007-01-20 21:48:18
Message-ID: 200701202148.l0KLmJq15303@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches


FYI, Neil has corrected this in CVS HEAD.

---------------------------------------------------------------------------

Tom Lane wrote:
> Neil Conway <neilc(at)samurai(dot)com> writes:
> > On Mon, 2006-09-04 at 15:19 -0400, Tom Lane wrote:
> >> AFAICT it's just junk. It happens to be the input times
> >> MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
> >> change the function to return VOID
>
> > I agree. Given how soon we want to get an 8.2 beta out the door, perhaps
> > this change would be best postponed to 8.3 (unless there's another
> > outstanding 8.2 patch that requires initdb?).
>
> Nothing outstanding at the moment.
>
> Although this is surely a small change, it's also pretty low-priority,
> so I'd counsel leaving it for 8.3 rather than trying to cram it in now.
> We have more important things to be worrying about ...
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +