Edit report at http://bugs.php.net/bug.php?id=50755&edit=1
ID: 50755 User updated by: ssufficool at gmail dot com Reported by: ssufficool at gmail dot com Summary: PDO DBLIB Fails with OOM Status: Open Type: Bug Package: PDO related Operating System: Linux 2.6.30-gentoo-r2 -PHP Version: 5.3.1 +PHP Version: 5.2 / 5.3 / 6 New Comment: Affects all versions of PHP, patches attached. Previous Comments: ------------------------------------------------------------------------ [2010-01-20 20:50:56] ssufficool at gmail dot com Patch sent to w...@php.net waiting response ------------------------------------------------------------------------ [2010-01-15 00:21:48] ssufficool at gmail dot com I have a patch that removes client side buffering and allows for large rowset queries without memory consumption. Compiled and tested http://svn.php.net/repository/php/php-src/branches/PHP_5_2 SVN Revision: 293557 I can send patch via e-mail. ------------------------------------------------------------------------ [2010-01-14 19:09:48] ssufficool at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=50755&edit=1