Bug #56811 Allow user variables in LIMIT clause.
Submitted: 16 Sep 2010 6:02 Modified: 16 Sep 2010 7:13
Reporter: Konstantin Osipov (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Parser Severity:S4 (Feature request)
Version:Any OS:Any
Assigned to: CPU Architecture:Any

[16 Sep 2010 6:02] Konstantin Osipov
Description:
MySQL still doesn't allow user variables in LIMIT clause.
The fix for Bug#11918 only allows stored procedure variables.
See how-to repeat.

How to repeat:
drop table if exists t1;
create table t1 (a int);
set @var=1;
select * from t1 limit @var;

Suggested fix:
Allow user variables in LIMIT clause. If the variable is STRING or DOUBLE or NULL, or negative integer, produce an error.
[14 May 2012 18:04] Trey Raymond
Like the last bug, this one is just sitting with no updates...Will we see this fix in an upcoming 5.5 build?  For SP-based applications, or even just apps that use variables statement to statement in a transaction, it's a pretty big limitation.