Re: Negative LIMIT and OFFSET?

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: Gregory Stark <stark@enterprisedb.com>, Simon Riggs <simon@2ndquadrant.com>, pgsql-hackers@postgresql.org
Date: 2007-12-17T04:54:51Z
Lists: pgsql-hackers
Bruce Momjian <bruce@momjian.us> writes:
> Since we got LIMIT/OFFSET from MySQL, would someone tell us how MySQL
> behaves in these cases?

Not very well, at least not in mysql 5.0.45:

mysql> select * from t limit -2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2' at line 1
mysql> select * from t limit 2 offset -2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2' at line 1

This behavior suggests that they can't even deal with LIMIT/OFFSET
values that aren't simple integer literals ...

			regards, tom lane