php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62625 fetching erroneous data when the data has special characters
Submitted: 2012-07-20 20:13 UTC Modified: 2016-05-12 06:44 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: andresblanco at gmail dot com Assigned: vnkbabu (profile)
Status: Not a bug Package: PDO_INFORMIX (PECL)
PHP Version: 5.3.15 OS: ubuntu
Private report: No CVE-ID: None
 [2012-07-20 20:13 UTC] andresblanco at gmail dot com
Description:
------------
The driver is chopping some values of the return strings. It's like special 
characters counts double. 
If a column 'name' has type varchar(2) and the value of name is 'áa' the value 
returned when queried is 'á' instead of 'áa'. If i resize the column to 
varchar(3) 
the result is correct.
Below I attach a short script to reproduce the bug. I included the dsn so you can 
see the encoding settings

Test script:
---------------
$dsn = "informix:database=base;server=ol_server;host=192.168.123.123;client_locale=en_us.utf8;db_locale=en_us.819;service=1526;protocol=olsoctcp;EnableScrollableCursors=1";
$db = new \PDO($dsn, 'user', 'pass');
$db->exec("CREATE TABLE ticket82 ( name VARCHAR(2) );");
$db->exec("INSERT INTO ticket82 VALUES ('aa');");

$statement = $db->query("select name from ticket82;");
$value = $statement->fetchAll(\PDO::FETCH_ASSOC);
echo "expected 'aa' got '{$value[0]['NAME']}'\n";

$db->exec("update ticket82 set name='áa';");
$statement = $db->query("select name from ticket82;");
$value = $statement->fetchAll(\PDO::FETCH_ASSOC);
echo "expected 'áa' got '{$value[0]['NAME']}'\n";

$db->exec("ALTER TABLE ticket82 MODIFY (name varchar(3));");
$statement = $db->query("select name from ticket82;");
$value = $statement->fetchAll(\PDO::FETCH_ASSOC);
echo "expected 'áa' got '{$value[0]['NAME']}'\n";

$db->exec("DROP TABLE ticket82;");

Expected result:
----------------
expected 'aa' got 'aa'
expected 'áa' got 'áa'
expected 'áa' got 'áa'


Actual result:
--------------
expected 'aa' got 'aa'
expected 'áa' got 'á'
expected 'áa' got 'áa'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-20 20:16 UTC] andresblanco at gmail dot com
The pdo_informix version i'm using is the last one, 1.2.7
 [2014-03-03 18:59 UTC] rahulpriyadarshi@php.net
-Assigned To: +Assigned To: rahulpriyadarshi
 [2014-03-03 18:59 UTC] rahulpriyadarshi@php.net
I have committed the changes into SVN branch, could you please give a try to this and let me know how it works for your environment.
 [2016-02-07 15:42 UTC] rahulpriyadarshi@php.net
-Assigned To: rahulpriyadarshi +Assigned To: vnkbabu
 [2016-05-12 06:44 UTC] vnkbabu@php.net
-Status: Assigned +Status: Not a bug
 [2016-05-12 06:44 UTC] vnkbabu@php.net
Hi,
  Have verified the issue. Since Informix database is created by default  in 819/1252 codepage and á occupes 2 bytes, hence  select statement after update is is giving only 1 character. Since the table definition has varchar(2) IDS server is returning only 2 bytes(i.e only 1st char), after ALTER statement, SELECT statement returning 'áa' because now the name is VARCHAR(3) and returning total 3 bytes to client.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 17:01:26 2019 UTC