php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: matthewv at ca dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-05-24 13:22 UTC] matthewv at ca dot ibm dot com
Description:
------------
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:
---------------
<?php
$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");
    }
    else
    {
      print($toPrintToScreen);
      // retrieve and display the result from the xquery
      $aResult = db2_fetch_assoc($stmt);
      printf("%s\n%s\n\n", $aResult['CID'], $aResult['INFO']);
      db2_free_stmt($stmt);
    }

?>

Expected result:
----------------
1000
<customerinfo xmlns="http://posample.org" 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:
--------------
1000
EuȜ   ?i?i    Hi        aResult " Ci   5   ?iF       miQ      

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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
Fair,

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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 22:01:30 2024 UTC