Bug #42765 [Com]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)

2011-08-30 Thread andreas at codejungle dot org
Edit report at https://bugs.php.net/bug.php?id=42765&edit=1

 ID: 42765
 Comment by: andreas at codejungle dot org
 Reported by:sms at inbox dot ru
 Summary:PDO ODBC: Long binary field in query result crashes
 PHP ("Out of memory" error)
 Status: Open
 Type:   Bug
 Package:PDO related
 Operating System:   Windows 2000 SP4
 PHP Version:5.2.4
 Block user comment: N
 Private report: N

 New Comment:

Bug is still existing in PHP 5.3.5 (os ubuntu natty)

The chunk workaround from skettler is working, but 22 000 queries for a 40 MB 
file is not optimal.

I tried also the php-ds-odbc_blob.patch, and the "Out of memory" error was gone,
but for some reasons, now the files are twice as large :(


Previous Comments:

[2010-06-20 17:43:42] paj...@php.net

hm, I don't maintain odbc.

However I would suggest SqlServer users on Windows to use SqlSrv instead, much 
more stable and features complete.


[2009-04-29 10:44:33] skett...@php.net

Confirmed not fixed with latest PHP 5.2 snapshot VC6 x86 Thread Safe 
(2009-Apr-27 00:00:00):

Fatal error: Out of memory (allocated 262144) (tried to allocate 4294967295 
bytes)

Current workaround is getting the length of the image, retrieving chunks of 
4096 characters and putting them back together in PHP.

SQL-Queries for this workaround look like these:

SELECT DATALENGTH(imagefield) AS imagelength FROM imagetable WHERE imageid 
= ?

SELECT CAST(SUBSTRING(imagefield, offset, length) AS VARCHAR(4096)) AS 
imagechunk FROM imagetable WHERE imageid = ?



[2009-04-25 14:50:26] j...@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




[2008-10-03 21:41:35] paj...@php.net

Thanks for the patches and testing.

About compiling php on windows, take a look here:

http://wiki.php.net/internals/windows


[2008-10-03 15:34:14] jeffreybolle at gmail dot com

I had the same problem recently. I'd like to thank csa for the great source 
code patch.  Recompiling the source under windows wasn't easy and it took me 
many hours to piece together all the software and libraries required.  The 
result was a fixed extension that can access large blob files, this has been 
tested under Windows Vista 32bit.
I thought I'd post a link for the compiled extension (PHP 5.2.6) in case any 
other windows users want to make use of this fix without going through the 
hassle of learning how to compile PHP from source.

http://s3.paramorphicdesigns.com/random/php/php_pdo_odbc.dll

If there are any problems feel free to contact me at jeffreybo...@gmail.com

Jeffrey




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

https://bugs.php.net/bug.php?id=42765


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


#42765 [Com]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)

2008-10-03 Thread jeffreybolle at gmail dot com
 ID:   42765
 Comment by:   jeffreybolle at gmail dot com
 Reported By:  sms at inbox dot ru
 Status:   Open
 Bug Type: PDO related
 Operating System: Windows 2000 SP4
 PHP Version:  5.2.4
 New Comment:

I had the same problem recently. I'd like to thank csa for the great
source code patch.  Recompiling the source under windows wasn't easy and
it took me many hours to piece together all the software and libraries
required.  The result was a fixed extension that can access large blob
files, this has been tested under Windows Vista 32bit.
I thought I'd post a link for the compiled extension (PHP 5.2.6) in
case any other windows users want to make use of this fix without going
through the hassle of learning how to compile PHP from source.

http://s3.paramorphicdesigns.com/random/php/php_pdo_odbc.dll

If there are any problems feel free to contact me at
[EMAIL PROTECTED]

Jeffrey


Previous Comments:


[2008-06-10 09:08:40] csa at dside dot dyndns dot org

By the way feel free to contact me on [EMAIL PROTECTED] if you have
problems with this patches.



[2008-06-10 09:06:02] csa at dside dot dyndns dot org

I got the same problem on Linux (64bit, php 5.2.6). Actually, the
problem is existing in all configurations. I have take a brief look
through php sources. The bug is in pdo_odbc code and affects all
architectures and underlying database engines.

Actually it is in 'ext/pdo_odbc/odbc_stmt.c', function
'odbc_stmt_describe'. The 'displaysize' variable is expected to contain 
estimated size of the column. This could be a negative number if BLOB or
TEXT data is stored (since the record sizes could seriously vary).
However, later in this function the check on data size does not consider
negative numbers. This causes the described behavior. This patch solves
problem for me:

http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_blob.patch

A Linux user trying to access MSSQL over FreeTDS may be interested in
the following patches as well: 
http://dside.dyndns.org/projects/patches.dir/freetds-ds-odbc.patch
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch



[2007-09-27 18:07:29] carlton dot whitehead at cebesius dot com

I encountered this bug with this setup:
Windows Server 2003 SP2 32bit
IIS 6
PHP 5.2.4
MS SQL Server 2005 Express SP2

PDO ODBC reproduce code:
---
prepare($stp);
$execResult = $ps->execute();
var_export($execResult, true);
}
catch (PDOException $e)
{
die($e->getMessage());
}
?>

