|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67437 error processing nvarchar(max) types from SQL Server with MS ODBC Linux Driver
Submitted: 2014-06-13 10:44 UTC Modified: 2015-02-15 04:22 UTC
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: laurent dot mirguet at aufeminin dot com Assigned:
Status: No Feedback Package: ODBC related
PHP Version: 5.5.13 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: laurent dot mirguet at aufeminin dot com
New email:
PHP Version: OS:


 [2014-06-13 10:44 UTC] laurent dot mirguet at aufeminin dot com
When using the Microsoft ODBC driver for SQL Server on Linux (see

Calling odbc_result() on an nvarchar(max) type results in a memory exhausted error as PHP is trying to allocate 4Go of RAM (the max size of an nvarchar type).

This seems to happen in the file ext/odbc/php_odbc.c line 2148 :
- the type nvarchar(max) is not recognized in the code, so the switch falls back in the default case
- and the value of result->values[field_ind].vallen is 4Go

I don't know whether the problem comes from the PHP code, the unixODBC code, or the Microsoft code...

Test script:
Any odbc_result() call on a non-empty nvarchar(max) type should do the trick and generate a memory exhauted error.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-13 09:19 UTC] stefan dot thuering at gmail dot com
I have a similar problem on Windows 2008 Server.

Running odbc_exec on a nvarchar(max) col in MSSQL crashes PHP 5.5
This was working on PHP 5.4

Error message:
PHP Fatal error:  Out of memory (allocated 786432) (tried to allocate 4294967293 bytes) in on line 27

When the field is nvarchar(4000) everything works.
 [2015-02-06 18:08 UTC]
@laurent, please check the current 5.5+ tree.

 [2015-02-06 18:08 UTC]
-Status: Open +Status: Feedback
 [2015-02-15 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2015-02-19 15:53 UTC] sinasalek at gmail dot com
Using PHP 5.6.5 on Ubuntu Linux 64bit. and still experiencing the same problem.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Mar 04 11:01:28 2024 UTC