Bug #63399 Some SHOW commands do not set FOUND_ROWS correctly
Submitted: 23 Nov 2011 9:27 Modified: 2 Dec 2011 23:37
Reporter: Hartmut Holzgraefe Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Information schema Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[23 Nov 2011 9:27] Hartmut Holzgraefe
Description:
E.g. after SHOW VARIABLES a SELECT FOUND_ROWS() returns the correct result while after SHOW SLAVE STATUS 1 found row is reported no matter whether SHOW SLAVE STATUS returned actual data or empty set 

Also SHOW AUTHORS always reports one for found_rows() although there are more than 70 actual result rows.

How to repeat:
SHOW VARIABLES;
SELECT FOUND_ROWS();
SHOW SLAVE STATUS; -- on a machine not configured as slave so that "Empty Set" is returned
SELECT FOUND_ROWS();

results:

> show variables;
[...]
322 rows in set (0.00 sec)

MySQL [test]> select found_rows();
> select found_rows();
+--------------+
| found_rows() |
+--------------+
|          322 |
+--------------+
1 row in set (0.00 sec)

> show slave status;
Empty set (0.00 sec)

> select found_rows();
+--------------+
| found_rows() |
+--------------+
|            1 |
+--------------+
1 row in set (0.00 sec)

Suggested fix:
Correctly report FOUND_ROWS() for all SHOW results
[23 Nov 2011 9:27] Hartmut Holzgraefe
Backgroud: i'm trying to determine whether a mysql server is configured as slave in init_file, if SHOW SLAVE STATUS would set FOUND_ROWS() correctly i could simply check for 1 or 0 there, now i'm falling back to checking for the existence of the master.info file using LOAD DATA INFILE

Checking the actual SHOW results using a stored procedure and cursor is not an option as for a cursor FETCH i need to know the exact column count which may change between releases though ...
[23 Nov 2011 9:43] Valeriy Kravchuk
Thank you for the bug report. Verified on Mac OS X:

mysql> show slave status;
Empty set (0.00 sec)

mysql> select found_rows();
+--------------+
| found_rows() |
+--------------+
|            1 |
+--------------+
1 row in set (0.00 sec)

mysql> select version();   
+--------------+
| version()    |
+--------------+
| 5.5.17-debug |
+--------------+
1 row in set (0.00 sec)
[2 Dec 2011 23:37] Hartmut Holzgraefe
Probably also somehow related: bug #63399