pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Make sampler_random_fract() actually obey its API contract. 2+ messages / 1 participants [nested] [flat]
* pgsql: Make sampler_random_fract() actually obey its API contract. @ 2015-07-01 22:08 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2015-07-01 22:08 UTC (permalink / raw) To: 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(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Make sampler_random_fract() actually obey its API contract. @ 2015-07-01 22:08 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2015-07-01 22:08 UTC (permalink / raw) To: 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 ------ REL9_5_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/cd7030ff085f5c378e837b392cb719cf23df9d0b Modified Files -------------- src/backend/utils/misc/sampling.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2015-07-01 22:08 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2015-07-01 22:08 pgsql: Make sampler_random_fract() actually obey its API contract. Tom Lane <tgl@sss.pgh.pa.us> 2015-07-01 22:08 pgsql: Make sampler_random_fract() actually obey its API contract. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox