Re: setseed accepts bad seeds

From: Kris Jurka <books(at)ejurka(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: setseed accepts bad seeds
Date: 2007-04-11 17:37:35
Message-ID: Pine.BSO.4.64.0704111328310.11607@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 11 Apr 2007, Tom Lane wrote:

> Kris Jurka <books(at)ejurka(dot)com> writes:
>> Why doesn't setseed complain when given a seed value outside of its
>> expected range?
>
> Why should it complain? The use of the value is totally unspecified
> anyway.
>

Because the user is likely using it incorrectly. I'm not sure what you
mean by totally unspecified. The documentation[1] states:

set seed for subsequent random() calls (value between 0 and 1.0)

When a user calls setseed(5), setseed(500), or setseed(-500) they get the
same seed value each time which is surely not what they intended. At
minimum I think it should raise a warning.

Also I think that documentation should be corrected to indicate that
vaules -1 to 1 are the correct seed value range or it should it should map
0->1 to the entire seed space, not just half of it as is currently done.
The decision of which change to make is unclear because it's a change to
either the call signature or to the generated values for a given user
supplied seed.

Kris Jurka

[1] http://www.postgresql.org/docs/8.2/static/functions-math.html#FUNCTIONS-MATH-FUNC-TABLE

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2007-04-11 18:29:35 Re: setseed accepts bad seeds
Previous Message Tom Lane 2007-04-11 14:50:29 Re: setseed accepts bad seeds