From: ssufficool at gmail dot com Operating system: Linux 2.6.30-gentoo-r2 PHP version: 5.3.1 PHP Bug Type: PDO related Bug description: PDO DBLIB Fails with OOM
Description: ------------ When querying large tables (> 800,000 rows) with PDO DBLIB I get out of memory. The same select query works fine using: linux# tsql -H host -U user -P pass SELECT * from aVeryLargeTable go quit on the command line using the freetds (dblib) library without consuming client-side memory. Reproduce code: --------------- $pdo = new PDO('dblib:host=host','user','pass'); echo "Creating table...\n"; $pdo->query("CREATE TABLE large_table (field_1 nvarchar(4000))"); $pdo->query("DECLARE @n int; set @n = 0; WHILE (@n < 50000) BEGIN insert into large_table values( replicate(4000,'-') ); set @n = @n + 1; END"); echo "Prepare\n"; $rs = $pdo->prepare("SELECT * FROM large_table"); echo "Execute\n"; /*********OOM HERE**************/ $rs->execute( ); Expected result: ---------------- A valid handle to a resultset in $rs Actual result: -------------- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 48 bytes) in /home/ssufficool/tds_test.php on line 12 It looks like the guts of ext/pdo_dblib/dblib_stmt.c:pdo_dblib_stmt_execute() at "/* let's fetch all the data */" Should be moved to: pdo_dblib_stmt_fetch() and only when a scrollable cursor is requested should the data be buffered at the client (not required for ct-lib) -- Edit bug report at http://bugs.php.net/?id=50755&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50755&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50755&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50755&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50755&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50755&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50755&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50755&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50755&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50755&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50755&r=support Expected behavior: http://bugs.php.net/fix.php?id=50755&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50755&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50755&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50755&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50755&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50755&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50755&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50755&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50755&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50755&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50755&r=mysqlcfg