#35517 [Asn]: mysqli_stmt_fetch() incorrectly returning NULL
ID: 35517
User updated by: php at pjberkel dot com
Reported By: php at pjberkel dot com
Status: Assigned
Bug Type: MySQLi related
Operating System: RHEL 4
PHP Version: 5CVS-2005-12-02 (snap)
Assigned To: ahristov
New Comment:
Just wondering if there has been any progress on fixing this problem?
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2005-12-02 11:07:18] tony2001@php.net
Andrey, take a look at it.
It happens because mysql_stmt_fetch() returns MYSQL_DATA_TRUNCATED.
Dunno if we should return an error in such case or if it's ok to ignore
it.
------------------------------------------------------------------------
[2005-12-02 10:35:40] php at pjberkel dot com
Description:
------------
This bug report is a follow-up to a previous bug:
http://bugs.php.net/bug.php?id=35103
I tested the original reproduce code using the lastest stable snapshot
available (php5.1-200512020130) and there appears to be another bug (or
feature) introduced as a result of the fix to bug #35103.
It appears as though $stmt->fetch() is returning NULL despite the fact
that the result has been correcly bound to the variable (and this only
seems to occur when the data is an unsigned int >= MAX_SIGNED_INT (as
in bug #35103). I notice in the manual page that mysqli_stmt_fetch()
returns NULL when "No more rows/data exists or data truncation
occurred" so it would appear this is a bug.
Can anybody confirm? (I'm using php5.1-200512020130 + mysql-5.0.16 on
RHEL 4).
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
(3000000897),(3800001532),(3900002281),(3100059612)");
/* BEGIN EXAMPLE OF BUG */
$stmt = $mysqli->prepare("SELECT id FROM temp");
$stmt->execute();
$stmt->bind_result($id);
while ($stmt->fetch()) {
var_dump($id);
}
$stmt->close();
/* END EXAMPLE OF BUG */
$mysqli->query("DROP TABLE temp");
$mysqli->close();
?>
Expected result:
----------------
string(10) "3000000897"
string(10) "3800001532"
string(10) "3900002281"
string(10) "3100059612"
Actual result:
--------------
[no output, while loop terminates immediately because $stmt->fetch()
returns NULL]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35517&edit=1
Thread (6 messages)