php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66738 For columns of LOB types the NULL values are returned as empty strings.
Submitted: 2014-02-18 22:10 UTC Modified: 2014-03-04 19:18 UTC
From: josemalonsom at yahoo dot es Assigned: rahulpriyadarshi (profile)
Status: Closed Package: PDO_INFORMIX (PECL)
PHP Version: Irrelevant OS: Ubuntu 12.04.3 LTS
Private report: No CVE-ID: None
 [2014-02-18 22:10 UTC] josemalonsom at yahoo dot es
Description:
------------
PHP: 5.5.8
Informix IDS: 12.10.UC2DE
CSDK: 4.10.UC2DE
PDO_INFORMIX: 1.3.1


When a column of some LOB type, TEXT, BYTE, CLOB or BLOB has NULL as value an empty string is returned instead of NULL when the value is fetched, occurs also when the PDO::ATTR_STRINGIFY_FETCHES driver option is set to true.

Test script:
---------------
  // $con has a valid PDO_INFORMIX connection.

  $sql = 'create table t1 ( c1 char(1), c2 char(1), ctext text, cbyte byte, cclob clob, cblob blob )';
  $con->exec($sql);

  $sql = "insert into t1 (c1) values ('A')";
  $con->exec($sql);

  $row = $con->query('select * from t1')->fetch(PDO::FETCH_ASSOC);

  foreach ($row as $field => &$value) {
    if (is_resource($value)) {
      $value = stream_get_contents($value);
    }
  }

  var_dump($row);


Expected result:
----------------
All the LOB types must be NULL.

Actual result:
--------------
array(6) {
  'C1' =>
  string(1) "A"
  'C2' =>
  NULL
  'CTEXT' =>
  string(0) ""
  'CBYTE' =>
  string(0) ""
  'CCLOB' =>
  string(0) ""
  'CBLOB' =>
  string(0) ""
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-21 10:43 UTC] rahulpriyadarshi@php.net
-Assigned To: +Assigned To: rahulpriyadarshi
 [2014-02-21 10:43 UTC] rahulpriyadarshi@php.net
I am able to reproduce this issue, will try to give the patch shortly.
 [2014-02-21 10:51 UTC] rahulpriyadarshi@php.net
Automatic comment from SVN on behalf of rahulpriyadarshi
Revision: http://svn.php.net/viewvc/?view=revision&revision=332875
Log: issue #66738, columns of LOB types the NULL values are returned as empty strings
 [2014-02-21 10:56 UTC] rahulpriyadarshi@php.net
I have made a patch for this and committed the changes on the SVN branch.

It is working fine in my environment, please give a try to Revision 332875 of SVN branch and let me know how it works for you.
 [2014-02-22 10:48 UTC] josemalonsom at yahoo dot es
Thanks very much for the fast reply.

It works but a new issue is introduced, now the TEXT types are returned always as NULL even when they contain a not NULL value.

Test script:
---------------

  // $con has a valid PDO_INFORMIX connection.

  $sql = 'create table t1 ( ctext text )';
  $con->exec($sql);

  $sql = "insert into t1 ( ctext ) values (?)";
  $stmt = $con->prepare($sql);
  $stmt->bindValue(1, 'text_value');
  $stmt->execute();

  $stmt = $con->prepare('select ctext from t1');
  $stmt->execute();

  $ctext = null;
  $stmt->bindColumn(1, $ctext, PDO::PARAM_LOB);

  $stmt->fetch(PDO::FETCH_BOUND);

  if (is_resource($ctext)) {
    $ctext = stream_get_contents($value);
  }

  var_dump($ctext);
 [2014-02-25 09:17 UTC] rahulpriyadarshi@php.net
I am able to reproduce the issue, and working on the same. 

I will try to resolve this issue as soon as possible.
 [2014-02-28 11:47 UTC] rahulpriyadarshi@php.net
Automatic comment from SVN on behalf of rahulpriyadarshi
Revision: http://svn.php.net/viewvc/?view=revision&revision=332903
Log: issue #66738, columns of LOB data types
 [2014-03-03 06:27 UTC] rahulpriyadarshi@php.net
I have made some changes and have committed the same to SVN branch, and it is now working fine with my environment.

Could you please try it and let us know how it works for you.
 [2014-03-04 19:18 UTC] josemalonsom at yahoo dot es
-Status: Assigned +Status: Closed
 [2014-03-04 19:18 UTC] josemalonsom at yahoo dot es
Yes, it works as expected, good job.

Thank you very much :).
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Mar 23 22:01:25 2019 UTC