Bug #46274 MySQL Xml output of binary field not valid ASCII
Submitted: 17 Jul 2009 20:21 Modified: 18 Aug 2009 10:15
Reporter: John McCormick Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: XML functions Severity:S2 (Serious)
Version:5.1.35 OS:Windows
Assigned to: CPU Architecture:Any
Tags: BINARY, XML

[17 Jul 2009 20:21] John McCormick
Description:
I have performed a query against a database that has a binary(1) field. When the binary value is 0 the resulting XML generated showing the value shows a value of '0'. If however the value is 1 the resulting XML has an actual byte with the value of 0x01 rather than the ASCII character '1'. 

How to repeat:
Create a table with a column with a datatype BINARY(1)

Set the value of one of the column to 1 in one row and the value to 0 in another row. Then perform the query with mysql.exe --xml option to get the result in XML.

Suggested fix:
Should return an ASCII value for the result rather than binary value in the XML.
[18 Jul 2009 10:15] Valeriy Kravchuk
Thank you for the problem report. Please, send complete test case. This is what I've got in my test:

mysql> create table tbn(c1 binary(1));
Query OK, 0 rows affected (0.13 sec)

mysql> insert into tbn values(0), (1);
Query OK, 2 rows affected (0.08 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from tbn;
+------+
| c1   |
+------+
| 0    |
| 1    |
+------+
2 rows in set (0.00 sec)

mysql> select hex(c1) from tbn;
+---------+
| hex(c1) |
+---------+
| 30      |
| 31      |
+---------+
2 rows in set (0.05 sec)

mysql> exit
Bye

C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot -P3308 --xml -e
"select * from tbn" test
<?xml version="1.0"?>

<resultset statement="select * from tbn
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <row>
        <field name="c1">0</field>
  </row>

  <row>
        <field name="c1">1</field>
  </row>
</resultset>

C:\Program Files\MySQL\MySQL Server 5.0\bin>cd "..\..\MySQL Server 5.1"\bin

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -uroot -proot -P3308 --xml -e
"select * from tbn" test
<?xml version="1.0"?>

<resultset statement="select * from tbn
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <row>
        <field name="c1">0</field>
  </row>

  <row>
        <field name="c1">1</field>
  </row>
</resultset>

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql --version
mysql  Ver 14.14 Distrib 5.1.36, for Win32 (ia32)

I do not see any problem.
[18 Aug 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".