bug#27571 asynchronous setting mysql_`query`::error and Query_log_e::error_code

refining tests as they appear to be non-deterministic.
parent 82a2cd5d
...@@ -17,8 +17,7 @@ update t1 set b=11 where a=2; ...@@ -17,8 +17,7 @@ update t1 set b=11 where a=2;
update t1 set b=b+10; update t1 set b=b+10;
kill query ID; kill query ID;
rollback; rollback;
ERROR 70100: Query execution was interrupted select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
select * from t1 /* must be the same as before (1,1),(2,2) */;
a b a b
1 1 1 1
2 2 2 2
...@@ -27,8 +26,7 @@ delete from t1 where a=2; ...@@ -27,8 +26,7 @@ delete from t1 where a=2;
delete from t1 where a=2; delete from t1 where a=2;
kill query ID; kill query ID;
rollback; rollback;
ERROR 70100: Query execution was interrupted select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
select * from t1 /* must be the same as before (1,1),(2,2) */;
a b a b
1 1 1 1
2 2 2 2
...@@ -41,39 +39,45 @@ begin; ...@@ -41,39 +39,45 @@ begin;
insert into t1 select * from t4 for update; insert into t1 select * from t4 for update;
kill query ID; kill query ID;
rollback; rollback;
ERROR 70100: Query execution was interrupted
rollback; rollback;
select * from t1 /* must be the same as before (1,1),(2,2) */; select * from t1 /* must be the same as before (1,1),(2,2) */;
a b a b
1 1 1 1
2 2 2 2
drop table t4; drop table t4;
create table t4 (a int, b int) ENGINE=MyISAM /* for killing update and delete */;
create function bug27563(n int) create function bug27563(n int)
RETURNS int(11) RETURNS int(11)
DETERMINISTIC DETERMINISTIC
begin begin
if n > 1 then if @b > 0 then
select get_lock("a", 10) into @a; select get_lock("a", 10) into @a;
else
set @b= 1;
end if; end if;
return n; return n;
end| end|
delete from t2; delete from t4;
insert into t2 values (1,1), (2,2); insert into t4 values (1,1), (1,1);
reset master; reset master;
select get_lock("a", 20); select get_lock("a", 20);
get_lock("a", 20) get_lock("a", 20)
1 1
update t2 set b=b + bug27563(b) order by a; set @b= 0;
update t4 set b=b + bug27563(b);
kill query ID; kill query ID;
ERROR 70100: Query execution was interrupted select * from t4 order by b /* must be (1,1), (1,2) */;
select * from t2 /* must be (1,2), (2,2) */;
a b a b
1 1
1 2 1 2
2 2 select @b /* must be 1 at the end of a stmt calling bug27563() */;
must have the update event more to FD @b
1
must have the update query event more to FD
show binlog events from <binlog_start>; show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; update t2 set b=b + bug27563(b) order by a master-bin.000001 # User var # # @`b`=0
master-bin.000001 # Query # # use `test`; update t4 set b=b + bug27563(b)
select select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null; is not null;
...@@ -86,22 +90,26 @@ select 0 /* must return 0 to mean the killed query is in */; ...@@ -86,22 +90,26 @@ select 0 /* must return 0 to mean the killed query is in */;
select RELEASE_LOCK("a"); select RELEASE_LOCK("a");
RELEASE_LOCK("a") RELEASE_LOCK("a")
1 1
delete from t2; delete from t4;
insert into t2 values (1,1), (2,2); insert into t4 values (1,1), (2,2);
reset master; reset master;
select get_lock("a", 20); select get_lock("a", 20);
get_lock("a", 20) get_lock("a", 20)
1 1
delete from t2 where a=1 or a=bug27563(2) order by a; set @b= 0;
delete from t4 where b=bug27563(1) or b=bug27563(2);
kill query ID; kill query ID;
ERROR 70100: Query execution was interrupted select count(*) from t4 /* must be 1 */;
select * from t2 /* must be (1,2), (2,2) */; count(*)
a b 1
1 1 select @b /* must be 1 at the end of a stmt calling bug27563() */;
2 2 @b
must have the update event more to FD 1
must have the delete query event more to FD
show binlog events from <binlog_start>; show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # User var # # @`b`=0
master-bin.000001 # Query # # use `test`; delete from t4 where b=bug27563(1) or b=bug27563(2)
select select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) (@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null; is not null;
...@@ -114,6 +122,7 @@ select 0 /* must return 0 to mean the killed query is in */; ...@@ -114,6 +122,7 @@ select 0 /* must return 0 to mean the killed query is in */;
select RELEASE_LOCK("a"); select RELEASE_LOCK("a");
RELEASE_LOCK("a") RELEASE_LOCK("a")
1 1
drop table t4;
drop function bug27563; drop function bug27563;
drop table t1,t2,t3; drop table t1,t2,t3;
end of the tests end of the tests
...@@ -68,7 +68,6 @@ select @result /* must be zero either way */; ...@@ -68,7 +68,6 @@ select @result /* must be zero either way */;
delete from t1; delete from t1;
delete from t2; delete from t2;
insert into t1 values (1,1),(2,2); insert into t1 values (1,1),(2,2);
let $ID= `select connection_id()`;
# #
# simple update # simple update
...@@ -77,6 +76,7 @@ connection con1; ...@@ -77,6 +76,7 @@ connection con1;
begin; update t1 set b=11 where a=2; begin; update t1 set b=11 where a=2;
connection con2; connection con2;
let $ID= `select connection_id()`;
send update t1 set b=b+10; send update t1 set b=b+10;
connection con1; connection con1;
...@@ -85,9 +85,9 @@ eval kill query $ID; ...@@ -85,9 +85,9 @@ eval kill query $ID;
rollback; rollback;
connection con2; connection con2;
--error ER_QUERY_INTERRUPTED --error 0,ER_QUERY_INTERRUPTED
reap; reap;
select * from t1 /* must be the same as before (1,1),(2,2) */; select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
# #
# multi update # multi update
...@@ -120,6 +120,7 @@ connection con1; ...@@ -120,6 +120,7 @@ connection con1;
begin; delete from t1 where a=2; begin; delete from t1 where a=2;
connection con2; connection con2;
let $ID= `select connection_id()`;
send delete from t1 where a=2; send delete from t1 where a=2;
connection con1; connection con1;
...@@ -128,9 +129,9 @@ eval kill query $ID; ...@@ -128,9 +129,9 @@ eval kill query $ID;
rollback; rollback;
connection con2; connection con2;
--error ER_QUERY_INTERRUPTED --error 0,ER_QUERY_INTERRUPTED
reap; reap;
select * from t1 /* must be the same as before (1,1),(2,2) */; select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
# #
# multi delete # multi delete
...@@ -163,6 +164,7 @@ insert into t4 values (3, 3); ...@@ -163,6 +164,7 @@ insert into t4 values (3, 3);
begin; insert into t1 values (3, 3); begin; insert into t1 values (3, 3);
connection con2; connection con2;
let $ID= `select connection_id()`;
begin; begin;
send insert into t1 select * from t4 for update; send insert into t1 select * from t4 for update;
...@@ -172,7 +174,7 @@ eval kill query $ID; ...@@ -172,7 +174,7 @@ eval kill query $ID;
rollback; rollback;
connection con2; connection con2;
--error ER_QUERY_INTERRUPTED --error 0,ER_QUERY_INTERRUPTED
reap; reap;
rollback; rollback;
select * from t1 /* must be the same as before (1,1),(2,2) */; select * from t1 /* must be the same as before (1,1),(2,2) */;
...@@ -182,13 +184,17 @@ drop table t4; # cleanup for the sub-case ...@@ -182,13 +184,17 @@ drop table t4; # cleanup for the sub-case
### ###
## non-ta table case: killing must be recorded in binlog ## non-ta table case: killing must be recorded in binlog
### ###
create table t4 (a int, b int) ENGINE=MyISAM /* for killing update and delete */;
delimiter |; delimiter |;
create function bug27563(n int) create function bug27563(n int)
RETURNS int(11) RETURNS int(11)
DETERMINISTIC DETERMINISTIC
begin begin
if n > 1 then if @b > 0 then
select get_lock("a", 10) into @a; select get_lock("a", 10) into @a;
else
set @b= 1;
end if; end if;
return n; return n;
end| end|
...@@ -198,25 +204,27 @@ delimiter ;| ...@@ -198,25 +204,27 @@ delimiter ;|
# update # update
# #
delete from t2; delete from t4;
insert into t2 values (1,1), (2,2); insert into t4 values (1,1), (1,1);
reset master; reset master;
connection con1; connection con1;
select get_lock("a", 20); select get_lock("a", 20);
connection con2; connection con2;
let $ID= `select connection_id()`; let $ID= `select connection_id()`;
send update t2 set b=b + bug27563(b) order by a; set @b= 0;
send update t4 set b=b + bug27563(b);
connection con1; connection con1;
--replace_result $ID ID --replace_result $ID ID
eval kill query $ID; eval kill query $ID;
connection con2; connection con2;
--error ER_QUERY_INTERRUPTED --error 0,ER_QUERY_INTERRUPTED
reap; reap;
select * from t2 /* must be (1,2), (2,2) */; select * from t4 order by b /* must be (1,1), (1,2) */;
--echo must have the update event more to FD select @b /* must be 1 at the end of a stmt calling bug27563() */;
--echo must have the update query event more to FD
source include/show_binlog_events.inc; source include/show_binlog_events.inc;
# a proof the query is binlogged with an error # a proof the query is binlogged with an error
...@@ -239,25 +247,27 @@ select RELEASE_LOCK("a"); ...@@ -239,25 +247,27 @@ select RELEASE_LOCK("a");
# delete # delete
# #
delete from t2; delete from t4;
insert into t2 values (1,1), (2,2); insert into t4 values (1,1), (2,2);
reset master; reset master;
connection con1; connection con1;
select get_lock("a", 20); select get_lock("a", 20);
connection con2; connection con2;
let $ID= `select connection_id()`; let $ID= `select connection_id()`;
send delete from t2 where a=1 or a=bug27563(2) order by a; set @b= 0;
send delete from t4 where b=bug27563(1) or b=bug27563(2);
connection con1; connection con1;
--replace_result $ID ID --replace_result $ID ID
eval kill query $ID; eval kill query $ID;
connection con2; connection con2;
--error ER_QUERY_INTERRUPTED --error 0,ER_QUERY_INTERRUPTED
reap; reap;
select * from t2 /* must be (1,2), (2,2) */; select count(*) from t4 /* must be 1 */;
--echo must have the update event more to FD select @b /* must be 1 at the end of a stmt calling bug27563() */;
--echo must have the delete query event more to FD
source include/show_binlog_events.inc; source include/show_binlog_events.inc;
# a proof the query is binlogged with an error # a proof the query is binlogged with an error
...@@ -276,6 +286,8 @@ connection con1; ...@@ -276,6 +286,8 @@ connection con1;
select RELEASE_LOCK("a"); select RELEASE_LOCK("a");
--remove_file $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog --remove_file $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
drop table t4;
# #
# load data - see simulation tests # load data - see simulation tests
# #
......
-- source include/have_debug.inc
-- source include/have_binlog_format_mixed_or_statement.inc -- source include/have_binlog_format_mixed_or_statement.inc
# #
# bug#27571 asynchronous setting mysql_$query()'s local error and # bug#27571 asynchronous setting mysql_$query()'s local error and
......
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