pgsql: Make sampler_random_fract() actually obey its API contract.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Make sampler_random_fract() actually obey its API contract.
Дата
Msg-id E1ZAQAn-0006Gh-WE@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Make sampler_random_fract() actually obey its API contract.

This function is documented to return a value in the range (0,1),
which is what its predecessor anl_random_fract() did.  However, the
new version depends on pg_erand48() which returns a value in [0,1).
The possibility of returning zero creates hazards of division by zero
or trying to compute log(0) at some call sites, and it might well
break third-party modules using anl_random_fract() too.  So let's
change it to never return zero.  Spotted by Coverity.

Michael Paquier, cosmetically adjusted by me

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/d7c19d68550eb6018e8581a73a351905f4cc435c

Modified Files
--------------
src/backend/utils/misc/sampling.c |    9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Fujii Masao
Дата:
Сообщение: pgsql: Make XLogFileCopy() look the same as in 9.4.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Make sampler_random_fract() actually obey its API contract.