Expected result:

output to browser: true

Actual result:
--
*Fatal error*: Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in *C:\Inetpub\wwwroot\FMarchive\lobtestPdoOdbc.php*
on line *9*


plain ODBC reproduce code:
--


Expected result:

output to browser: true

Actual result:
--
output to browser: true
(this indicates odbc_execute worked correctly)



[2007-09-26 11:00:15] sms at inbox dot ru

Description:

With PDO ODBC I can't get long binary data from Microsoft SQL Server
(image and varbinary(MAX) fields). PDO->query, PDOStatement->execute()
always result in PHP "Out of memory" error, even if output contains no
rows.
The same queries work fine with ODBC unified extension.


Reproduce code:
---
query("select [nbin] from [atts] where [id]=1");
?>

Expected result:

No PHP fatal errors

Actual result:
--
PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in D:\Web\test.php on line 3





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



#42765 [Com]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)

2008-06-10 Thread csa at dside dot dyndns dot org
 ID:   42765
 Comment by:   csa at dside dot dyndns dot org
 Reported By:  sms at inbox dot ru
 Status:   Open
 Bug Type: PDO related
 Operating System: Windows 2000 SP4
 PHP Version:  5.2.4
 New Comment:

By the way feel free to contact me on [EMAIL PROTECTED] if you have
problems with this patches.


Previous Comments:


[2008-06-10 09:06:02] csa at dside dot dyndns dot org

I got the same problem on Linux (64bit, php 5.2.6). Actually, the
problem is existing in all configurations. I have take a brief look
through php sources. The bug is in pdo_odbc code and affects all
architectures and underlying database engines.

Actually it is in 'ext/pdo_odbc/odbc_stmt.c', function
'odbc_stmt_describe'. The 'displaysize' variable is expected to contain 
estimated size of the column. This could be a negative number if BLOB or
TEXT data is stored (since the record sizes could seriously vary).
However, later in this function the check on data size does not consider
negative numbers. This causes the described behavior. This patch solves
problem for me:

http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_blob.patch

A Linux user trying to access MSSQL over FreeTDS may be interested in
the following patches as well: 
http://dside.dyndns.org/projects/patches.dir/freetds-ds-odbc.patch
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch



[2007-09-27 18:07:29] carlton dot whitehead at cebesius dot com

I encountered this bug with this setup:
Windows Server 2003 SP2 32bit
IIS 6
PHP 5.2.4
MS SQL Server 2005 Express SP2

PDO ODBC reproduce code:
---
prepare($stp);
$execResult = $ps->execute();
var_export($execResult, true);
}
catch (PDOException $e)
{
die($e->getMessage());
}
?>

Expected result:

output to browser: true

Actual result:
--
*Fatal error*: Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in *C:\Inetpub\wwwroot\FMarchive\lobtestPdoOdbc.php*
on line *9*


plain ODBC reproduce code:
--


Expected result:

output to browser: true

Actual result:
--
output to browser: true
(this indicates odbc_execute worked correctly)



[2007-09-26 11:00:15] sms at inbox dot ru

Description:

With PDO ODBC I can't get long binary data from Microsoft SQL Server
(image and varbinary(MAX) fields). PDO->query, PDOStatement->execute()
always result in PHP "Out of memory" error, even if output contains no
rows.
The same queries work fine with ODBC unified extension.


Reproduce code:
---
query("select [nbin] from [atts] where [id]=1");
?>

