summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2005-06-22 20:22:54 +0200
committerunknown <msvensson@neptunus.(none)>2005-06-22 20:22:54 +0200
commite5d0e337f8cabe2824dd324888bca22fd628b350 (patch)
treeb9cdaa151c2d83ee93fc17a7e2fa7fe0688d6b7c /client
parent19f51d3fa50e1ffda7e25eabc879b63627920a81 (diff)
downloadmariadb-git-e5d0e337f8cabe2824dd324888bca22fd628b350.tar.gz
BUG#9657 mysqldump xml ( -x ) does not format NULL fields correctly
- Importing the bug fixes by patch due to merge problems. client/mysqldump.c: Import patch patch mysql-test/r/mysqldump.result: Import patch patch mysql-test/t/mysqldump.test: Import patch patch
Diffstat (limited to 'client')
-rw-r--r--client/mysqldump.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 207235983da..f4116253f8f 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -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)
@@ -1051,6 +1054,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.
SYNOPSIS
@@ -1870,7 +1907,14 @@ static void dumpTable(uint numFields, char *table)
}
}
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);
}
}