Re: [BUGS] BUG #14737: Wrong PL/pgSQL behaviour
От | David G. Johnston |
---|---|
Тема | Re: [BUGS] BUG #14737: Wrong PL/pgSQL behaviour |
Дата | |
Msg-id | CAKFQuwZn6DOm=+8vL3AnTXM4Jt1jJZFADpHOmk6WwfpXiZ5srA@mail.gmail.com обсуждение исходный текст |
Ответ на | [BUGS] BUG #14737: Wrong PL/pgSQL behaviour (frank.von.postgresql.org@familie-gard.de) |
Ответы |
Re: [BUGS] BUG #14737: Wrong PL/pgSQL behaviour
|
Список | pgsql-bugs |
Bug reference: 14737
Logged by: Frank Gard
Email address: frank.von.postgresql.org@familie-gard.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.
В списке pgsql-bugs по дате отправления: