Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z9yEo-0001fp-F8 for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Jun 2015 16:18:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z9yEn-0004oS-Mg for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Jun 2015 16:18:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z9yDx-00046k-5S for pgsql-bugs@postgresql.org; Tue, 30 Jun 2015 16:17:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z9yDs-0006yr-0i for pgsql-bugs@postgresql.org; Tue, 30 Jun 2015 16:17:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t5UGHFKv006322; Tue, 30 Jun 2015 12:17:15 -0400 From: Tom Lane To: Petr Jelinek cc: Michael Paquier , PostgreSQL mailing lists Subject: Re: Re: sampling.c and potential divisions by 0 ang log(0) with tablesample and ANALYZE in 9.5 In-reply-to: <558E09FB.6010909@2ndquadrant.com> References: <558E09FB.6010909@2ndquadrant.com> Comments: In-reply-to Petr Jelinek message dated "Sat, 27 Jun 2015 04:27:07 +0200" Date: Tue, 30 Jun 2015 12:17:15 -0400 Message-ID: <6321.1435681035@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Petr Jelinek 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