| From: | Petr Jelinek <petr(at)2ndquadrant(dot)com> |
|---|---|
| To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: sampling.c and potential divisions by 0 ang log(0) with tablesample and ANALYZE in 9.5 |
| Date: | 2015-06-27 02:27:07 |
| Message-ID: | 558E09FB.6010909@2ndquadrant.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On 2015-06-25 10:01, Michael Paquier wrote:
> Hi all,
> (Petr in CC)
>
> Coverity is pointing out that anl_random_fract and
> sampler_random_fract can return 0, causing in some code paths math
> errors, aka division by 0 or even log(0) in the case of TABLESAMPLE or
> even ANALYZE.
>
> In 9.4, anl_random_fract is careful enough to use random() + 1 to
> prevent that, but that's not the case of 9.5 where we begin to use
> pg_erand48, that returns a double in range [0.0,1.0).
>
> I think that we should change the returned double to be (0.0,1.0]
Agreed.
> instead like in the patch attached (bernouilli and system methods need
> a brush-up as well). I haven't updated tsm_system_rows and
> tsm_system_time but their regression diffs are attached.
>
I don't see need for the other 1 - x changes outside of the
sampler_random_fract() tbh. Yes it changes the regression tests output
but I don't think it changes correctness of the results.
--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
| Attachment | Content-Type | Size |
|---|---|---|
| sampling_division_by_zero,diff | text/plain | 6.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2015-06-27 05:46:08 | Re: sampling.c and potential divisions by 0 ang log(0) with tablesample and ANALYZE in 9.5 |
| Previous Message | Jim Nasby | 2015-06-26 23:13:31 | Re: [HACKERS] BUG #13473: VACUUM FREEZE mistakenly cancel standby sessions |