From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
Cc: | petr(at)2ndquadrant(dot)com |
Subject: | sampling.c and potential divisions by 0 ang log(0) with tablesample and ANALYZE in 9.5 |
Date: | 2015-06-25 08:01:02 |
Message-ID: | CAB7nPqTL0YYPgGt00gV8mw+23U4ki8yXUKV0mfji3YVpAqR8sA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
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]
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.
This bug can be triggered when using TABLESAMPLE, now ANALYZE is more
worrying because it could happen during an auto-analyze.
Thoughts?
--
Michael
Attachment | Content-Type | Size |
---|---|---|
20150625_sampling_maths.patch | text/x-patch | 2.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | hubert depesz lubaczewski | 2015-06-25 12:15:56 | Bug in docs - modifiers for to_char() |
Previous Message | hunkaverage | 2015-06-25 06:07:20 | BUG #13468: System hijacked by PostgreSQL user |