Re: LIMIT problem

From: silly sad <sad(at)bankir(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: LIMIT problem
Date: 2010-05-01 09:05:11
Message-ID: 4BDBEEC7.5030405@bankir.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 05/01/10 03:58, Jasen Betts wrote:
> On 2010-04-30, silly sad<sad(at)bankir(dot)ru> 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 :)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Leif Biberg Kristensen 2010-05-01 17:29:03 Re: regexp_replace and search/replace values stored in table
Previous Message silly sad 2010-05-01 08:55:21 Re: LIMIT problem