Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 5D22018FE98B for ; Thu, 1 Dec 2011 17:51:02 -0400 (AST) Received: from 30.55.colo.spiretech.net ([69.168.55.30] helo=lists.commandprompt.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RWEWv-00058C-SE for pgsql-bugs@postgresql.org; Thu, 01 Dec 2011 21:51:01 +0000 Received: from perhan.alvh.no-ip.org (spinlock.commandprompt.com [69.168.55.30]) by lists.commandprompt.com (Postfix) with ESMTPA id 42E99217; Thu, 1 Dec 2011 13:50:42 -0800 (PST) Received: from perhan.alvh.no-ip.org ([200.126.81.66] helo=perhan.alvh.no-ip.org) by assp.commandprompt.com with ESMTPS(AES256-SHA) (2.1.1); 1 Dec 2011 13:50:40 -0800 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 6A2E06E478; Thu, 1 Dec 2011 18:50:38 -0300 (CLST) Content-Type: text/plain; charset=UTF-8 Cc: Boszormenyi Zoltan , Pg Bugs , rep.dot.nop Subject: Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails From: Alvaro Herrera To: Tom Lane In-reply-to: <16385.1322775178@sss.pgh.pa.us> References: <4ED7E66D.9090701@cybertec.at> <16385.1322775178@sss.pgh.pa.us> Date: Thu, 01 Dec 2011 18:50:38 -0300 Message-Id: <1322776151-sup-3519@alvh.no-ip.org> User-Agent: Sup/git X-Assp-Version: 2.1.1(11278) on assp.commandprompt.com X-Assp-Client-TLS: yes X-Assp-ID: assp.commandprompt.com m1-76242-02618 X-Assp-Envelope-From: alvherre@alvh.no-ip.org X-Assp-Intended-For: zb@cybertec.at X-Assp-Original-Subject: Re: [BUGS] BUG #6315: FETCH NEXT :next ROWS ONLY fails Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/16 X-Sequence-Number: 31827 Excerpts from Tom Lane's message of jue dic 01 18:32:58 -0300 2011: > Boszormenyi Zoltan writes: > > 2011-12-01 20:09 keltez=C3=A9ssel, rep.dot.nop@gmail.com =C3=ADrta: > >> Binding for "OFFSET :offset" works fine but binding for a = "FETCH NEXT :next > >> ROWS ONLY" raises: > >> syntax error at or near "$2" > >> SELECT * FROM foo OFFSET $1 ROWS FETCH NEXT $2 ROWS ONLY >=20 > > This is not a supported syntax. Consider using > > SELECT * FROM foo OFFSET $1 LIMIT $2 > > instead. >=20 > 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=3D# prepare foo(int, int) as select * from generate_series(1, 20= 0) offset $1 fetch next ($2) rows only; PREPARE alvherre=3D# execute foo(2+3, 1+2); generate_series=20 ----------------- 6 7 8 (3 filas) --=20 =C3=81lvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support