Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails

From: Bernhard Reutner-Fischer <rep(dot)dot(dot)nop(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Boszormenyi Zoltan <zb(at)cybertec(dot)at>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
Date: 2011-12-01 22:04:14
Message-ID: CAC1BbcTHHKAS+Cp80OZz15pg8z4G0b7tThLGqjazLiwOSgYgwA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 1 December 2011 22:50, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
>
> Excerpts from Tom Lane's message of jue dic 01 18:32:58 -0300 2011:
>> Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
>> > 2011-12-01 20:09 keltezéssel, rep(dot)dot(dot)nop(at)gmail(dot)com írta:
>> >> Binding for &quot;OFFSET :offset&quot; works fine but binding for a &quot;FETCH NEXT :next
>> >> ROWS ONLY&quot; raises:
>> >> syntax error at or near &quot;$2&quot;
>> >> SELECT * FROM foo OFFSET $1 ROWS FETCH NEXT $2 ROWS ONLY
>>
>> > This is not a supported syntax. Consider using
>> > SELECT * FROM foo OFFSET $1 LIMIT $2
>> > instead.

I think it's SQL2008 and is the "new" way of stating OFFSET $1 LIMIT
$2 (see docs).

>>
>> Well, actually it is supported, but you missed the fine print where it
>> says that you have to add parentheses if the offset or count isn't a
>> simple integer constant.  I'll apply a patch to make that a bit more
>> obvious.
>
> Hmm, it works with parens only in the "fetch next" clause, they don't
> seem necessary in the limit.  FWIW.

Exactly. That's why I find the need to quote the latter a bit counter
intuitive :)
cheers,
>
> alvherre=# prepare foo(int, int) as select * from generate_series(1, 200) offset $1 fetch next ($2) rows only;
> PREPARE
> alvherre=# execute foo(2+3, 1+2);
>  generate_series
> -----------------
>               6
>               7
>               8
> (3 filas)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2011-12-01 22:06:04 Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
Previous Message Alvaro Herrera 2011-12-01 21:50:38 Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails