Commit 9faaec9e authored by bar@mysql.com's avatar bar@mysql.com

bug#27608 XML output is not well-formed

Problem: output was empty if the result is empty.
Fix: print XML header and footer, even if the result
is empty, to produce well-formed XML output.
parent cec17aa0
...@@ -2117,6 +2117,17 @@ com_go(String *buffer,char *line __attribute__((unused))) ...@@ -2117,6 +2117,17 @@ com_go(String *buffer,char *line __attribute__((unused)))
if (!mysql_num_rows(result) && ! quick && !info_flag) if (!mysql_num_rows(result) && ! quick && !info_flag)
{ {
strmov(buff, "Empty set"); strmov(buff, "Empty set");
if (opt_xml)
{
/*
We must print XML header and footer
to produce a well-formed XML even if
the result set is empty (Bug#27608).
*/
init_pager();
print_table_data_xml(result);
end_pager();
}
} }
else else
{ {
......
set autocommit=1;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; insert into bug16206 values(2)
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
show binlog events;
Log_name Pos Event_type Server_id End_log_pos Info
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
f n Query 1 n use `test`; insert into bug16206 values(0)
f n Query 1 n use `test`; insert into bug16206 values(1)
f n Query 1 n use `test`; BEGIN
f n Query 1 n use `test`; insert into bug16206 values(2)
f n Query 1 n use `test`; COMMIT
f n Query 1 n use `test`; insert into bug16206 values(3)
drop table bug16206;
set autocommit=0;
End of 5.0 tests
...@@ -71,4 +71,18 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); ...@@ -71,4 +71,18 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
<field name="NULL" xsi:nil="true" /> <field name="NULL" xsi:nil="true" />
</row> </row>
</resultset> </resultset>
<?xml version="1.0"?>
<resultset statement="select 1 limit 0
" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></resultset>
--------------
select 1 limit 0
--------------
<?xml version="1.0"?>
<resultset statement="select 1 limit 0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></resultset>
Empty set
Bye
drop table t1; drop table t1;
-- source include/not_embedded.inc
-- source include/have_bdb.inc
#
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
#
set autocommit=1;
let $VERSION=`select version()`;
reset master;
create table bug16206 (a int);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
reset master;
create table bug16206 (a int) engine= bdb;
insert into bug16206 values(0);
insert into bug16206 values(1);
start transaction;
insert into bug16206 values(2);
commit;
insert into bug16206 values(3);
--replace_result $VERSION VERSION
--replace_column 1 f 2 n 5 n
show binlog events;
drop table bug16206;
set autocommit=0;
--echo End of 5.0 tests
...@@ -17,5 +17,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b'); ...@@ -17,5 +17,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
--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 1 & 3 from dual"
--exec $MYSQL --xml test -e "select null from dual" --exec $MYSQL --xml test -e "select null from dual"
--exec $MYSQL --xml test -e "select 1 limit 0"
--exec $MYSQL --xml test -vv -e "select 1 limit 0"
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