pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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 12:17:15 -0400
Message-ID: <6321.1435681035@sss.pgh.pa.us> (raw)
In-Reply-To: <558E09FB.6010909@2ndquadrant.com>
References: <CAB7nPqTL0YYPgGt00gV8mw+23U4ki8yXUKV0mfji3YVpAqR8sA@mail.gmail.com>
	<558E09FB.6010909@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Petr Jelinek <petr@2ndquadrant.com> writes:
> On 2015-06-25 10:01, Michael Paquier wrote:
>> I think that we should change the returned double to be (0.0,1.0]

> Agreed.

I find this to be a pretty bad idea.  That definition is simply weird;
where else in the world will you find a random number generator that does
that?  What are the odds that any callers are actually designed for that
behavior?

Another problem is that we consider anl_random_fract() to be an exported
API, and the very longstanding definition of that is that the result is
in (0,1), excluding both endpoints.  Whatever we do with
sampler_random_fract(), we'd better make sure that anl_random_fract()
preserves that behavior, else we are likely to break third-party modules.

A simple fix would be to adjust sampler_random_fract to disallow 0
as result, say by repeating the pg_erand48 call if it produces 0.
I'm not sure if that would throw off any of the math in the new
tablesample-related callers.  If it would, I'm inclined to fix the
problem call-site-by-call-site, rather than inventing a definition
of sampler_random_fract() that fails to satisfy the POLA.

			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



view thread (12+ messages)  latest in thread

Message-ID: <6321.1435681035@sss.pgh.pa.us>
Permalink:  ../6321.1435681035@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6321.1435681035@sss.pgh.pa.us

 · 

reply

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: <6321.1435681035@sss.pgh.pa.us>
  References: <CAB7nPqTL0YYPgGt00gV8mw+23U4ki8yXUKV0mfji3YVpAqR8sA@mail.gmail.com> <558E09FB.6010909@2ndquadrant.com> <6321.1435681035@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