random escape function

Поиск
Список
Период
Сортировка
Искать

random escape function

От:
Kris Jurka <books@ejurka.com>
Дата:

The escape function {fn rand(param)} isn't working on 8.3 servers because 
setseed has been changed to return void and reading the JDBC spec, I'm not 
sure it ever worked as required.

We map "SELECT {fn rand(0.5)}" to "SELECT setseed(0.5)*0+random()" which 
worked in previous servers because the setseed call returned an int.  Now 
we get "ERROR: operator does not exist: void * integer".  So that's our 
immediate problem, but looking a little closer at the spec shows that rand 
is supposed to take an integer argument, not a float limited to 0->1.  So 
at minimum we'd need to remap the parameter range.

Also the spec doesn't say what rand is actually supposed to do.  What is 
the purpose of providing a rand function if you have to supply a seed 
every single time.  The seed has to be random, so where does that come 
from?  Is the idea that you pass the same seed every time and get the next 
value from that seed's stream?

Given the above functional and definitional problems I think the easiest 
course of action is to simply remove the mapping.

Kris Jurka


Re: random escape function

От:
"Xavier Poinsard" <xpoinsard@free.fr>
Дата:
Ok, you can remove this mapping.

Kris Jurka a écrit :
> 
> The escape function {fn rand(param)} isn't working on 8.3 servers
> because setseed has been changed to return void and reading the JDBC
> spec, I'm not sure it ever worked as required.
> 
> We map "SELECT {fn rand(0.5)}" to "SELECT setseed(0.5)*0+random()" which
> worked in previous servers because the setseed call returned an int. 
> Now we get "ERROR: operator does not exist: void * integer".  So that's
> our immediate problem, but looking a little closer at the spec shows
> that rand is supposed to take an integer argument, not a float limited
> to 0->1.  So at minimum we'd need to remap the parameter range.
> 
> Also the spec doesn't say what rand is actually supposed to do.  What is
> the purpose of providing a rand function if you have to supply a seed
> every single time.  The seed has to be random, so where does that come
> from?  Is the idea that you pass the same seed every time and get the
> next value from that seed's stream?
> 
> Given the above functional and definitional problems I think the easiest
> course of action is to simply remove the mapping.
> 
> Kris Jurka
> 
> 

Re: random escape function

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Kris Jurka  writes:
> Also the spec doesn't say what rand is actually supposed to do.  What is 
> the purpose of providing a rand function if you have to supply a seed 
> every single time.

Is it really a seed?  Maybe it's supposed to be the desired range of the
output, or something.

			regards, tom lane

Re: random escape function

От:
Kris Jurka <books@ejurka.com>
Дата:


On Wed, 11 Apr 2007, Tom Lane wrote:

> Kris Jurka  writes:
>> Also the spec doesn't say what rand is actually supposed to do.  What is
>> the purpose of providing a rand function if you have to supply a seed
>> every single time.
>
> Is it really a seed?  Maybe it's supposed to be the desired range of the
> output, or something.
>

All the documentation has to say is "RAND(integer) Random floating point 
for seed integer)"  so it clearly thinks it's a seed of some kind.

Kris Jurka
FAQ