php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66345 The trailing spaces are removed on varchar and lvarchar types.
Submitted: 2013-12-24 10:35 UTC Modified: 2016-05-12 10:07 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: josemalonsom at yahoo dot es Assigned: vnkbabu (profile)
Status: Not a bug Package: PDO_INFORMIX (PECL)
PHP Version: 5.5.7 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: josemalonsom at yahoo dot es
New email:
PHP Version: OS:

 

 [2013-12-24 10:35 UTC] josemalonsom at yahoo dot es
Description:
------------
The PDO Informix driver trims trailing spaces on varchar and lvarchar types.

CSDK: 4.10UC2DE
PHP: 5.3.10, 5.5.7
PDO_INFORMIX: 1.2.7, 1.3.1
Informix: IDS 11.50.UC9DE


Test script:
---------------
  $con = new PDO($dsn, $user, $passwd);

  $sql = 'create table test_varchar (test_varchar varchar(10),test_lvarchar lvarchar(10))';

  $con->exec($sql);

  $sql = 'insert into test_varchar(test_varchar, test_lvarchar) values ("foo ", "foo ")';

  $con->exec($sql);

  $sql = 'select * from test_varchar';

  $row = $con->query($sql)->fetch(PDO::FETCH_ASSOC);

  print strlen($row['TEST_VARCHAR']) . "\n";
  print strlen($row['TEST_LVARCHAR']) . "\n";


Expected result:
----------------
The fetched strings had to be the same that the inserted strings.

Actual result:
--------------
The trailing spaces of the strings are removed (the spaces are saved in the database, it can be checked with the dbaccess command).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-12 10:05 UTC] rahulpriyadarshi@php.net
-Assigned To: +Assigned To: rahulpriyadarshi
 [2014-02-12 10:05 UTC] rahulpriyadarshi@php.net
This is the default behavior PDO_Informix have with varchar, lvarchar type.

Do you wants to get trailing spaces also? If yes then we will look into the possibility to provide this support.
 [2014-02-13 19:22 UTC] josemalonsom at yahoo dot es
-Type: Bug +Type: Feature/Change Request
 [2014-02-13 19:22 UTC] josemalonsom at yahoo dot es
The dbaccess client returns the trailing spaces in this cases so it is not a limitation imposed by the RDBMS, i think that the behaviour expected should be that the data is returned such as were inserted, without modifications, the spaces are also data.

I assume that the default behaviour can't be changed or it can break the code already existing but i think that an option to change the default behaviour would be useful.
 [2016-02-07 15:46 UTC] rahulpriyadarshi@php.net
-Assigned To: rahulpriyadarshi +Assigned To: vnkbabu
 [2016-05-12 10:07 UTC] vnkbabu@php.net
-Status: Assigned +Status: Not a bug
 [2016-05-12 10:07 UTC] vnkbabu@php.net
I did the debug of PDO_INFORMIX, i printed the fetched values right after issuing the SQLFetchScroll() API, i can see we are getting the trimmed down string from the informix ODBC driver.


(gdb)
1029            rc = SQLFetchScroll((SQLHSTMT)stmt_res->hstmt, direction, (SQLINTEGER) offset);
(gdb)  p stmt_res->columns[0]
$8 = {name = 0x7ffff6271eb0, namelen = 12, data_type = 12, returned_type = PDO_PARAM_STR, data_size = 10, nullable = 1, scale = 0, out_length = 3, data = {l_val = 140737323217184,
    str_val = 0x7ffff6283120 "foo"}}
(gdb)  p stmt_res->columns[1]
$9 = {name = 0x7ffff6271f00, namelen = 13, data_type = 12, returned_type = PDO_PARAM_STR, data_size = 10, nullable = 1, scale = 0, out_length = 3, data = {l_val = 140737323217232,
    str_val = 0x7ffff6283150 "foo"}}

I also see the similar discussion with ODBC application,
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014438618

If you disagree please raise an PMR to Informix Client team.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 03:01:28 2025 UTC