ID:               35837
 Comment by:       exaton at free dot fr
 Reported By:      [EMAIL PROTECTED]
 Status:           Assigned
 Bug Type:         PDO related
 Operating System: Windows
 PHP Version:      5CVS-2005-12-29 (snap)
 Assigned To:      wez
 New Comment:

PHP Version 5.1.3RC2-dev 2006-03-19 15:30
WinXP SP2, Apache2 2.0.55

More haywire behaviour when using FETCH_LAZY :

$SQL = new PDO('pgsql:host=localhost;port=5432;dbname=xxxxx', 'user',
'password');

$stmt = $SQL -> query('SELECT ident, descr FROM variables ORDER BY
ident');

$stmt -> setFetchMode(PDO :: FETCH_LAZY);

foreach ($stmt as $row) {
  var_dump($row -> ident); (1) // existing column
  var_dump($row -> foo); (2) // non-existant column
}

$SQL = NULL;

The first (2) is garbage, and so are practically all following (1) and
(2). At the next page load, Apache crashes. Apache crashes every two
page loads in this fashion.

Comment out (1), leaving (2). The first output is NULL, followed by
whole PDORows. Apache no longer crashes.

Add, in appropriate locations :

class MyPDOStatement extends PDOStatement { }

$SQL -> setAttribute(PDO :: ATTR_STATEMENT_CLASS,
array('MyPDOStatement'));

(1) left commented out. The first (2) is bool(true), the following ones
are whole PDORows again. Apache doesn't crash.

Replace those two additions with :

class MyPDOStatement extends PDOStatement {
  private function __construct() { }
}

$SQL -> setAttribute(PDO :: ATTR_STATEMENT_CLASS,
array('MyPDOStatement', array()));

Then the first (2) is :

object(MyPDOStatement)#2 (1) {
  ["queryString"]=>
  string(49) "SELECT ident, descr FROM variables ORDER BY ident"
}

and the following are PDORows again. Apache still no longer crashes.

Have fun >.>


Previous Comments:
------------------------------------------------------------------------

[2005-12-29 13:20:37] [EMAIL PROTECTED]

Assigned to the maintainer.

------------------------------------------------------------------------

[2005-12-29 11:56:36] [EMAIL PROTECTED]

Description:
------------
PHP crashes at the end of the script when I use PDO::FETCH_LAZY.

I've to say that from my testing (for some clever reason I started to
use PDO::FETCH_LAZY right from the start and therefore have gone
through many obscure crashes and exceptions) that I also saw the
following problems with it:
* it seems to consume memory and never releases it. I've got exception
thrown from the Microsoft Access Driver about running out of memory.
When I stopped using PDO::FETCH_LAZY the exception was never thrown
again.
* I got exception thrown about "invalid table ids" for now reasons
which also went away when I stopped using PDO::FETCH_LAZY

I was working with an Access Database (mdb file) but never fetching big
data but it were about 1500 SQL statements sent.

I've read report http://bugs.php.net/bug.php?id=35431 but I can confirm
this for the current snapshot also.

Reproduce code:
---------------
$p = new PDO('odbc:driver={Microsoft Access Driver
(*.mdb)};Dbq=beispieldatenbank.mdb');
$s = $p->query("SELECT COUNT(*) FROM ADDRESSES WHERE GUID = ''",
PDO::FETCH_LAZY);
$s->fetch();


Expected result:
----------------
Script should not crash.

Actual result:
--------------
Script crashes and Windows prompts me with a dialog to send a report to
M$


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35837&edit=1

Reply via email to