Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1FACF632A8D for ; Sat, 1 May 2010 06:05:21 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 60482-09 for ; Sat, 1 May 2010 09:05:14 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moon.antora.ru (moon.antora.ru [89.111.189.180]) by mail.postgresql.org (Postfix) with ESMTP id C0806632A48 for ; Sat, 1 May 2010 06:05:13 -0300 (ADT) Envelope-to: pgsql-sql@postgresql.org Received: from moon.inner.space ([10.1.1.5] helo=moon.antora.ru) by moon.antora.ru with esmtp (Exim 4.67) (envelope-from ) id 1O88dM-0004Zb-M9 for pgsql-sql@postgresql.org; Sat, 01 May 2010 13:05:12 +0400 Received: from [192.168.1.6] [178.34.182.145] by moon.antora.ru (Axigen) with (DHE-RSA-AES256-SHA encrypted) ESMTPSA id 0F2994; Sat, 1 May 2010 13:05:12 +0400 Message-ID: <4BDBEEC7.5030405@bankir.ru> Date: Sat, 01 May 2010 13:05:11 +0400 From: silly sad User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20100111 Thunderbird/3.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: LIMIT problem References: <4BDAD20A.1090503@bankir.ru> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.89 tagged_above=-5 required=5 tests=AWL=0.090, BAYES_50=0.8 X-Spam-Level: X-Archive-Number: 201005/2 X-Sequence-Number: 34050 On 05/01/10 03:58, Jasen Betts wrote: > On 2010-04-30, silly sad wrote: >> suppose i request >> >> SELECT foo(t.x) FROM t LIMIT 1; >> >> Whither it DEFINED how many times foo() will be executed? > > foo will be executed repeatedly until it returns a result or all the > rows in t are exhausted. > >> May anyone rely on it? > > not sure > >> Or we have to avoid this non SQLish trick? > > > This will execute it once (or not at all where t has no rows) > > SELECT foo(x) FROM (SELECT x FROM t LIMIT 1) as bar; > this subselect "isolation" looks like a safe way. Unlike LIMITed select looks unpredictable to me. Thanx for assistance :)