From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | frank(dot)von(dot)postgresql(dot)org(at)familie-gard(dot)de |
Cc: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #14737: Wrong PL/pgSQL behaviour |
Date: | 2017-07-07 16:28:03 |
Message-ID: | CAKFQuwZn6DOm=+8vL3AnTXM4Jt1jJZFADpHOmk6WwfpXiZ5srA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Fri, Jul 7, 2017 at 9:10 AM, <frank(dot)von(dot)postgresql(dot)org(at)familie-gard(dot)de>
wrote:
> Bug reference: 14737
> Logged by: Frank Gard
> Email address: frank(dot)von(dot)postgresql(dot)org(at)familie-gard(dot)de
> PostgreSQL version: 9.6.3
> Operating system: Debian GNU/Linux
>
Not a bug - RANDOM() is a volatile function so it gets evaluated once per
row.
UPDATE ttb_histogramm
> SET
> anzahl = anzahl + 1
> WHERE
> wert = p_von + FLOOR( ( 1 + p_bis - p_von ) * RANDOM() )
Unfortunately this is not the case. When calling it
> multiple times, it returns numbers smaller and greater, and always
> different
> values for each call. Very strange (to me)!!!
>
Which is the symptom one will see if, for every row, the value of random
is different.
> When I change my function a little bit, writing the random number into an
> INTEGER variable, and using this variable within my UPDATE statement,
> everything works fine:
>
Then this is what you should do.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Grzegorz Grabek | 2017-07-07 17:19:42 | GIN index not working for integer[] if there is more then one column in table |
Previous Message | frank.von.postgresql.org | 2017-07-07 16:10:41 | BUG #14737: Wrong PL/pgSQL behaviour |