Loading client/mysql.cc +6 −6 Original line number Diff line number Diff line Loading @@ -155,6 +155,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"}; Loading Loading @@ -2126,13 +2128,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); } Loading mysql-test/r/client_xml.result 0 → 100644 +75 −0 Original line number Diff line number Diff line create table t1 ( `a&b` int, `a<b` int, `a>b` text ); insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select * from t1 "> <row> <field name="a&b">1</field> <field name="a<b">2</field> <field name="a>b">a&b a<b a>b</field> </row> </resultset> <?xml version="1.0"?> <mysqldump> <database name="test"> <table_structure name="t1"> <field Field="a&b" Type="int(11)" Null="YES" Key="" Extra="" /> <field Field="a<b" Type="int(11)" Null="YES" Key="" Extra="" /> <field Field="a>b" Type="text" Null="YES" Key="" Extra="" /> <options Name="t1" Engine="MyISAM" Version="9" Row_format="Dynamic" Rows="1" Avg_row_length="28" Data_length="28" Max_data_length="4294967295" Index_length="1024" Data_free="0" Create_time="2005-01-26 01:21:39" Update_time="2005-01-26 01:21:39" Collation="latin1_swedish_ci" Create_options="" Comment="" /> </table_structure> <table_data name="t1"> <row> <field name="a&b">1</field> <field name="a<b">2</field> <field name="a>b">a&b a<b a>b</field> </row> </table_data> </database> </mysqldump> <?xml version="1.0"?> <resultset statement="select count(*) from t1 "> <row> <field name="count(*)">1</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select 1 < 2 from dual "> <row> <field name="1 < 2">1</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select 1 > 2 from dual "> <row> <field name="1 > 2">0</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select 1 & 3 from dual "> <row> <field name="1 & 3">1</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select null from dual "> <row> <field name="NULL">NULL</field> </row> </resultset> drop table t1; mysql-test/t/client_xml.test 0 → 100644 +18 −0 Original line number Diff line number Diff line # Test of the xml output of the 'mysql' and 'mysqldump' clients -- makes # sure that basic encoding issues are handled properly create table t1 ( `a&b` int, `a<b` int, `a>b` text ); insert into t1 values (1, 2, 'a&b a<b a>b'); --exec $MYSQL --xml test -e 'select * from t1' --exec $MYSQL_DUMP --xml test --exec $MYSQL --xml test -e 'select count(*) from t1' --exec $MYSQL --xml test -e 'select 1 < 2 from dual' --exec $MYSQL --xml test -e 'select 1 > 2 from dual' --exec $MYSQL --xml test -e 'select 1 & 3 from dual' --exec $MYSQL --xml test -e 'select null from dual' drop table t1; Loading
client/mysql.cc +6 −6 Original line number Diff line number Diff line Loading @@ -155,6 +155,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"}; Loading Loading @@ -2126,13 +2128,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); } Loading
mysql-test/r/client_xml.result 0 → 100644 +75 −0 Original line number Diff line number Diff line create table t1 ( `a&b` int, `a<b` int, `a>b` text ); insert into t1 values (1, 2, 'a&b a<b a>b'); <?xml version="1.0"?> <resultset statement="select * from t1 "> <row> <field name="a&b">1</field> <field name="a<b">2</field> <field name="a>b">a&b a<b a>b</field> </row> </resultset> <?xml version="1.0"?> <mysqldump> <database name="test"> <table_structure name="t1"> <field Field="a&b" Type="int(11)" Null="YES" Key="" Extra="" /> <field Field="a<b" Type="int(11)" Null="YES" Key="" Extra="" /> <field Field="a>b" Type="text" Null="YES" Key="" Extra="" /> <options Name="t1" Engine="MyISAM" Version="9" Row_format="Dynamic" Rows="1" Avg_row_length="28" Data_length="28" Max_data_length="4294967295" Index_length="1024" Data_free="0" Create_time="2005-01-26 01:21:39" Update_time="2005-01-26 01:21:39" Collation="latin1_swedish_ci" Create_options="" Comment="" /> </table_structure> <table_data name="t1"> <row> <field name="a&b">1</field> <field name="a<b">2</field> <field name="a>b">a&b a<b a>b</field> </row> </table_data> </database> </mysqldump> <?xml version="1.0"?> <resultset statement="select count(*) from t1 "> <row> <field name="count(*)">1</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select 1 < 2 from dual "> <row> <field name="1 < 2">1</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select 1 > 2 from dual "> <row> <field name="1 > 2">0</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select 1 & 3 from dual "> <row> <field name="1 & 3">1</field> </row> </resultset> <?xml version="1.0"?> <resultset statement="select null from dual "> <row> <field name="NULL">NULL</field> </row> </resultset> drop table t1;
mysql-test/t/client_xml.test 0 → 100644 +18 −0 Original line number Diff line number Diff line # Test of the xml output of the 'mysql' and 'mysqldump' clients -- makes # sure that basic encoding issues are handled properly create table t1 ( `a&b` int, `a<b` int, `a>b` text ); insert into t1 values (1, 2, 'a&b a<b a>b'); --exec $MYSQL --xml test -e 'select * from t1' --exec $MYSQL_DUMP --xml test --exec $MYSQL --xml test -e 'select count(*) from t1' --exec $MYSQL --xml test -e 'select 1 < 2 from dual' --exec $MYSQL --xml test -e 'select 1 > 2 from dual' --exec $MYSQL --xml test -e 'select 1 & 3 from dual' --exec $MYSQL --xml test -e 'select null from dual' drop table t1;