git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: 8217370) | patch
Make sampler_random_fract() actually obey its API contract.
Wed, 1 Jul 2015 22:07:48 +0000 (18:07 -0400)
Wed, 1 Jul 2015 22:07:48 +0000 (18:07 -0400)
commit d7c19d68550eb6018e8581a73a351905f4cc435c
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
src/backend/utils/misc/sampling.c diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /