Below is the list of changes that have just been committed into a local
5.0 repository of iggy. When iggy does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-10-13 11:59:38-04:00, iggy@stripped +3 -0
Bug#19745: mysqldump --xml produces invalid xml
The mysqldump command with the --xml and --hex-blob options will output blob data encoded as hexBinary. The proper XML
datatype is defined as xs:hexBinary. A user supplied XSL or XSLT is necessary for an XML parser to read hex encoded
binary data.
client/mysqldump.c@stripped, 2006-10-13 11:59:36-04:00, iggy@stripped +32 -10
Bug#19745: mysqldump --xml produces invalid xml
- --xml option respects the --hex-blob option by ouptuting blob data hex encoded.
- Moved hex-blob code to it's own function.
- --extended-insert and --xml are mutually exclusive. Otherwise, the xml file will contain INSERT commands.
- Minor comment cleanup.
mysql-test/r/mysqldump.result@stripped, 2006-10-13 11:59:36-04:00, iggy@stripped +22 -0
Bug#19745: mysqldump --xml produces invalid xml
-Added results.
mysql-test/t/mysqldump.test@stripped, 2006-10-13 11:59:36-04:00, iggy@stripped +15 -0
Bug#19745: mysqldump --xml produces invalid xml
--Added test.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: iggy
# Host: rolltop.ignatz42.dyndns.org
# Root: /mnt/storeage/bug19745/my50-bug19745
--- 1.243/client/mysqldump.c 2006-10-13 11:59:45 -04:00
+++ 1.244/client/mysqldump.c 2006-10-13 11:59:45 -04:00
@@ -1123,7 +1123,7 @@ static char *quote_for_like(const char *
SYNOPSIS
print_quoted_xml()
- output - output file
+ xml_file - output file
str - string to print
len - its length
@@ -1271,6 +1271,31 @@ static void print_xml_row(FILE *xml_file
}
/*
+ Print hex value for blob data.
+
+ SYNOPSIS
+ print_blob_as_hex()
+ output_file - output file
+ use_xml_hex_grammar - TRUE to use XML hex grammar. FALSE otherwise.
+ str - string to print
+ len - its length
+
+ DESCRIPTION
+ Print hex value for blob data.
+*/
+
+static void print_blob_as_hex(FILE *output_file, my_bool use_xml_hex_grammar, const char *str, ulong len)
+{
+ /* sakaik got the idea to to provide blob's in hex notation. */
+ char *ptr= str, *end= ptr + len;
+ if (!use_xml_hex_grammar)
+ fputs("0x", output_file);
+ for (; ptr < end ; ptr++)
+ fprintf(output_file, "%02X", *((uchar *)ptr));
+ check_io(output_file);
+}
+
+/*
dump_routines_for_db
-- retrievs list of routines for a given db, and prints out
the CREATE PROCEDURE definition into the output (the dump).
@@ -2338,7 +2363,7 @@ static void dump_table(char *table, char
field->type == MYSQL_TYPE_LONG_BLOB ||
field->type == MYSQL_TYPE_MEDIUM_BLOB ||
field->type == MYSQL_TYPE_TINY_BLOB)) ? 1 : 0;
- if (extended_insert)
+ if (extended_insert && !opt_xml)
{
if (i == 0)
dynstr_set(&extended_row,"(");
@@ -2429,17 +2454,14 @@ static void dump_table(char *table, char
{
print_xml_tag1(md_result_file, "\t\t", "field name=",
field->name, "");
- print_quoted_xml(md_result_file, row[i], length);
+ if (opt_hex_blob && is_blob && length)
+ print_blob_as_hex(md_result_file, TRUE, row[i], length);
+ else
+ print_quoted_xml(md_result_file, row[i], length);
fputs("</field>\n", md_result_file);
}
else if (opt_hex_blob && is_blob && length)
- {
- /* sakaik got the idea to to provide blob's in hex notation. */
- char *ptr= row[i], *end= ptr + length;
- fputs("0x", md_result_file);
- for (; ptr < end ; ptr++)
- fprintf(md_result_file, "%02X", *((uchar *)ptr));
- }
+ print_blob_as_hex(md_result_file, FALSE, row[i], length);
else
unescape(md_result_file, row[i], length);
}
--- 1.116/mysql-test/r/mysqldump.result 2006-10-13 11:59:45 -04:00
+++ 1.117/mysql-test/r/mysqldump.result 2006-10-13 11:59:45 -04:00
@@ -3196,5 +3196,27 @@ UNLOCK TABLES;
DROP TABLE `t1`;
#
+# Bug #19745: mysqldump --xml produces invalid xml
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (f1 int(10), data MEDIUMBLOB);
+INSERT INTO t1 VALUES(1,0xff00fef0);
+<?xml version="1.0"?>
+<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<database name="test">
+ <table_structure name="t1">
+ <field Field="f1" Type="int(10)" Null="YES" Key="" Extra="" />
+ <field Field="data" Type="mediumblob" Null="YES" Key="" Extra="" />
+ </table_structure>
+ <table_data name="t1">
+ <row>
+ <field name="f1">1</field>
+ <field name="data">FF00FEF0</field>
+ </row>
+ </table_data>
+</database>
+</mysqldump>
+DROP TABLE t1;
+#
# End of 5.0 tests
#
--- 1.105/mysql-test/t/mysqldump.test 2006-10-13 11:59:45 -04:00
+++ 1.106/mysql-test/t/mysqldump.test 2006-10-13 11:59:45 -04:00
@@ -1413,5 +1413,20 @@ DROP TABLE `t1`;
--enable_warnings
--echo #
+--echo # Bug #19745: mysqldump --xml produces invalid xml
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (f1 int(10), data MEDIUMBLOB);
+INSERT INTO t1 VALUES(1,0xff00fef0);
+
+--exec $MYSQL_DUMP --xml --hex-blob --skip-create-options test t1
+
+DROP TABLE t1;
+
+--echo #
--echo # End of 5.0 tests
--echo #
| Thread |
|---|
| • bk commit into 5.0 tree (iggy:1.2295) BUG#19745 | Ignacio Galarza | 13 Oct |