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  (Frank Gard <frank@familie-gard.de>)
Список pgsql-bugs
On Fri, Jul 7, 2017 at 9:10 AM, <frank.von.postgresql.org@familie-gard.de> wrote:
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 по дате отправления:

Предыдущее
От: frank.von.postgresql.org@familie-gard.de
Дата:
Сообщение: [BUGS] BUG #14737: Wrong PL/pgSQL behaviour
Следующее
От: Grzegorz Grabek
Дата:
Сообщение: [BUGS] GIN index not working for integer[] if there is more then one columnin table