php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at pjberkel dot com
New email:
PHP Version: OS:

 

 [2005-12-02 10:35 UTC] 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]


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-02 11:07 UTC] 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-29 10:49 UTC] georg@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC