|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57683 When retrieving XML cast as a blob on Linux you will get garbage back where on
Submitted: 2007-05-24 13:22 UTC Modified: 2007-05-30 12:28 UTC
From: matthewv at ca dot ibm dot com Assigned:
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
 [2007-05-24 13:22 UTC] matthewv at ca dot ibm dot com
This piece of code is being run against the sample XML database created with ?db2sampl ?xml?. Clean output is produced on windows and garbage is produce when I run this sample on various Linux systems.

Reproduce code:
$db2conn = db2_connect("SAMPLE", "", "");

    $query = "SELECT cid AS CID, XMLSERIALIZE(info as blob) as INFO FROM customer WHERE cid < 1005";

    $stmt = db2_exec($db2conn, $query);

    if($stmt === false)
        print(db2_stmt_errormsg() . "\n");
      // retrieve and display the result from the xquery
      $aResult = db2_fetch_assoc($stmt);
      printf("%s\n%s\n\n", $aResult['CID'], $aResult['INFO']);


Expected result:
<customerinfo xmlns="" Cid="1000"><name>Kathy Smith</name><addr country="Canada"><street>5 Rosewood</street><city>Toronto</city><prov-state>Ontario</prov-state><pcode-zip>M6W 1E6</pcode-zip></addr><phone type="work">416-555-1358</phone></customerinfo>

Actual result:
EuȜ   ?i?i    Hi        aResult " Ci   5   ?iF       miQ      


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-30 11:34 UTC] opendev at us dot ibm dot com
This test appears to be working as expected.  The output is coming back as binary as you specified with "info as blob".  A quick work-around if you want regular text to come back is to use clob instead.  For example:

$query = "SELECT cid AS CID, XMLSERIALIZE(info as clob) as INFO FROM customer WHERE cid < 1005";

We hope this resolves your situation.  Please let us know if you have any further issues.
 [2007-05-30 12:28 UTC] matthewv at ca dot ibm dot com

But how then do I decode the binary data in to something useful?

When I pull back data as a varchar,  CLOB or BLOB I expect the data to be equivalent in some way. (This should be especially true under Linux since Binary data and text data are treated as the same.)  But what I get back is just garbage and contains ether nothing or only part of what was querying, on top of that the binary data that I get back is not consistent which would be expected if I was getting something proper back. 

On top of this if I was to get the data back and read all the results PHP segfault core dump.  

I realize by looking at this just from an overview it looks like what you expect but when running this you will see that this dose not do what is expected.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Jul 09 18:01:27 2020 UTC