Commit 9c979676 authored by aelkin/elkin@koti.dsl.inet.fi's avatar aelkin/elkin@koti.dsl.inet.fi
Browse files

Merge aelkin@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl

into  koti.dsl.inet.fi:/home/elkin/MySQL/TEAM/FIXES/5.0/bug28597-log_name_upgrade
parents 27636d56 a179cf15
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -9,4 +9,44 @@ insert into t2 values (null, null), (null, get_lock("a", 10));
select @result /* must be zero either way */;
@result
0
select RELEASE_LOCK("a");
RELEASE_LOCK("a")
1
delete from t1;
delete from t2;
insert into t1 values (1,1),(2,2);
begin;
update t1 set b=11 where a=2;
update t1 set b=b+10;
kill query ID;
rollback;
select * from t1  order by a /* must be the same as before (1,1),(2,2) */;
a	b
1	1
2	2
begin;
delete from t1 where a=2;
delete from t1 where a=2;
kill query ID;
rollback;
select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
a	b
1	1
2	2
drop table if exists t4;
create table t4 (a int, b int) engine=innodb;
insert into t4 values (3, 3);
begin;
insert into t1 values (3, 3);
begin;
insert into t1 select * from t4 for update;
kill query ID;
rollback;
rollback;
select * from t1 /* must be the same as before (1,1),(2,2) */;
a	b
1	1
2	2
drop table t4;
drop table t1,t2,t3;
end of the tests
+33 −0
Original line number Diff line number Diff line
drop table if exists t1,t2;
create table t1  (a int) engine=MyISAM;
insert into t1 set a=1;
reset master;
update t1 set a=2 /* will be "killed" after work has been done */;
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null
1
select 1 /* must return 1 as query completed before got killed*/;
1
1
create table t2 (a int, b int) ENGINE=MyISAM;
reset master;
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2 /* will be "killed" in the middle */;
ERROR 70100: Query execution was interrupted
show binlog events from 98;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	98	Begin_load_query	1	#	;file_id=1;block_len=12
master-bin.000001	133	Execute_load_query	1	#	use `test`; load data infile '../std_data_ln/rpl_loaddata.dat' into table t2 /* will be "killed" in the middle */ ;file_id=1
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null
1
select 0 /* must return 0 to mean the killed query is in */;
0
0
drop table t1,t2;
end of the tests
+93 −140
Original line number Diff line number Diff line
@@ -55,194 +55,147 @@ enable_result_log;

select @result /* must be zero either way */;

# the functions are either *insensitive* to killing or killing can cause
# strange problmes with the error propagation out of SF's stack
#  Bug#27563, Bug#27565, BUG#24971
#
# TODO: use if's block as regression test for the bugs or remove
#
if (0)
{
delimiter |;
create function bug27563() 
RETURNS int(11)
DETERMINISTIC
begin
  select get_lock("a", 10)  into @a;
  return 1;
end|
delimiter ;|

# the function is sensitive to killing requiring innodb though with wrong client error 
# TO FIX in BUG#27565; TODO: remove --error 1105 afterwards
delimiter |;
create function bug27565() 
RETURNS int(11)
DETERMINISTIC
begin
  select a from t1 where a=1  into @a for update;
  return 1;
end|
delimiter ;|

reset master;

--remove_file $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
connection con1;
select RELEASE_LOCK("a");

### ta table case: killing causes rollback
#
# bug#27571 asynchronous setting mysql_`query`::error and Query_log_e::error_code
#

# A. autocommit ON
connection con1;
select get_lock("a", 20);
# checking that killing inside of select loops is safe as before
# killing after the loop can be only simulated - another test

connection con2;
let $ID= `select connection_id()`;
send insert into t1 values (bug27563(),1);
delete from t1;
delete from t2;
insert into t1 values (1,1),(2,2);

#
# simple update
#
connection con1;
eval kill query $ID;
begin; update t1 set b=11 where a=2;

connection con2;
# todo (re-record test): after bugs 27563,27565 got fixed affected rows will report zero
--enable_info
# todo: remove 0 return after fixing Bug#27563
--error 0,ER_QUERY_INTERRUPTED
reap; ### pb: wrong error
--disable_info
###--replace_column 2 # 5 #
### show binlog events from 98 /* nothing in binlog unless Bug#27563 */;
show master status /* must be only FD event unless Bug#27563 */;
select count(*) from t1 /* must be zero unless Bug#27563 */;

# M. multi-statement-ta
connection con2;
let $ID= `select connection_id()`;
begin;
send insert into t1 values (bug27563(),1);
send update t1 set b=b+10;

connection con1;
--replace_result $ID ID
eval kill query $ID;
rollback;

connection con2;
# todo (re-record test): after bugs 27563,27565 got fixed affected rows will report zero
--enable_info
# todo: remove 0 return after fixing  Bug#27563
--error 0,ER_QUERY_INTERRUPTED
reap;
--disable_info
select count(*) from t1 /* must be zero unless Bug#27563 */;
commit;
select * from t1  order by a /* must be the same as before (1,1),(2,2) */;

#
# multi update
# commented out as Bug #31807 multi-update,delete killing does not report with ER_QUERY_INTERRUPTED
# in the way
#
# connection con1;
# begin; update t1 set b=b+10;

### non-ta table case: killing must be recorded in binlog
# connection con2;
# send update t1 as t_1,t1 as t_2 set t_1.b=11 where t_2.a=2;

reset master;
# connection con1;
# --replace_result $ID ID
# eval kill query $ID;
# rollback;

# disable_abort_on_error;

# connection con2;
# --error HY000,ER_QUERY_INTERRUPTED
# reap;
# select * from t1 /* must be the same as before (1,1),(2,2) */;

# enable_abort_on_error;
#
# simple delete
#
connection con1;
begin; delete from t1 where a=2;

connection con2;
let $ID= `select connection_id()`;
send insert into t2 values (bug27563(),1);
send delete from t1 where a=2;

connection con1;
--replace_result $ID ID
eval kill query $ID;
rollback;

connection con2;
# todo: remove 0 return after fixing  Bug#27563
--error 0,ER_QUERY_INTERRUPTED
reap;
select count(*) from t2 /* must be one */;
#show binlog events from 98 /* must have the insert on non-ta table */;
show master status  /* must have the insert event more to FD */;
# the value of the error flag of KILLED_QUERY is tested further

connection con1;
select RELEASE_LOCK("a");

### test with effective killing of SF()

delete from t1;
delete from t2;
insert into t1 values (1,1);
insert into t2 values (1,1);
select * from t1 order by a /* must be the same as before (1,1),(2,2) */;

#
# Bug#27565
# test where KILL is propagated as error to the top level
# still another bug with the error message to the user
# todo: fix reexecute the result file after fixing
# multi delete
# the same as for multi-update
#
begin; update t1 set b=0 where a=1;

connection con2;
let $ID= `select connection_id()`;
send update t2 set b=bug27565()-1 where a=1;
# connection con1;
# begin; delete from t1 where a=2;

connection con1;
eval kill query $ID;
commit;
# connection con2;
# send delete t1 from t1 where t1.a=2;

connection con2;
# todo: fix Bug #27565 killed query of SF() is not reported correctly and 
# remove 1105 (wrong)
#--error ER_QUERY_INTERRUPTED
--error 1105,ER_QUERY_INTERRUPTED
reap; ### pb: wrong error
select * from t1 /* must be: (1,0) */;
select * from t2 /* must be as before: (1,1) */;
# connection con1;
# --replace_result $ID ID
# eval kill query $ID;
# rollback;

## bug#22725 with effective and propagating killing
# connection con2;
# --error 0,ER_QUERY_INTERRUPTED
# reap;
# select * from t1 /* must be the same as before (1,1),(2,2) */;
#
# insert select
#
# top-level ta-table
connection con1;
delete from t3;
reset master;
begin; update t1 set b=0 where a=1;
--disable_warnings
drop table if exists t4;
--enable_warnings
create table t4 (a int, b int) engine=innodb;
insert into t4 values (3, 3);
begin; insert into t1 values (3, 3);

connection con2;
let $ID= `select connection_id()`;
# the query won't perform completely since the function gets interrupted
send insert into t3 values  (0,0),(1,bug27565());
begin;
send insert into t1 select * from t4 for update;

connection con1;
--replace_result $ID ID
eval kill query $ID;
rollback;

connection con2;
# todo: fix Bug #27565 killed query of SF() is not reported correctly and 
# remove 1105 (wrong)
#--error ER_QUERY_INTERRUPTED
--error 1105,ER_QUERY_INTERRUPTED
reap; ### pb: wrong error
select count(*) from t3 /* must be zero */;
show master status /* nothing in binlog */;

# top-level non-ta-table
connection con1;
delete from t2;
reset master;
begin;  update t1 set b=0 where a=1;

connection con2;
let $ID= `select connection_id()`;
# the query won't perform completely since the function gets intrurrupted
send insert into t2 values (0,0),(1,bug27565()) /* non-ta t2 */;

connection con1;
eval kill query $ID;
--error 0,ER_QUERY_INTERRUPTED
reap;
rollback;
select * from t1 /* must be the same as before (1,1),(2,2) */;

connection con2;
# todo: fix Bug #27565 killed query of SF() is not reported correctly and 
# remove 1105 (wrong)
#--error ER_QUERY_INTERRUPTED
--error 1105,ER_QUERY_INTERRUPTED
reap; ### pb: wrong error
drop table t4; # cleanup for the sub-case

select count(*) from t2    /* count must be one */;
show master status /* insert into non-ta must be in binlog */;
###
## non-ta table case: killing must be recorded in binlog
###

drop function bug27563;
drop function bug27565;
}
# In order to be deterministic the test needs INFORMATION_SCHEMA.PROCESSLIST
# which is not available on 5.0 at this time.
# Therefore, skip this part on 5.0.

