php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65950 Field name truncation if the field name is bigger than 32 characters
Submitted: 2013-10-23 11:49 UTC Modified: 2013-10-28 09:44 UTC
From: michael dot y at zend dot com Assigned: yohgaki (profile)
Status: Closed Package: ODBC related
PHP Version: 5.4.21 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael dot y at zend dot com
New email:
PHP Version: OS:

 

 [2013-10-23 11:49 UTC] michael dot y at zend dot com
Description:
------------
Field names are truncated to 30 charactes if they are bigger than 32 bytes in MS SQL Server. If i am using odbc php extension that connects to unixodbc + freetds.


Test script:
---------------
<?php

$cnx = odbc_connect("Driver=FreeTDS; Server=10.9.178.47;port=1433;Database=AdventureWorks;CHARSET=UTF-8;TDS_Version=8.0;", "sa", "pass");

$query = "SELECT * FROM dbo.Roman";

$res = odbc_exec($cnx,$query);

while( $row = odbc_fetch_array($res) ) {
        print_r($row);
} 

echo $cnx;
?>

Expected result:
----------------
Roman table there is a field which name is hello_one_two_three_four_five_six_seven_eight_nine_ten_eleven.

Actual result:
--------------
It is truncated to hello_one_two_three_four_five_ .

Patches

php_odbc.patch (last revision 2013-10-23 11:49 UTC by michael dot y at zend dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-25 23:11 UTC] yohgaki@php.net
I think SQL standard is 128, but 256 should work also. (There may be DBMS that has larger limit) Checked php_obdb.c and it look fine with your patch. 

I'll apply your patch.
Thank you.
 [2013-10-26 23:01 UTC] yohgaki@php.net
-Assigned To: +Assigned To: yohgaki
 [2013-10-26 23:01 UTC] yohgaki@php.net
Patches for branches is ready, but git is closed now.
Assign this to myself.
 [2013-10-28 09:44 UTC] yohgaki@php.net
-Status: Assigned +Status: Closed
 [2013-10-28 09:44 UTC] yohgaki@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

http://git.php.net/?p=php-src.git;a=commitdiff;h=e50eb1ce3408d15cd26fd88203c68f52e59f6b0b
 [2013-11-04 09:00 UTC] ab@php.net
Automatic comment on behalf of yohgaki
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e50eb1ce3408d15cd26fd88203c68f52e59f6b0b
Log: Fixed bug #65950 Field name truncation if the field name is bigger than 32 characters
 [2013-11-28 14:48 UTC] charles dot durrant at thomsonreuters dot com
I had this problem, patch appreciated
 [2013-11-28 15:09 UTC] charles dot durrant at thomsonreuters dot com
Under SQL server Native Client 11.00 on Linux I get truncated to 15 - field names are returned as wide chars so I assume it is getting halved so 256 is a safer buffer size.
 [2014-10-07 23:16 UTC] stas@php.net
Automatic comment on behalf of yohgaki
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=e50eb1ce3408d15cd26fd88203c68f52e59f6b0b
Log: Fixed bug #65950 Field name truncation if the field name is bigger than 32 characters
 [2014-10-07 23:27 UTC] stas@php.net
Automatic comment on behalf of yohgaki
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=e50eb1ce3408d15cd26fd88203c68f52e59f6b0b
Log: Fixed bug #65950 Field name truncation if the field name is bigger than 32 characters
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC