pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6315: FETCH NEXT :next ROWS ONLY fails
6+ messages / 5 participants
[nested] [flat]
* BUG #6315: FETCH NEXT :next ROWS ONLY fails
@ 2011-12-01 19:09 rep.dot.nop@gmail.com
2011-12-01 20:41 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Boszormenyi Zoltan <zb@cybertec.at>
0 siblings, 1 reply; 6+ messages in thread
From: rep.dot.nop@gmail.com @ 2011-12-01 19:09 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 6315
Logged by: Bernhard Reutner-Fischer
Email address: rep.dot.nop@gmail.com
PostgreSQL version: 9.1.1
Operating system: linux
Description:
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
2011-12-01 19:09 BUG #6315: FETCH NEXT :next ROWS ONLY fails rep.dot.nop@gmail.com
@ 2011-12-01 20:41 ` Boszormenyi Zoltan <zb@cybertec.at>
2011-12-01 21:32 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Boszormenyi Zoltan @ 2011-12-01 20:41 UTC (permalink / raw)
To: pgsql-bugs
2011-12-01 20:09 keltezéssel, rep.dot.nop@gmail.com írta:
> The following bug has been logged on the website:
>
> Bug reference: 6315
> Logged by: Bernhard Reutner-Fischer
> Email address: rep.dot.nop@gmail.com
> PostgreSQL version: 9.1.1
> Operating system: linux
> Description:
>
> 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
This is not a supported syntax. Consider using
SELECT * FROM foo OFFSET $1 LIMIT $2
instead.
--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
2011-12-01 19:09 BUG #6315: FETCH NEXT :next ROWS ONLY fails rep.dot.nop@gmail.com
2011-12-01 20:41 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Boszormenyi Zoltan <zb@cybertec.at>
@ 2011-12-01 21:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-12-01 21:50 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2011-12-01 21:32 UTC (permalink / raw)
To: Boszormenyi Zoltan <zb@cybertec.at>; +Cc: pgsql-bugs; rep.dot.nop@gmail.com
Boszormenyi Zoltan <zb@cybertec.at> writes:
> 2011-12-01 20:09 keltezéssel, rep.dot.nop@gmail.com írta:
>> 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
> 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.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
2011-12-01 19:09 BUG #6315: FETCH NEXT :next ROWS ONLY fails rep.dot.nop@gmail.com
2011-12-01 20:41 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Boszormenyi Zoltan <zb@cybertec.at>
2011-12-01 21:32 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-12-01 21:50 ` Alvaro Herrera <alvherre@commandprompt.com>
2011-12-01 22:04 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-12-01 22:06 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: Alvaro Herrera @ 2011-12-01 21:50 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Boszormenyi Zoltan <zb@cybertec.at>; pgsql-bugs; rep.dot.nop <rep.dot.nop@gmail.com>
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 "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
>
> > 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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
2011-12-01 19:09 BUG #6315: FETCH NEXT :next ROWS ONLY fails rep.dot.nop@gmail.com
2011-12-01 20:41 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Boszormenyi Zoltan <zb@cybertec.at>
2011-12-01 21:32 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Tom Lane <tgl@sss.pgh.pa.us>
2011-12-01 21:50 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Alvaro Herrera <alvherre@commandprompt.com>
@ 2011-12-01 22:04 ` Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Bernhard Reutner-Fischer @ 2011-12-01 22:04 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Boszormenyi Zoltan <zb@cybertec.at>; pgsql-bugs
On 1 December 2011 22:50, Alvaro Herrera <alvherre@commandprompt.com> wrote:
>
> 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 "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
>>
>> > 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)
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails
2011-12-01 19:09 BUG #6315: FETCH NEXT :next ROWS ONLY fails rep.dot.nop@gmail.com
2011-12-01 20:41 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Boszormenyi Zoltan <zb@cybertec.at>
2011-12-01 21:32 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Tom Lane <tgl@sss.pgh.pa.us>
2011-12-01 21:50 ` Re: BUG #6315: FETCH NEXT :next ROWS ONLY fails Alvaro Herrera <alvherre@commandprompt.com>
@ 2011-12-01 22:06 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 6+ messages in thread
From: Tom Lane @ 2011-12-01 22:06 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: Boszormenyi Zoltan <zb@cybertec.at>; pgsql-bugs; rep.dot.nop <rep.dot.nop@gmail.com>
Alvaro Herrera <alvherre@commandprompt.com> 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
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2011-12-01 22:06 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-12-01 19:09 BUG #6315: FETCH NEXT :next ROWS ONLY fails rep.dot.nop@gmail.com
2011-12-01 20:41 ` Boszormenyi Zoltan <zb@cybertec.at>
2011-12-01 21:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-12-01 21:50 ` Alvaro Herrera <alvherre@commandprompt.com>
2011-12-01 22:04 ` Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-12-01 22:06 ` Tom Lane <tgl@sss.pgh.pa.us>
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