Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Bug #7790 PEAR_Error when using Iterator and unbuffered results
Submitted: 2006-06-02 05:24 UTC
From: stoyan Assigned: lsmith
Status: Closed Package: MDB2 (version 2.0.3)
PHP Version: 5.0.5 OS: Windows
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 35 - 33 = ?

 
 [2006-06-02 05:24 UTC] stoyan (Stoyan)
Description: ------------ I got a PEAR error when using the iterator with unbuffered query. It worked OK, but then there was probably an attempt to free the result set, so I got the error at the end of an iteration loop. Test script: --------------- MDB2::loadFile('Iterator'); $query = 'SELECT * FROM people'; $mdb2->setOption('result_buffering', false); $result = $mdb2->query($query, null, true, 'MDB2_Iterator'); foreach ($result as $row) { var_dump($row); } Actual result: -------------- array(2) { ["id"]=> string(1) "1" ["name"]=> string(5) "Eddie" } array(2) { ["id"]=> string(1) "2" ["name"]=> string(4) "Mike" } MDB2 Error: Array: free: Could not free result[Native code: ] [Native message: ]

Comments

 [2006-06-03 07:06 UTC] lsmith (Lukas Smith)
I was not able to reproduce this issue using CVS along with the mysql driver. What driver are you using? What RDBMS version?
 [2006-06-03 14:14 UTC] stoyan
MySQL 5.0.15 MDB2 2.0.3. MDB2_Driver_mysql 1.0.3
 [2006-06-05 07:40 UTC] lsmith (Lukas Smith)
Ok, I tried again using the same version of PHP5, MDB2 and MDB2_Driver_mysql along with mysql 5.0.16. Running the script you have provided I cannot reproduce your issues. Could you maybe also provide how you make the $mdb2 instance along with all other non default options?
 [2006-06-13 20:36 UTC] stoyan
I tried again on a slightly different setup: PHP 5.1.4. MySQL 5.0.21 Same MDB 2.0.3. with MySQL driver 1.0.3. Got the same error. Here's the complete script using the pear error handler from the MDB2 examples. -- <?php error_reporting(E_ALL); require_once 'MDB2.php'; function handle_pear_error ($error_obj) { print '<pre><b>PEAR-Error</b><br />'; echo $error_obj->getMessage().': '.$error_obj->getUserinfo(); print '</pre>'; } PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error'); $dsn = 'mysql://root@localhost/mdb2test'; $mdb2 =& MDB2::factory($dsn); MDB2::loadFile('Iterator'); $query = 'SELECT * FROM people'; $mdb2->setOption('result_buffering', false); $result = $mdb2->query($query, null, true, 'MDB2_Iterator'); foreach ($result as $row) { var_dump($row); } echo phpversion(); ?> -- The result is: == 5.1.4 PEAR-ErrorMDB2 Error: Array: free: Could not free result[Native code: ] [Native message: ] == So the error message is after my call to phpversion(), which probably leads to MDB2_Iterator's destructor where there is a call to free(). Do you think this has something to do with the fact that I used an unbuffered query? I mean is it ok to free a result from an unbuffered query, since nothing is stored?
 [2006-06-13 21:03 UTC] lsmith (Lukas Smith)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.