Bug#21263 mysql client XML output does not distinguish between NULL and string 'NULL'

  
  Fix: "mysql --xml" now print NULL values the same way that "mysqldump --xml" does:
  
    <field name="name" xsi:nil="true" />
  
  to distinguish from empty strings:
  
    <field name="name"></field>
  
  and from string "NULL":
  
    <field name="name">NULL</field>
parent 53dea283
...@@ -2509,9 +2509,14 @@ print_table_data_xml(MYSQL_RES *result) ...@@ -2509,9 +2509,14 @@ print_table_data_xml(MYSQL_RES *result)
{ {
tee_fprintf(PAGER, "\t<field name=\""); tee_fprintf(PAGER, "\t<field name=\"");
xmlencode_print(fields[i].name, (uint) strlen(fields[i].name)); xmlencode_print(fields[i].name, (uint) strlen(fields[i].name));
tee_fprintf(PAGER, "\">"); if (cur[i])
xmlencode_print(cur[i], lengths[i]); {
tee_fprintf(PAGER, "</field>\n"); tee_fprintf(PAGER, "\">");
xmlencode_print(cur[i], lengths[i]);
tee_fprintf(PAGER, "</field>\n");
}
else
tee_fprintf(PAGER, "\" xsi:nil=\"true\" />\n");
} }
(void) tee_fputs(" </row>\n", PAGER); (void) tee_fputs(" </row>\n", PAGER);
} }
......
...@@ -68,7 +68,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); ...@@ -68,7 +68,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
<resultset statement="select null from dual <resultset statement="select null from dual
"> ">
<row> <row>
<field name="NULL">NULL</field> <field name="NULL" xsi:nil="true" />
</row> </row>
</resultset> </resultset>
drop table t1; drop table t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment