From: phpbugs at mfoxx dot myspamkiller dot com
Operating system: winxp, sp1
PHP version: 5.0.4
PHP Bug Type: MSSQL related
Bug description: mssql extension has a max length on returnable fieldnames
Description:
------------
FYI: I am running php 5.0.4 (binary distro) for windows, with apache
2.0.50 (binary distro), on a winXP sp1 machine.
If i execute:
select field1 as 'abcdefghijklmnopqrstuvwxyz0123456789' from mytable
in SQL Query Analyzer against a SQL Server 2000 database, i get the
expected result that the field name is named that whole big long alias, 36
characters in length.
However, when i execute the same query using mssql_query() in PHP, and i
examine the results of mssql_fetch_object(), mssql_fetch_array(), or
mssql_fetch_assoc(), the field name (alias) is truncated at 30 characters
(it seems).
I do the same test against the mysql_xxx extension, and I get no
truncation (i tested with upwards of about 100 chars in the field_name
alias and all was fine).
Reproduce code:
---------------
$link = mssql_connect("localhost","sa","mypassword");
mssql_select_db("my_db",$link);
$query = "select field1 as 'abcdefghijklmnopqrstuvwxyz0123456789' from
my_table";
$result = mssql_query($query);
print_r(mssql_fetch_object($result));
$result = mssql_query($query);
print_r(mssql_fetch_array($result));
$result = mssql_query($query);
print_r(mssql_fetch_assoc($result));
Expected result:
----------------
stdClass Object ( [abcdefghijklmnopqrstuvwxyz0123456789] => 0 ) Array (
[0] => 0 [abcdefghijklmnopqrstuvwxyz0123456789] => 0 ) Array (
[abcdefghijklmnopqrstuvwxyz0123456789] => 0 )
Actual result:
--------------
stdClass Object ( [abcdefghijklmnopqrstuvwxyz0123] => 0 ) Array ( [0] => 0
[abcdefghijklmnopqrstuvwxyz0123] => 0 ) Array (
[abcdefghijklmnopqrstuvwxyz0123] => 0 )
** notice that all 3 methods have a truncated field_name to 30 characters.
This obviously results in unexpected code problems when I have dynamic SQL
queries being generated and its difficult to predict if an alias I assign
to a field may exceed this limit, and if it does, i never get the value
out in my result-set processing because the name doesn't match what i
think it should.
--
Edit bug report at http://bugs.php.net/?id=33060&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33060&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33060&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33060&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33060&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33060&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33060&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33060&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33060&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33060&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33060&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33060&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33060&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33060&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33060&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33060&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33060&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33060&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33060&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33060&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33060&r=mysqlcfg