Bug #4538 Stored procedure doesn't support found_rows()
Submitted: 13 Jul 2004 16:10 Modified: 28 Sep 2004 8:18
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.1-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Bugs System CPU Architecture:Any

[13 Jul 2004 16:10] Peter Gulutzan
Description:
If "SELECT SQL_CALC_FOUND_ROWS ..." and "SELECT FOUND_ROWS() ..." are in a 
stored procedure, the result is usually 0. If the same statements are outside a stored 
procedure, the result is 1. 
 
 

How to repeat:
mysql> create table t (s1 int); 
Query OK, 0 rows affected (0.27 sec) 
 
mysql> insert into t values (1); 
Query OK, 1 row affected (0.00 sec) 
 
mysql> select sql_calc_found_rows * from t; 
+------+ 
| s1   | 
+------+ 
|    1 | 
+------+ 
1 row in set (0.00 sec) 
 
mysql> select found_rows(); 
+--------------+ 
| found_rows() | 
+--------------+ 
|            1 | 
+--------------+ 
1 row in set (0.00 sec) 
 
mysql> delimiter // 
 
mysql> create procedure p () begin select sql_calc_found_rows * from t; select 
found_rows(); end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p()// 
+------+ 
| s1   | 
+------+ 
|    1 | 
+------+ 
1 row in set (0.01 sec) 
 
+--------------+ 
| found_rows() | 
+--------------+ 
|            0 | 
+--------------+ 
1 row in set (0.01 sec) 
 
Query OK, 0 rows affected (0.01 sec)
[28 Sep 2004 8:18] Per-Erik Martin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

No longer repeatable.