Bug #65657 @@sql_select_limit applies to stored procedures
Submitted: 18 Jun 2012 14:18 Modified: 21 Mar 2013 1:19
Reporter: William Chiquito Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.0, 5.1, 5.5 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: sql_select_limit, stored procedures

[18 Jun 2012 14:18] William Chiquito
Description:
MySQL manual says:
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_sql_select_limi...

"sql_select_limit does not apply to SELECT statements executed within stored routines."

This works in stored procedures.

See also Bug #24489.

How to repeat:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mydatabase;
Database changed

mysql> /*Table structure for table `bug_sql_select_limit_table` */

mysql> DROP TABLE IF EXISTS `bug_sql_select_limit_table`;
Query OK, 0 rows affected (0.00 sec)

mysql> create table `bug_sql_select_limit_table` (
    ->   `id` int(10) unsigned not null auto_increment,
    ->   `date` timestamp not null default current_timestamp on update current_timestamp,
    ->   primary key (`id`)
    -> ) engine=innodb;
Query OK, 0 rows affected (0.02 sec)

mysql> /*Data for the table `bug_sql_select_limit_table` */

mysql> insert into `bug_sql_select_limit_table`(`date`)
    -> values
    -> ('2012-06-18 15:49:02'),('2012-06-18 15:49:03'),
    -> ('2012-06-18 15:49:04'),('2012-06-18 15:49:05'),
    -> ('2012-06-18 15:49:06'),('2012-06-18 15:49:07'),
    -> ('2012-06-18 15:49:08'),('2012-06-18 15:49:09');
Query OK, 8 rows affected (0.01 sec)
Records: 8  Duplicates: 0  Warnings: 0

mysql> /* procedure structure for procedure `bug_sql_select_limit_procedure` */

mysql> /*!50003 drop procedure if exists  `bug_sql_select_limit_procedure` */;
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter $$

mysql> /*!50003 create procedure `bug_sql_select_limit_procedure`(`p_limit` int)
    -> begin
    -> if not (`p_limit` < 0) then
    ->  set @@session.sql_select_limit := `p_limit`;
    -> end if;
    -> select `id`, `date` from `bug_sql_select_limit_table`;
    -> end */$$
Query OK, 0 rows affected (0.00 sec)

mysql> delimiter ;

mysql> call `bug_sql_select_limit_procedure`(2);
+----+---------------------+
| id | date                |
+----+---------------------+
|  1 | 2012-06-18 15:49:02 |
|  2 | 2012-06-18 15:49:03 |
+----+---------------------+
2 rows in set (0.00 sec)

Query OK, 0 rows affected (0.01 sec)
[18 Jun 2012 14:50] Valeriy Kravchuk
Thank you for the problem report.
[21 Mar 2013 1:19] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Removed the paragraph stating that sql_select_limit does not apply in stored programs.