From: php at pjberkel dot com Operating system: RHEL 4 PHP version: 5.0.5 PHP Bug Type: MySQLi related Bug description: mysqli bind_result incorrectly handles unsigned int
Description: ------------ When using "mysqli_stmt_bind_result" to retrieve a 32bit unsigned integer value from a mysql database (version 4.1.13-standard) that is greater than the maximum *signed* value but less than the maximum *unsigned* value (i.e. 2147483647 < int <= 4294967295), the integer is returned incorrectly as a signed value. I did read in the manual that php does not support unsigned integers (http://www.php.net/manual/en/language.types.integer.php), however in this case, mysqli_stmt_bind_result should probably cast the result to a float. Reproduce code: --------------- <?php $mysqli = new mysqli("host", "user", "pass", "db"); $mysqli->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)"); $mysqli->query("INSERT INTO temp (id) VALUES (2147483647),(2147483648),(2147483649),(3800001532),(3900002281),(4294967295)"); /* BEGIN EXAMPLE OF BUG */ $stmt = $mysqli->prepare("SELECT id FROM temp"); $stmt->execute(); $stmt->bind_result($id); while ($stmt->fetch()) { print $id . "<br>\n"; } $stmt->close(); /* END EXAMPLE OF BUG */ $mysqli->query("DROP TABLE temp"); $mysqli->close(); ?> Expected result: ---------------- 2147483647 2147483648 2147483649 3800001532 3900002281 4294967295 Actual result: -------------- 2147483647 -2147483648 -2147483647 -494965764 -394965015 -1 -- Edit bug report at http://bugs.php.net/?id=35103&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35103&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35103&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35103&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=35103&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35103&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35103&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35103&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35103&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35103&r=support Expected behavior: http://bugs.php.net/fix.php?id=35103&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35103&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35103&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35103&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35103&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35103&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35103&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35103&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35103&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35103&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35103&r=mysqlcfg
