| 1 |
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); |
| 2 |
create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; |
| 3 |
create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM; |
| 4 |
create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB; |
| 5 |
select get_lock("a", 20); |
| 6 |
get_lock("a", 20) |
| 7 |
1 |
| 8 |
reset master; |
| 9 |
insert into t2 values (null, null), (null, get_lock("a", 10)); |
| 10 |
kill query ID; |
| 11 |
select |
| 12 |
(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog")) |
| 13 |
is not null; |
| 14 |
set @result= 1 - 0 - 1; |
| 15 |
select @result /* must be zero either way */; |
| 16 |
@result |
| 17 |
0 |
| 18 |
select RELEASE_LOCK("a"); |
| 19 |
RELEASE_LOCK("a") |
| 20 |
1 |
| 21 |
delete from t1; |
| 22 |
delete from t2; |
| 23 |
insert into t1 values (1,1),(2,2); |
| 24 |
begin; |
| 25 |
update t1 set b=11 where a=2; |
| 26 |
begin; |
| 27 |
update t1 set b=b+10; |
| 28 |
kill query ID; |
| 29 |
rollback; |
| 30 |
rollback; |
| 31 |
select * from t1 order by a /* must be the same as before (1,1),(2,2) */; |
| 32 |
a b |
| 33 |
1 1 |
| 34 |
2 2 |
| 35 |
begin; |
| 36 |
delete from t1 where a=2; |
| 37 |
begin; |
| 38 |
delete from t1 where a=2; |
| 39 |
kill query ID; |
| 40 |
rollback; |
| 41 |
rollback; |
| 42 |
select * from t1 order by a /* must be the same as before (1,1),(2,2) */; |
| 43 |
a b |
| 44 |
1 1 |
| 45 |
2 2 |
| 46 |
drop table if exists t4; |
| 47 |
create table t4 (a int, b int) engine=innodb; |
| 48 |
insert into t4 values (3, 3); |
| 49 |
begin; |
| 50 |
insert into t1 values (3, 3); |
| 51 |
begin; |
| 52 |
insert into t1 select * from t4 for update; |
| 53 |
kill query ID; |
| 54 |
rollback; |
| 55 |
rollback; |
| 56 |
select * from t1 /* must be the same as before (1,1),(2,2) */; |
| 57 |
a b |
| 58 |
1 1 |
| 59 |
2 2 |
| 60 |
drop table t4; |
| 61 |
create table t4 (a int, b int) ENGINE=MyISAM /* for killing update and delete */; |
| 62 |
create function bug27563(n int) |
| 63 |
RETURNS int(11) |
| 64 |
DETERMINISTIC |
| 65 |
begin |
| 66 |
if @b > 0 then |
| 67 |
select get_lock("a", 20) into @a; |
| 68 |
else |
| 69 |
set @b= 1; |
| 70 |
end if; |
| 71 |
return n; |
| 72 |
end| |
| 73 |
Warnings: |
| 74 |
Warning 1681 Integer display width is deprecated and will be removed in a future release. |
| 75 |
delete from t4; |
| 76 |
insert into t4 values (1,1), (1,1); |
| 77 |
reset master; |
| 78 |
select get_lock("a", 20); |
| 79 |
get_lock("a", 20) |
| 80 |
1 |
| 81 |
set @b= 0; |
| 82 |
update t4 set b=b + bug27563(b); |
| 83 |
select count(*) FROM INFORMATION_SCHEMA.PROCESSLIST where state='User lock'; |
| 84 |
count(*) |
| 85 |
1 |
| 86 |
Warnings: |
| 87 |
Warning 1287 'INFORMATION_SCHEMA.PROCESSLIST' is deprecated and will be removed in a future release. Please use performance_schema.processlist instead |
| 88 |
kill query ID; |
| 89 |
ERROR 70100: Query execution was interrupted |
| 90 |
select * from t4 order by b /* must be (1,1), (1,2) */; |
| 91 |
a b |
| 92 |
1 1 |
| 93 |
1 2 |
| 94 |
select @b /* must be 1 at the end of a stmt calling bug27563() */; |
| 95 |
@b |
| 96 |
1 |
| 97 |
must have the update query event on the 4th line |
| 98 |
include/show_binlog_events.inc |
| 99 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 100 |
binlog.000001 # Query # # BEGIN |
| 101 |
binlog.000001 # User var # # @`b`=0 |
| 102 |
binlog.000001 # Query # # use `test`; update t4 set b=b + bug27563(b) |
| 103 |
binlog.000001 # Query # # COMMIT |
| 104 |
*** a proof the query is binlogged with an error *** |
| 105 |
select |
| 106 |
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) |
| 107 |
is not null AS Loaded; |
| 108 |
Loaded |
| 109 |
1 |
| 110 |
Warnings: |
| 111 |
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. |
| 112 |
select 0 /* must return 0 to mean the killed update is in */; |
| 113 |
0 |
| 114 |
0 |
| 115 |
select RELEASE_LOCK("a"); |
| 116 |
RELEASE_LOCK("a") |
| 117 |
1 |
| 118 |
delete from t4; |
| 119 |
insert into t4 values (1,1), (2,2); |
| 120 |
reset master; |
| 121 |
select get_lock("a", 20); |
| 122 |
get_lock("a", 20) |
| 123 |
1 |
| 124 |
set @b= 0; |
| 125 |
delete from t4 where b=bug27563(1) or b=bug27563(2); |
| 126 |
select count(*) FROM INFORMATION_SCHEMA.PROCESSLIST where state='User lock'; |
| 127 |
count(*) |
| 128 |
1 |
| 129 |
Warnings: |
| 130 |
Warning 1287 'INFORMATION_SCHEMA.PROCESSLIST' is deprecated and will be removed in a future release. Please use performance_schema.processlist instead |
| 131 |
kill query ID; |
| 132 |
ERROR 70100: Query execution was interrupted |
| 133 |
select count(*) from t4 /* must be 1 */; |
| 134 |
count(*) |
| 135 |
1 |
| 136 |
select @b /* must be 1 at the end of a stmt calling bug27563() */; |
| 137 |
@b |
| 138 |
1 |
| 139 |
must have the delete query event on the 4th line |
| 140 |
include/show_binlog_events.inc |
| 141 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 142 |
binlog.000001 # Query # # BEGIN |
| 143 |
binlog.000001 # User var # # @`b`=0 |
| 144 |
binlog.000001 # Query # # use `test`; delete from t4 where b=bug27563(1) or b=bug27563(2) |
| 145 |
binlog.000001 # Query # # COMMIT |
| 146 |
select |
| 147 |
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) |
| 148 |
is not null AS Loaded; |
| 149 |
Loaded |
| 150 |
1 |
| 151 |
Warnings: |
| 152 |
Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'. |
| 153 |
select 0 /* must return 0 to mean the killed delete is in */; |
| 154 |
0 |
| 155 |
0 |
| 156 |
select RELEASE_LOCK("a"); |
| 157 |
RELEASE_LOCK("a") |
| 158 |
1 |
| 159 |
drop table t4; |
| 160 |
drop function bug27563; |
| 161 |
drop table t1,t2,t3; |
| 162 |
end of the tests |