pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@commandprompt.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Boszormenyi Zoltan <zb@cybertec.at>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Cc: rep.dot.nop <rep.dot.nop@gmail.com>
Subject: Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
Date: Thu, 01 Dec 2011 18:50:38 -0300
Message-ID: <1322776151-sup-3519@alvh.no-ip.org> (raw)
In-Reply-To: <16385.1322775178@sss.pgh.pa.us>
References: <E1RWC0F-0000xy-Bh@wrigleys.postgresql.org>
	<4ED7E66D.9090701@cybertec.at>
	<16385.1322775178@sss.pgh.pa.us>


Excerpts from Tom Lane's message of jue dic 01 18:32:58 -0300 2011:
> Boszormenyi Zoltan <zb@cybertec.at> writes:
> > 2011-12-01 20:09 keltezéssel, rep.dot.nop@gmail.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.
> 
> 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.

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)


-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support



view thread (6+ messages)  latest in thread

Message-ID: <1322776151-sup-3519@alvh.no-ip.org>
Permalink:  ../1322776151-sup-3519@alvh.no-ip.org/
Also on:    postgresql.org/message-id/1322776151-sup-3519@alvh.no-ip.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@commandprompt.com, tgl@sss.pgh.pa.us, zb@cybertec.at, rep.dot.nop@gmail.com
  Subject: Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
  In-Reply-To: <1322776151-sup-3519@alvh.no-ip.org>
  References: <E1RWC0F-0000xy-Bh@wrigleys.postgresql.org> <4ED7E66D.9090701@cybertec.at> <16385.1322775178@sss.pgh.pa.us> <1322776151-sup-3519@alvh.no-ip.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox