Loading client/mysqldump.c +46 −2 Original line number Diff line number Diff line Loading @@ -463,7 +463,10 @@ static void write_header(FILE *sql_file, char *db_name) if (opt_xml) { fputs("<?xml version=\"1.0\"?>\n", sql_file); fputs("<mysqldump>\n", sql_file); fputs("<mysqldump ", sql_file); fputs("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", sql_file); fputs(">\n", sql_file); check_io(sql_file); } else if (!opt_compact) Loading Loading @@ -1050,6 +1053,40 @@ static void print_xml_tag1(FILE * xml_file, const char* sbeg, } /* Print xml tag with for a field that is null SYNOPSIS print_xml_null_tag() xml_file - output file sbeg - line beginning stag_atr - tag and attribute sval - value of attribute send - line ending DESCRIPTION Print tag with one attribute to the xml_file. Format is: <stag_atr="sval" xsi:nil="true"/> NOTE sval MUST be a NULL terminated string. sval string will be qouted before output. */ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, const char* stag_atr, const char* sval, const char* send) { fputs(sbeg, xml_file); fputs("<", xml_file); fputs(stag_atr, xml_file); fputs("\"", xml_file); print_quoted_xml(xml_file, sval, strlen(sval)); fputs("\" xsi:nil=\"true\" />", xml_file); fputs(send, xml_file); check_io(xml_file); } /* Print xml tag with many attributes. Loading Loading @@ -1870,7 +1907,14 @@ static void dumpTable(uint numFields, char *table) } } else { /* The field value is NULL */ if (!opt_xml) fputs("NULL", md_result_file); else print_xml_null_tag(md_result_file, "\t\t", "field name=", field->name, "\n"); } check_io(md_result_file); } } Loading mysql-test/r/mysqldump.result +59 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ DROP TABLE IF EXISTS t1, `"t"1`; CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2); <?xml version="1.0"?> <mysqldump> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_structure name="t1"> <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" /> Loading Loading @@ -103,7 +103,7 @@ DROP TABLE t1; CREATE TABLE t1(a int, b text, c varchar(3)); INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES"); <?xml version="1.0"?> <mysqldump> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_structure name="t1"> <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" /> Loading @@ -128,7 +128,7 @@ DROP TABLE t1; CREATE TABLE t1 (`a"b"` char(2)); INSERT INTO t1 VALUES ("1\""), ("\"2"); <?xml version="1.0"?> <mysqldump> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_structure name="t1"> <field Field="a"b"" Type="char(2)" Null="YES" Key="" Extra="" /> Loading Loading @@ -1436,3 +1436,59 @@ MYSQL_DUMP_DIR: Got error: 1049: Unknown database 'mysqldump_test_d' when select MYSQL_DUMP_DIR: Got error: 1102: Incorrect database name 'mysqld\ump_test_db' when selecting the database drop table t1, t2, t3; drop database mysqldump_test_db; create table t1 (a int(10)); create table t2 (pk int primary key auto_increment, a int(10), b varchar(30), c datetime, d blob, e text); insert into t1 values (NULL), (10), (20); insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thirty"); <?xml version="1.0"?> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_data name="t1"> <row> <field name="a" xsi:nil="true" /> </row> <row> <field name="a">10</field> </row> <row> <field name="a">20</field> </row> </table_data> <table_data name="t2"> <row> <field name="pk">1</field> <field name="a" xsi:nil="true" /> <field name="b" xsi:nil="true" /> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> <row> <field name="pk">2</field> <field name="a">10</field> <field name="b" xsi:nil="true" /> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> <row> <field name="pk">3</field> <field name="a" xsi:nil="true" /> <field name="b">twenty</field> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> <row> <field name="pk">4</field> <field name="a">30</field> <field name="b">thirty</field> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> </table_data> </database> </mysqldump> drop table t1, t2; mysql-test/t/mysqldump.test +13 −0 Original line number Diff line number Diff line Loading @@ -636,3 +636,16 @@ drop table t1, t2, t3; drop database mysqldump_test_db; # # Bug #9657 mysqldump xml ( -x ) does not format NULL fields correctly # create table t1 (a int(10)); create table t2 (pk int primary key auto_increment, a int(10), b varchar(30), c datetime, d blob, e text); insert into t1 values (NULL), (10), (20); insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thirty"); --exec $MYSQL_DUMP --skip-comments --xml --no-create-info test drop table t1, t2; Loading
client/mysqldump.c +46 −2 Original line number Diff line number Diff line Loading @@ -463,7 +463,10 @@ static void write_header(FILE *sql_file, char *db_name) if (opt_xml) { fputs("<?xml version=\"1.0\"?>\n", sql_file); fputs("<mysqldump>\n", sql_file); fputs("<mysqldump ", sql_file); fputs("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", sql_file); fputs(">\n", sql_file); check_io(sql_file); } else if (!opt_compact) Loading Loading @@ -1050,6 +1053,40 @@ static void print_xml_tag1(FILE * xml_file, const char* sbeg, } /* Print xml tag with for a field that is null SYNOPSIS print_xml_null_tag() xml_file - output file sbeg - line beginning stag_atr - tag and attribute sval - value of attribute send - line ending DESCRIPTION Print tag with one attribute to the xml_file. Format is: <stag_atr="sval" xsi:nil="true"/> NOTE sval MUST be a NULL terminated string. sval string will be qouted before output. */ static void print_xml_null_tag(FILE * xml_file, const char* sbeg, const char* stag_atr, const char* sval, const char* send) { fputs(sbeg, xml_file); fputs("<", xml_file); fputs(stag_atr, xml_file); fputs("\"", xml_file); print_quoted_xml(xml_file, sval, strlen(sval)); fputs("\" xsi:nil=\"true\" />", xml_file); fputs(send, xml_file); check_io(xml_file); } /* Print xml tag with many attributes. Loading Loading @@ -1870,7 +1907,14 @@ static void dumpTable(uint numFields, char *table) } } else { /* The field value is NULL */ if (!opt_xml) fputs("NULL", md_result_file); else print_xml_null_tag(md_result_file, "\t\t", "field name=", field->name, "\n"); } check_io(md_result_file); } } Loading
mysql-test/r/mysqldump.result +59 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ DROP TABLE IF EXISTS t1, `"t"1`; CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2); <?xml version="1.0"?> <mysqldump> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_structure name="t1"> <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" /> Loading Loading @@ -103,7 +103,7 @@ DROP TABLE t1; CREATE TABLE t1(a int, b text, c varchar(3)); INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES"); <?xml version="1.0"?> <mysqldump> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_structure name="t1"> <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" /> Loading @@ -128,7 +128,7 @@ DROP TABLE t1; CREATE TABLE t1 (`a"b"` char(2)); INSERT INTO t1 VALUES ("1\""), ("\"2"); <?xml version="1.0"?> <mysqldump> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_structure name="t1"> <field Field="a"b"" Type="char(2)" Null="YES" Key="" Extra="" /> Loading Loading @@ -1436,3 +1436,59 @@ MYSQL_DUMP_DIR: Got error: 1049: Unknown database 'mysqldump_test_d' when select MYSQL_DUMP_DIR: Got error: 1102: Incorrect database name 'mysqld\ump_test_db' when selecting the database drop table t1, t2, t3; drop database mysqldump_test_db; create table t1 (a int(10)); create table t2 (pk int primary key auto_increment, a int(10), b varchar(30), c datetime, d blob, e text); insert into t1 values (NULL), (10), (20); insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thirty"); <?xml version="1.0"?> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="test"> <table_data name="t1"> <row> <field name="a" xsi:nil="true" /> </row> <row> <field name="a">10</field> </row> <row> <field name="a">20</field> </row> </table_data> <table_data name="t2"> <row> <field name="pk">1</field> <field name="a" xsi:nil="true" /> <field name="b" xsi:nil="true" /> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> <row> <field name="pk">2</field> <field name="a">10</field> <field name="b" xsi:nil="true" /> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> <row> <field name="pk">3</field> <field name="a" xsi:nil="true" /> <field name="b">twenty</field> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> <row> <field name="pk">4</field> <field name="a">30</field> <field name="b">thirty</field> <field name="c" xsi:nil="true" /> <field name="d" xsi:nil="true" /> <field name="e" xsi:nil="true" /> </row> </table_data> </database> </mysqldump> drop table t1, t2;
mysql-test/t/mysqldump.test +13 −0 Original line number Diff line number Diff line Loading @@ -636,3 +636,16 @@ drop table t1, t2, t3; drop database mysqldump_test_db; # # Bug #9657 mysqldump xml ( -x ) does not format NULL fields correctly # create table t1 (a int(10)); create table t2 (pk int primary key auto_increment, a int(10), b varchar(30), c datetime, d blob, e text); insert into t1 values (NULL), (10), (20); insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thirty"); --exec $MYSQL_DUMP --skip-comments --xml --no-create-info test drop table t1, t2;