1
0
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:
unknown
2005-01-25 14:25:40 -08:00
parent 4bb1c716e8
commit d8f3934148
3 changed files with 99 additions and 6 deletions

View File

@ -154,6 +154,8 @@ static char mysql_charsets_dir[FN_REFLEN+1];
static const char *xmlmeta[] = {
"&", "&amp;",
"<", "&lt;",
">", "&gt;",
"\"", "&quot;",
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 :
" &nbsp; ") : "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 :
" &nbsp; ") : "NULL"));
tee_fprintf(PAGER, "</field>\n");
}
(void) tee_fputs(" </row>\n", PAGER);
}