From: Date: June 22 2005 8:22pm Subject: bk commit into 4.1 tree (msvensson:1.2303) BUG#9657 List-Archive: http://lists.mysql.com/internals/26333 X-Bug: 9657 Message-Id: <20050622182258.6DC5C25DF7F@blaudden.homeip.net> Below is the list of changes that have just been committed into a local 4.1 repository of msvensson. When msvensson 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 1.2303 05/06/22 20:22:54 msvensson@neptunus.(none) +3 -0 BUG#9657 mysqldump xml ( -x ) does not format NULL fields correctly - Importing the bug fixes by patch due to merge problems. mysql-test/t/mysqldump.test 1.36 05/06/22 20:19:40 msvensson@neptunus.(none)[msvensson] +13 -0 Import patch patch mysql-test/r/mysqldump.result 1.48 05/06/22 20:21:33 msvensson@neptunus.(none)[msvensson] +59 -3 Import patch patch client/mysqldump.c 1.190 05/06/22 20:15:06 msvensson@neptunus.(none)[msvensson] +46 -2 Import patch patch # 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: msvensson # Host: neptunus.(none) # Root: /home/msvensson/mysql/mysql-4.1 --- 1.189/client/mysqldump.c 2005-06-21 14:17:35 +02:00 +++ 1.190/client/mysqldump.c 2005-06-22 20:15:06 +02:00 @@ -463,7 +463,10 @@ if (opt_xml) { fputs("\n", sql_file); - fputs("\n", sql_file); + fputs("\n", sql_file); check_io(sql_file); } else if (!opt_compact) @@ -1051,6 +1054,40 @@ /* + 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: + + 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. SYNOPSIS @@ -1870,7 +1907,14 @@ } } else - fputs("NULL", md_result_file); + { + /* 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); } } --- 1.47/mysql-test/r/mysqldump.result 2005-06-21 14:17:35 +02:00 +++ 1.48/mysql-test/r/mysqldump.result 2005-06-22 20:21:33 +02:00 @@ -2,7 +2,7 @@ CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2); - + @@ -103,7 +103,7 @@ CREATE TABLE t1(a int, b text, c varchar(3)); INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES"); - + @@ -128,7 +128,7 @@ CREATE TABLE t1 (`a"b"` char(2)); INSERT INTO t1 VALUES ("1\""), ("\"2"); - + @@ -1436,3 +1436,59 @@ 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"); + + + + + + + + + 10 + + + 20 + + + + + 1 + + + + + + + + 2 + 10 + + + + + + + 3 + + twenty + + + + + + 4 + 30 + thirty + + + + + + + +drop table t1, t2; --- 1.35/mysql-test/t/mysqldump.test 2005-06-21 14:17:35 +02:00 +++ 1.36/mysql-test/t/mysqldump.test 2005-06-22 20:19:40 +02:00 @@ -636,3 +636,16 @@ 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; +