Bug #73725 [Opn->Csd]: Unable to retrieve value of varchar(max) type

From: Date: Mon, 22 Jan 2018 16:05:54 +0000
Subject: Bug #73725 [Opn->Csd]: Unable to retrieve value of varchar(max) type
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213661@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
 Updated by:         ab@php.net
 Reported by:        honza dot hink at gmail dot com
 Summary:            Unable to retrieve value of varchar(max) type
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            ODBC related
 Operating System:   Windows 10
 PHP Version:        7.1.0
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2384ade53c9ddb45b56e803a8d8494737732b84b
Log: Fixed bug #73725 Unable to retrieve value of varchar(max) type


Previous Comments:
------------------------------------------------------------------------
[2018-01-19 11:57:07] honza dot hink at gmail dot com

I am afraid the problem will remain open for next decade too.

------------------------------------------------------------------------
[2018-01-19 11:43:26] Jan_Oonk at hotmail dot com

Had the same problem.
Simple to recreate:
make a table in Microsoft SQL Server Express (64-bit) v13.0.4001.0 NT x64
with a column varchar(max)

I used 
Apache/2.4.18 (Win64) 
PHP/7.0.3 
PDO with {ODBC Driver 13 for SQL Server}

Do a simple select query on the column and echo it and you will notice the text will be garbled.

The solution was to use a fixed size varchar column for example varchar(1024)

------------------------------------------------------------------------
[2017-03-21 14:23:09] david dot js dot campbell at gmail dot com

Having the exact same issue (PHP 5.6, reproducible on any version as it seems).   The issue is we
cannot use the native {SQL Server} driver as it does not support TLS 1.2+

So far the only solution is to cast the column to text when selecting, which is not a solution at
all.

------------------------------------------------------------------------
[2016-12-19 22:12:53] honza dot hink at gmail dot com

Of course, the 64-bit architecture is used in both PHP and ODBC, but the same behavior is in 32-bit
versions. You used different driver "ODBC SQL Server Driver" that has worse bugs. I used
the newest "SQL Server Native Client 11.0".

The worse bug is - text column type must be placed at the end in select list else error is reported.
See my comment here:

http://stackoverflow.com/questions/6361340/java-sql-sqlexceptionmicrosoftodbc-driver-manager-invalid-descriptor-in/31963700#31963700

Both errors are in this drivers for >7 years and to say truth - I dont believe much I will live
to see the see a fix.

------------------------------------------------------------------------
[2016-12-19 11:19:09] ab@php.net

Thanks for posting the trace. Please pastebin it somewhere next time. On my side, I cannot reproduce
the wrong behavior, please check https://gist.github.com/weltling/a8b7087b78bb059b909e1c073862ceb2#file-bug73725-log-L211
. In your variant, it tells

DIAG [01004] [Microsoft][SQL Server Native Client 11.0]String data, right truncation (0) 

Is the PHP you use 64-bit build as well? Probably shouldn't work otherwise, but anyway. Some
environment/configuration difference might cause this, probably more about it. Or some other code,
surrounding the reproducer. Also seems we've used different drivers. I'd suggest you to
check and compare the traces, the environment difference is for sure to read from there.

Thanks.

------------------------------------------------------------------------


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=73725


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


Thread (11 messages)

« previous php.bugs (#213661) next »