system rm $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog ;

#
# common cleanup 
#

drop table t1,t2,t3;

--echo end of the tests
+1 −0
Original line number Diff line number Diff line
--loose-debug=d,simulate_kill_bug27571
+66 −0
Original line number Diff line number Diff line
-- source include/have_debug.inc
#
# bug#27571 asynchronous setting mysql_$query()'s local error and 
#           Query_log_event::error_code
#

--disable_warnings
drop table if exists t1,t2;
--enable_warnings

#
#  Checking that killing upon successful row-loop does not affect binlogging
#

create table t1  (a int) engine=MyISAM;
insert into t1 set a=1;
reset master;

update t1 set a=2 /* will be "killed" after work has been done */;

# a proof the query is binlogged with no error

--exec $MYSQL_BINLOG --start-position=98 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
let $error_code= `select @a like "%#%error_code=0%" /* must return 1 */`;
eval select $error_code /* must return 1 as query completed before got killed*/;

# cleanup for the sub-case
system rm $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog;


#
#  Checking that killing inside of row-loop for LOAD DATA into
#  non-transactional table affects binlogging
#

create table t2 (a int, b int) ENGINE=MyISAM;
reset master;
--error ER_QUERY_INTERRUPTED
load data infile '../std_data_ln/rpl_loaddata.dat' into table t2 /* will be "killed" in the middle */;


# a proof the query is binlogged with an error

source include/show_binlog_events.inc;

--exec $MYSQL_BINLOG --start-position=98 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval select
(@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
let $error_code= `select @a like "%#%error_code=0%" /* must return 0*/`;
eval select $error_code /* must return 0 to mean the killed query is in */;

# cleanup for the sub-case
system rm $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog;


drop table t1,t2;

--echo end of the tests
Loading