Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id C6A2D18FE98B for ; Thu, 1 Dec 2011 18:06:20 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RWElo-0006fY-Q6 for pgsql-bugs@postgresql.org; Thu, 01 Dec 2011 22:06:21 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pB1M652Z018846; Thu, 1 Dec 2011 17:06:05 -0500 (EST) To: Alvaro Herrera cc: Boszormenyi Zoltan , Pg Bugs , "rep.dot.nop" Subject: Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails In-reply-to: <1322776151-sup-3519@alvh.no-ip.org> References: <4ED7E66D.9090701@cybertec.at> <16385.1322775178@sss.pgh.pa.us> <1322776151-sup-3519@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Thu, 01 Dec 2011 18:50:38 -0300" Date: Thu, 01 Dec 2011 17:06:04 -0500 Message-ID: <18845.1322777164@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -3.1 (---) X-Archive-Number: 201112/17 X-Sequence-Number: 31828 Alvaro Herrera writes: > Excerpts from Tom Lane's message of jue dic 01 18:32:58 -0300 2011: >> 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. ITYM "offset"? You do need the parens if you want to spell it SQL:2008's way, with the ROW/ROWS noise word. regression=# select * from int8_tbl offset 2+2; q1 | q2 ------------------+------------------- 4567890123456789 | -4567890123456789 (1 row) regression=# select * from int8_tbl offset 2+2 rows; ERROR: syntax error at or near "rows" LINE 1: select * from int8_tbl offset 2+2 rows; ^ regression=# select * from int8_tbl offset (2+2) rows; q1 | q2 ------------------+------------------- 4567890123456789 | -4567890123456789 (1 row) The comment in gram.y says there are parsing conflicts if we try to not require the parens, and that SQL:2008 doesn't actually require anything beyond a simple integer constant here. regards, tom lane