Bug #73725 [Opn]: Unable to retrieve value of varchar(max) type
| From: | honza dot hink at gmail dot com | Date: | Mon, 12 Dec 2016 16:10:31 +0000 |
| Subject: | Bug #73725 [Opn]: Unable to retrieve value of varchar(max) type | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205934@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73725&edit=1
ID: 73725
User updated by: honza dot hink at gmail dot com
Reported by: honza dot hink at gmail dot com
Summary: Unable to retrieve value of varchar(max) type
Status: Open
Type: Bug
Package: ODBC related
Operating System: Windows 10
PHP Version: 7.1.0
Block user comment: N
Private report: N
New Comment:
Related to MS SQL - all versions from 2005 to 2014
Previous Comments:
------------------------------------------------------------------------
[2016-12-12 16:06:45] honza dot hink at gmail dot com
Description:
------------
If result set contains a column type varchar(max) then all functions (odbc_fetch_array,
odbc_fetch_row etc.) return some random bytes.
It looks like buffer overrun.
If you change declaration varchar(max) to varchar(200) then it will work.
Very old bug, I hopped it will be finally fixed in PHP 7, but wainly.
Test script:
---------------
<?php
$con=odbc_connect("Local64bit","you","yourPWD");
$res=odbc_do($con,"set nocount on
create table #t(i int, txt varchar(max))
insert into #t values(101,'Any text')
select i,txt from #t
");
$r=odbc_fetch_array($res);
print_r($r);
?>
Expected result:
----------------
Array ( [i] => 101 [txt] => Any text )
Actual result:
--------------
Array ( [i] => 101 [txt] => â¬Âk )
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73725&edit=1