mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Change 'mysql' client to output XML like the 'mysqldump'
tool does, with the column names as attributes on <field> elements, instead of trying to use the column name as the element name. Also fix some encoding issues. (Bug #7811) client/mysql.cc: Quote > and " in XML output, and use <field name="XXX"></field> instead of <XXX></XXX>, to make the output more like mysqldump --xml and avoid having to turn XXX into a sensible element name.
This commit is contained in:
@ -154,6 +154,8 @@ static char mysql_charsets_dir[FN_REFLEN+1];
|
||||
static const char *xmlmeta[] = {
|
||||
"&", "&",
|
||||
"<", "<",
|
||||
">", ">",
|
||||
"\"", """,
|
||||
0, 0
|
||||
};
|
||||
static const char *day_names[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
|
||||
@ -2116,13 +2118,11 @@ print_table_data_xml(MYSQL_RES *result)
|
||||
(void) tee_fputs("\n <row>\n", PAGER);
|
||||
for (uint i=0; i < mysql_num_fields(result); i++)
|
||||
{
|
||||
tee_fprintf(PAGER, "\t<%s>", (fields[i].name ?
|
||||
(fields[i].name[0] ? fields[i].name :
|
||||
" ") : "NULL"));
|
||||
tee_fprintf(PAGER, "\t<field name=\"");
|
||||
xmlencode_print(fields[i].name, strlen(fields[i].name));
|
||||
tee_fprintf(PAGER, "\">");
|
||||
xmlencode_print(cur[i], lengths[i]);
|
||||
tee_fprintf(PAGER, "</%s>\n", (fields[i].name ?
|
||||
(fields[i].name[0] ? fields[i].name :
|
||||
" ") : "NULL"));
|
||||
tee_fprintf(PAGER, "</field>\n");
|
||||
}
|
||||
(void) tee_fputs(" </row>\n", PAGER);
|
||||
}
|
||||
|
Reference in New Issue
Block a user