Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z9yK5-00020W-If for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Jun 2015 16:23:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z9yK3-0000ax-Q5 for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Jun 2015 16:23:47 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z9yHz-0006th-MC for pgsql-bugs@postgresql.org; Tue, 30 Jun 2015 16:21:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z9yHw-0003eU-UW for pgsql-bugs@postgresql.org; Tue, 30 Jun 2015 16:21:37 +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 t5UGLSpR006413; Tue, 30 Jun 2015 12:21:28 -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: <6321.1435681035@sss.pgh.pa.us> References: <558E09FB.6010909@2ndquadrant.com> <6321.1435681035@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 30 Jun 2015 12:17:15 -0400" Date: Tue, 30 Jun 2015 12:21:28 -0400 Message-ID: <6412.1435681288@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 I wrote: > 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? And, in fact, a bit of looking quickly finds a counterexample, in analyze.c: int k = (int) (targrows * sampler_random_fract(rstate.randstate)); Assert(k >= 0 && k < targrows); You can't just whack this around to satisfy some new call sites without considering the behavior of existing use-cases. 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