#33693 [NEW]: mssql uniqueidentifier in select crashes php

From: Date: Thu, 14 Jul 2005 08:53:48 +0000
Subject: #33693 [NEW]: mssql uniqueidentifier in select crashes php
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81846@lists.php.net to get a copy of this message
From: r dot vanicek at seznam dot cz Operating system: Linux (Debian 3.1) PHP version: 4.4.0 PHP Bug Type: Sybase-ct (ctlib) related Bug description: mssql uniqueidentifier in select crashes php Description: ------------ I am connecting from PHP to Sybase and MSSQL. I have sybase-ct extension enabled. I use freetds-0.63. When I select from MSSQL any column of type "uniqueidentifier", PHP crashes on fetch. The problem is conversion. Sybase-ct module does not handle CS_UNIQUE_TYPE, and tries to store the 38 byte string that freetds returns to it into 16 byte string. Freetds refuses to do so and signals an error, which is probably fatal. Test suite: see reproduce code. The solution I suggest is to intoduce CS_UNIQUE_TYPE into php_sybase_ct.c, function php_sybase_fetch_result_set for example like this: case CS_DECIMAL_TYPE: result->datafmt[i].maxlength = result->datafmt[i].precision + 3; /* numeric(10) vs numeric(10, 1) */ result->numerics[i] = (result->datafmt[i].scale == 0) ? 3 : 2; break; case CS_UNIQUE_TYPE: result->datafmt[i].maxlength = 38; result->numerics[i] = 0; break; default: result->datafmt[i].maxlength++; result->numerics[i] = 0; break; This solution works for me quite well. Reproduce code: --------------- create table TEST (a int, b varchar, c uniqueidentifier); insert into TEST values (1,'hello',newid()); sybase_connect( "srv", "uid", "pwd" ); sybase_select_db( "dbname" ); // this works fine $res = sybase_query( "select a,b from TEST" ); $row = sybase_fetch_array( $res ); // this crashes $res = sybase_query( "select a,b,c from TEST" ); $row = sybase_fetch_array( $res ); It is all the same if you use mssql_ functions instead of sybase_ functions. Expected result: ---------------- eg. row containing 1 'hello' 'EB668095-F85D-4C59-A202-120C5CE1B65' Actual result: -------------- crash, in Apache error.log I see this: [notice] child pid 18857 exit signal Segmentation fault (11) error_handler: Data-conversion resulted in overflow. -- Edit bug report at http://bugs.php.net/?id=33693&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33693&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33693&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33693&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33693&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33693&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33693&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33693&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33693&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33693&r=support Expected behavior: http://bugs.php.net/fix.php?id=33693&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33693&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33693&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33693&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33693&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33693&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33693&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33693&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33693&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33693&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33693&r=mysqlcfg

« previous php.bugs (#81846) next »