ID:               40121
 Comment by:       eric dot johney at sellingsource dot com
 Reported By:      [EMAIL PROTECTED]
 Status:           Assigned
 Bug Type:         PDO related
 Operating System: Mac OS X 10.4.8
 PHP Version:      5.2.1RC2
 Assigned To:      fmk
 New Comment:

This is still a problem for me in 5.2.5 using the PDO DBLIB driver.
Mysql and mssql_* functions work fine on the same query.


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

[2007-01-15 12:11:15] [EMAIL PROTECTED]

And more issues :-)

That previous example was done with just one row in the 
resultset, but after I tried to return more rows, I found 
something disturbing:

Code:

$db = new PDO('dblib:host=hostname;dbname=database', 
'username', 'password');
$query = 'select top 10 * from table';
$stmt = $db->prepare($query);

for ($i = 0; $i < 10; $i++) {
    $stmt->execute();
    $stmt->fetchAll();
    $stmt->closeCursor();

    echo memory_get_usage() . "\n";
}

Output:

172240
240044
307824
375632
443464
511288
579064
646932
714776
782576

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

[2007-01-15 07:07:21] [EMAIL PROTECTED]

After playing around with GDB I noticed that the S->cols is 
being allocated on different memory block each time. S and S-
>rows stay in the same place, though. I suppose this is due 
the different methods used to allocate memory, but I just 
don't have enough clue to fix it.

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

[2007-01-14 21:50:40] [EMAIL PROTECTED]

I couldn't get it to compile, so I corrected the mysql -> 
dblib, not sure whether this was the intention though. I 
don't have enough karma, so the patch is below:

RCS file: /repository/php-src/ext/pdo_dblib/dblib_stmt.c,v
retrieving revision 1.6.2.2.2.3
diff -u -r1.6.2.2.2.3 dblib_stmt.c
--- dblib_stmt.c        14 Jan 2007 16:57:50 -0000      
1.6.2.2.2.3
+++ dblib_stmt.c        14 Jan 2007 21:43:35 -0000
@@ -250,9 +250,9 @@
        return 1;
 }
 
-static int dblib_mysql_stmt_cursor_closer(pdo_stmt_t *stmt 
TSRMLS_DC)
+static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt 
TSRMLS_DC)
 {
-       pdo_dblib_stmt *S = (pdo_mysql_stmt*)stmt-
>driver_data;
+       pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt-
>driver_data;
 
        if (S->rows) {
                free_rows(S TSRMLS_CC);
@@ -273,6 +273,6 @@
        NULL, /* get attr */
        NULL, /* meta */
        NULL, /* nextrow */
-       dblib_mysql_stmt_cursor_closer
+       pdo_dblib_stmt_cursor_closer
 };


However, it doesn't fix the problem. See, gdb breaks fine on 
pdo_dblib_stmt_dtor on each iteration and stepping it shows 
that it even attempts to free stuff. So I guess the error 
isn't here?

After running gdb with patch above it does close the cursor 
on each iteration, but it's not still affecting the 
increasing memory usage.

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

[2007-01-14 16:57:56] [EMAIL PROTECTED]

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.



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

[2007-01-13 18:23:10] [EMAIL PROTECTED]

Forgot to mention that it works perfectly with MySQL driver.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/40121

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

Reply via email to