Bug #68964 [Com]: Allowed memory size exhausted with odbc_exec
Edit report at https://bugs.php.net/bug.php?id=68964&edit=1
ID: 68964
Comment by: giodev at panozzo dot it
Reported by: giodev at panozzo dot it
Summary: Allowed memory size exhausted with odbc_exec
Status: Open
Type: Bug
Package: ODBC related
Operating System: Windows Server 2012
PHP Version: 5.6.5
Block user comment: N
Private report: N
New Comment:
Update: nxtext and nvrchar(max) fields causes the problem, even if they are empty. If you change the
fields to nvarchar(4000), all seems to be working.
This bug is similar to bug #67437, but #67437 is linux related.
Previous Comments:
------------------------------------------------------------------------
[2015-01-31 18:52:04] giodev at panozzo dot it
Two more notes:
- This happens when querying both MSSQL server Express 2008 or 2012
- Workaround: change ntext field to nvarchar(max) (as explained here: https://msdn.microsoft.com/en-us/library/ms186939.aspx)
------------------------------------------------------------------------
[2015-01-31 18:38:49] giodev at panozzo dot it
Description:
------------
I'm running PHP 5.6.5 x64 nts on Windows Server 2012, 64bit, fastcgi.
When I execute odbc_exec from a table with ntext field, selecting the ntext field, PHP crashes my
script with the following error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate
1073741824 bytes) in C:\Users\username1\Desktop\odbc_exec_crash_test.php on line 16
The same problem persists with almost all previous versions available on the download site, both 32
and 64 bits, non-thread-safe:
php 5.6.5 i386 nts
php 5.5.21 x64 nts
php 5.4.37 i386 nts
Test script:
---------------
<?php
$dbloc_dsn_srv = "DRIVER={SQL Server Native Client 11.0};Server=MYSERVER\MYINSTANCE".
";ExtendedAnsiSQL=1;Database=mydb;UID=userweb1;PWD=pwdweb";
$cn = odbc_pconnect($dbloc_dsn_srv,"","")
or die("Error connecting to DB\n".odbc_errormsg());
print "PHP version ".phpversion()."\n";
$qry = "IF OBJECT_ID('test1', 'U') IS NOT NULL DROP TABLE test1";
$res = odbc_exec($cn,$qry) or die("Drop query error: $qry\n");
$qry = "CREATE TABLE test1 ( id integer not null, field ntext default '' not null,
primary key(id))";
$res = odbc_exec($cn,$qry) or die("Query error: $qry\n");
$qry = "SELECT field from test1";
$res = odbc_exec($cn,$qry) or die("Query error: $qry\n");
while( $row = odbc_fetch_object($res) ) {
print $row->field."\n";
}
print "Done without errors\n";
?>
Expected result:
----------------
PHP version 5.6.5
Done without errors
Actual result:
--------------
PHP version 5.6.5
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1073741824 bytes)
in C:\Users\username1\Desktop\odbc_exec_crash_test.php on line 16
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68964&edit=1
Thread (7 messages)