Bug #8632 SQL_CALC_FOUND_ROWS and DUAL
Submitted: 20 Feb 2005 13:11 Modified: 1 Mar 2005 21:45
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:4.1.10 OS:
Assigned to: Assigned Account CPU Architecture:Any

[20 Feb 2005 13:11] Martin Friebe
Description:
SQL_CALC_FOUND_ROWS used in a non table select, always returns 0, even so one result line has been returned, by the query itself.

Not really needing this, but it should either work, or if its not supposed to work, it should return an error.

How to repeat:
select SQL_CALC_FOUND_ROWS 1 from  DUAL; select found_rows();
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
+--------------+
| found_rows() |
+--------------+
|            0 |
+--------------+
1 row in set (0.00 sec)

select SQL_CALC_FOUND_ROWS 1 from  DUAL limit 1; select found_rows();
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
+--------------+
| found_rows() |
+--------------+
|            0 |
+--------------+
1 row in set (0.23 sec)

select SQL_CALC_FOUND_ROWS 1 ; select found_rows();
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
+--------------+
| found_rows() |
+--------------+
|            0 |
+--------------+
1 row in set (0.01 sec)

Suggested fix:
Either have found_rows return 1
or
reject the original query with an error and document
[1 Mar 2005 21:45] Timour Katchaounov
This bug is duplicate of BUG#6089, which was already fixed in exactly the same way
as the cset above.