Bug #6184 FOUND_ROWS() returns the wrong value when GROUP BY and HAVING clauses are used
Submitted: 20 Oct 2004 20:49 Modified: 21 Oct 2004 13:58
Reporter: Matt Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.20 OS:Linux (Gentoo Linux 2.6.8)
Assigned to: MySQL Verification Team CPU Architecture:Any

[20 Oct 2004 20:49] Matt
Description:
FOUND_ROWS() returns a value that is 1 greater than it should be when SQL_CALC_FOUND_ROWS is used with a query that also has GROUP BY and HAVING clauses.

How to repeat:
SELECT SQL_CALC_FOUND_ROWS id FROM foo GROUP BY id HAVING id < 10;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
|  4 |
|  5 |
|  6 |
|  7 |
|  8 |
|  9 |
+----+
9 rows in set (0.01 sec)

SELECT FOUND_ROWS();
+--------------+
| FOUND_ROWS() |
+--------------+
|           10 |
+--------------+
1 row in set (0.00 sec)
[21 Oct 2004 11:05] MySQL Verification Team
Hi,

Thank you for the report, but I wasn't able to repeat it with 4.0.22-debug-log.
[21 Oct 2004 14:19] Matt
Upgrading to version 4.0.21 fixed the problem... looks like it's just a problem in 4.0.20.