Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Craig Ringer
Tom Lane wrote: Craig Ringer <[EMAIL PROTECTED]> writes: Personally I'd expect that to only evaluate once. It's saying "where f_name.counter in this row is equal to some single random value generated at the start of the query". The parameters of the random() function do not depend on the input,

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Artacus
You can force Pg to re-evaluate random() by adding a dummy parameter that depends on the input record, or (probably better) by writing a variant of it that tests the input against a randomly generated value and returns a boolean. Eg: Thanks all. So here's the situation. I added a dummy param

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Tom Lane
Craig Ringer <[EMAIL PROTECTED]> writes: > Personally I'd expect that to only evaluate once. It's saying "where > f_name.counter in this row is equal to some single random value > generated at the start of the query". The parameters of the random() > function do not depend on the input, so Pg evalu

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Klint Gore
Artacus wrote: So my understanding of volatile functions is that volatile functions can return different results given the same input. I have a function random(int, int) that returns a random value between $1 and $2. I want to use it in a query to generate values. But it only evaluates once p

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Craig Ringer
Artacus wrote: > So my understanding of volatile functions is that volatile functions can > return different results given the same input. > > I have a function random(int, int) that returns a random value between > $1 and $2. I want to use it in a query to generate values. But it only > evaluates

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Tom Lane
Artacus <[EMAIL PROTECTED]> writes: > I have a function random(int, int) that returns a random value between > $1 and $2. I want to use it in a query to generate values. But it only > evaluates once per query and not once per row like I need it to. > -- This always returns the same value > SELEC

[GENERAL] Problem with volatile function

2008-06-18 Thread Artacus
So my understanding of volatile functions is that volatile functions can return different results given the same input. I have a function random(int, int) that returns a random value between $1 and $2. I want to use it in a query to generate values. But it only evaluates once per query and not