#44278 [Com]: nvarchar(max) mangled

From: Date: Tue, 26 May 2009 06:52:44 +0000
Subject: #44278 [Com]: nvarchar(max) mangled
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137742@lists.php.net to get a copy of this message
ID: 44278 Comment by: ian at mutexlabs dot com Reported By: ethan dot nelson at ltd dot org Status: Open Bug Type: PDO related Operating System: win2k3 PHP Version: 5.2.7 New Comment: I can confirm this bug on Windows 2003, PHP 5.2.7, 5.2.9 and the 5.2.10-dev release linked in this bug. I'm actually using the odbc_* functions, not PDO, but the behaviour is the same. I worked around the problem by rebuilding the database using nvarchar(255) instead of nvarchar(max) types - it was safer than modifying the PHP app. I saw similar (corruption) behaviour on varchar and char types, though I didn't investigate closely. text columns are OK, but unsuitable for my application. Previous Comments: ------------------------------------------------------------------------ [2009-05-19 22:51:45] ethan dot nelson at ltd dot org No difference in behavior from what I can see. Can you reproduce the bug on your end? My screen reports the following using my reproduce code (with a few lines from the phpinfo command()): SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled Array ( [0] => Array ( [good] => asdfasdfasdf [garbled] => &#65533;í[(í[&#65533;&#65533;&#65533; ) ) PHP Logo PHP Version 5.2.10-dev System Windows NT LTD-PWWW2 5.2 build 3790 Build Date May 19 2009 11:39:28 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\bin\\..\snap_5_2\vc6\x86\template" "--with-php-build=d:\php-sdk\bin\\..\snap_5_2\vc6\x86\php_build" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared" Server API ISAPI ------------------------------------------------------------------------ [2009-05-03 01:00:10] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2009-04-25 14:54:59] jani@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-28 20:21:41] ethan dot nelson at ltd dot org <?php ini_set("display_errors","yes"); $poo = new PDO("odbc:DEVELOPMENT"); $query = "SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled"; $stm = $poo->prepare($query); echo $query."<br>\n"; $id = 1; $stm->bindParam(':id',$id,PDO::PARAM_INT); $id2 = 1; $stm->bindParam(':id2',$id2,PDO::PARAM_INT); echo "<pre>\n"; if ($stm->execute()) print_r($stm->fetchAll(PDO::FETCH_ASSOC)); else print_r( $stm->errorInfo()); echo "</pre>\n"; phpinfo(); ?> -----------Results in: SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled Array ( [0] => Array ( [good] => asdfasdfasdf [garbled] => ä ä ) ) PHP Version 5.2.7RC2-dev ------------------------------------------------------------------------ [2008-02-28 00:51:28] ethan dot nelson at ltd dot org Description: ------------ I'm using PDO and the ODBC extension. Also I've installed the latest version of the SQL 2005 client tools so that I could create a System DSN using the SQLNative driver. That in place, I've run into trouble when selecting data out of nvarchar(max) fields. nvarchar works fine, nvarchar(max) fails. Additionally, it appears that I can insert data into these columns without issue. Try something simple... Reproduce code: --------------- $pdo = new PDO("odbc:systemdsn"); $query = "SELECT CAST('asdfasdfasdf' AS nvarchar) AS good, CAST('asdfasdfasdf' AS nvarchar(max)) AS garbled"; $poo = $pdo->prepare($query); $poo->execute(); $row = $poo->fetch(PDO::FETCH_ASSOC); print_r($row); Expected result: ---------------- Array ( [good] => asdfasdfasdf [garbled] => asdfasdfasdf ) Actual result: -------------- Array ( [good] => asdfasdfasdf [garbled] => &#65533;&#65533;L &#65533;L&#65533;&#65533;&#65533; ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44278&edit=1

« previous php.bugs (#137742) next »