From: Tom Lane <tgl@sss.pgh.pa.us>
To: Petr Jelinek <petr@2ndquadrant.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: Re: sampling.c and potential divisions by 0 ang log(0) with tablesample and ANALYZE in 9.5
Date: Tue, 30 Jun 2015 14:52:02 -0400
Message-ID: <31445.1435690322@sss.pgh.pa.us> (raw)
In-Reply-To: <5592CE94.1000208@2ndquadrant.com>
References: <CAB7nPqTL0YYPgGt00gV8mw+23U4ki8yXUKV0mfji3YVpAqR8sA@mail.gmail.com>
<558E09FB.6010909@2ndquadrant.com>
<6321.1435681035@sss.pgh.pa.us>
<6412.1435681288@sss.pgh.pa.us>
<5592CE94.1000208@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Petr Jelinek <petr@2ndquadrant.com> writes:
> Right, very good point.
> So, we used to protect against this problem by using long value and doing:
> ((double) random() + 1) / ((double) MAX_RANDOM_VALUE + 2)
> Maybe best solution is to have pg_lrand48() variant which accepts seed
> as parameter same way pg_erand48() does and use the same logic we used
> to have before sampling was added.
I'm unimpressed with this coding because it presumes that MAX_RANDOM_VALUE
(which is defined as the maximum value returned by random()) has something
to do with the output range of pg_lrand48(). While that might
accidentally fail to fail on all known platforms, it's not good, because
those functions don't have the same provenance and so there's no good
reason to assume that they produce the same output range.
Rather than expanding the API of port.h still further, I continue to think
that the best answer is just to repeat if we get a zero from pg_erand48.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, petr@2ndquadrant.com, michael.paquier@gmail.com
Subject: Re: sampling.c and potential divisions by 0 ang log(0) with tablesample and ANALYZE in 9.5
In-Reply-To: <31445.1435690322@sss.pgh.pa.us>
References: <CAB7nPqTL0YYPgGt00gV8mw+23U4ki8yXUKV0mfji3YVpAqR8sA@mail.gmail.com> <558E09FB.6010909@2ndquadrant.com> <6321.1435681035@sss.pgh.pa.us> <6412.1435681288@sss.pgh.pa.us> <5592CE94.1000208@2ndquadrant.com> <31445.1435690322@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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