Expected result:

No PHP fatal errors

Actual result:
--
PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in D:\Web\test.php on line 3





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



#42765 [Com]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)

2008-06-10 Thread csa at dside dot dyndns dot org
 ID:   42765
 Comment by:   csa at dside dot dyndns dot org
 Reported By:  sms at inbox dot ru
 Status:   Open
 Bug Type: PDO related
 Operating System: Windows 2000 SP4
 PHP Version:  5.2.4
 New Comment:

I got the same problem on Linux (64bit, php 5.2.6). Actually, the
problem is existing in all configurations. I have take a brief look
through php sources. The bug is in pdo_odbc code and affects all
architectures and underlying database engines.

Actually it is in 'ext/pdo_odbc/odbc_stmt.c', function
'odbc_stmt_describe'. The 'displaysize' variable is expected to contain 
estimated size of the column. This could be a negative number if BLOB or
TEXT data is stored (since the record sizes could seriously vary).
However, later in this function the check on data size does not consider
negative numbers. This causes the described behavior. This patch solves
problem for me:

http://dside.dyndns.org/projects/patches.dir/php-ds-odbc_blob.patch

A Linux user trying to access MSSQL over FreeTDS may be interested in
the following patches as well: 
http://dside.dyndns.org/projects/patches.dir/freetds-ds-odbc.patch
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch


Previous Comments:


[2007-09-27 18:07:29] carlton dot whitehead at cebesius dot com

I encountered this bug with this setup:
Windows Server 2003 SP2 32bit
IIS 6
PHP 5.2.4
MS SQL Server 2005 Express SP2

PDO ODBC reproduce code:
---
prepare($stp);
$execResult = $ps->execute();
var_export($execResult, true);
}
catch (PDOException $e)
{
die($e->getMessage());
}
?>

Expected result:

output to browser: true

Actual result:
--
*Fatal error*: Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in *C:\Inetpub\wwwroot\FMarchive\lobtestPdoOdbc.php*
on line *9*


plain ODBC reproduce code:
--


Expected result:

output to browser: true

Actual result:
--
output to browser: true
(this indicates odbc_execute worked correctly)



[2007-09-26 11:00:15] sms at inbox dot ru

Description:

With PDO ODBC I can't get long binary data from Microsoft SQL Server
(image and varbinary(MAX) fields). PDO->query, PDOStatement->execute()
always result in PHP "Out of memory" error, even if output contains no
rows.
The same queries work fine with ODBC unified extension.


Reproduce code:
---
query("select [nbin] from [atts] where [id]=1");
?>

Expected result:

No PHP fatal errors

Actual result:
--
PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in D:\Web\test.php on line 3





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



#42765 [Com]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)

2007-09-27 Thread carlton dot whitehead at cebesius dot com
 ID:   42765
 Comment by:   carlton dot whitehead at cebesius dot com
 Reported By:  sms at inbox dot ru
 Status:   Open
 Bug Type: PDO related
 Operating System: Windows 2000 SP4
 PHP Version:  5.2.4
 New Comment:

I encountered this bug with this setup:
Windows Server 2003 SP2 32bit
IIS 6
PHP 5.2.4
MS SQL Server 2005 Express SP2

PDO ODBC reproduce code:
---
prepare($stp);
$execResult = $ps->execute();
var_export($execResult, true);
}
catch (PDOException $e)
{
die($e->getMessage());
}
?>

Expected result:

output to browser: true

Actual result:
--
*Fatal error*: Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in *C:\Inetpub\wwwroot\FMarchive\lobtestPdoOdbc.php*
on line *9*


plain ODBC reproduce code:
--


Expected result:

output to browser: true

Actual result:
--
output to browser: true
(this indicates odbc_execute worked correctly)


Previous Comments:


[2007-09-26 11:00:15] sms at inbox dot ru

Description:

With PDO ODBC I can't get long binary data from Microsoft SQL Server
(image and varbinary(MAX) fields). PDO->query, PDOStatement->execute()
always result in PHP "Out of memory" error, even if output contains no
rows.
The same queries work fine with ODBC unified extension.


Reproduce code:
---
query("select [nbin] from [atts] where [id]=1");
?>

Expected result:

No PHP fatal errors

Actual result:
--
PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate
4294967295 bytes) in D:\Web\test.php on line 3





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