#35103 [Fbk->Opn]: mysqli bind_result incorrectly handles unsigned int
| From: | php at pjberkel dot com | Date: | Fri, 04 Nov 2005 11:46:31 +0000 |
| Subject: | #35103 [Fbk->Opn]: mysqli bind_result incorrectly handles unsigned int | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-87566@lists.php.net to get a copy of this message | ||
ID: 35103
User updated by: php at pjberkel dot com
Reported By: php at pjberkel dot com
-Status: Feedback
+Status: Open
Bug Type: MySQLi related
Operating System: RHEL 4
PHP Version: 5.0.5
New Comment:
Compiling the current php5 STABLE CVS snapshot version under RHEL 4
yields the same incorrect results as before: using "var_dump" instead
of "print" in the original example gives the results:
int(2147483647)
int(-2147483648)
int(-2147483647)
int(-494965764)
int(-394965015)
int(-1)
Previous Comments:
------------------------------------------------------------------------
[2005-11-04 11:25:03] derick@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
------------------------------------------------------------------------
[2005-11-04 11:17:12] php at pjberkel dot com
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 this bug report at http://bugs.php.net/?id=35103&edit=1