|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35517 mysqli_stmt_fetch() incorrectly returning NULL
Submitted: 2005-12-02 10:35 UTC Modified: 2005-12-29 10:49 UTC
From: php at pjberkel dot com Assigned: georg (profile)
Status: Closed Package: MySQLi related
PHP Version: 5CVS-2005-12-02 (snap) OS: RHEL 4
Private report: No CVE-ID: None
 [2005-12-02 10:35 UTC] php at pjberkel dot com
This bug report is a follow-up to a previous bug:

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:

$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)");

$stmt = $mysqli->prepare("SELECT id FROM temp");
while ($stmt->fetch()) {

$mysqli->query("DROP TABLE temp");


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]


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-02 11:07 UTC]
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-29 10:49 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 20:01:39 2024 UTC