From:             phpbug at elitecoders dot com
Operating system: OS X
PHP version:      5.0.4
PHP Bug Type:     MySQL related
Bug description:  SQL_CALC_FOUND_ROWS and mysql.trace_mode=true always returns 1

Description:
------------
When the php.ini "mysql.trace_mode" option is set to true,
and you do a mysql_query with SQL_CALC_FOUND_ROWS,
the result of a SELECT FOUND_ROWS() will always be 1, no matter how many
rows would have been returned (disregarding any LIMIT clause.)

changing mysql.trace_mode to false will make it return the correct number.

Reproduce code:
---------------
ini_set('mysql.trace_mode', true);

$result_id = mysql_query('SELECT SQL_CALC_FOUND_ROWS column FROM t LIMIT
5');

$rows = array();
while($row = mysql_fetch_assoc($result_id)) {
    $rows[] = $row;
}

$result_id = mysql_query('SELECT FOUND_ROWS()');

list($row_total) = mysql_fetch_row($result_id);

Expected result:
----------------
$row_total will be the number of rows returned if there were no LIMIT
clause.

Actual result:
--------------
$row_total is 1, regardless of the actual found rows.

-- 
Edit bug report at http://bugs.php.net/?id=33021&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33021&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33021&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33021&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33021&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33021&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33021&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33021&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33021&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33021&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33021&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33021&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33021&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33021&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33021&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33021&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33021&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33021&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33021&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33021&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33021&r=mysqlcfg

Reply via email to