1--echo #
2--echo # Bug#20262654 INNODB: MYSQL IS TRYING TO PERFORM A CONSISTENT READ
3--echo #              BUT THE READ VIEW IS NOT AS
4--echo #
5
6set sql_mode="";
7create table t1(a int)engine=innodb;
8create table t2(b int)engine=innodb;
9
10delimiter $;
11create procedure p1()
12begin
13  declare counter integer default 0;
14  declare continue handler for sqlexception begin set counter = counter + 10;end;
15  repeat
16    if rand()>0.5 then start transaction; end if;
17    if rand()>0.5 then
18      select var_samp(1), exists(select 1 from t1 lock in share mode)
19      from t1 into @a,@b;
20    end if;
21    if rand()>0.5 then
22      select var_samp(1), exists(select 1 from t1 for update)
23      from t1 into @a,@b;
24    end if;
25    if rand()>0.5 then insert ignore into t1 values (); end if;
26    if rand()>0.5 then insert ignore into t2 values (); end if;
27    if rand()>0.5 then delete from t1; end if;
28    if rand()>0.5 then delete from t2; end if;
29    if rand()>0.5 then commit; end if;
30    set counter = counter + 1;
31  until counter >= 100 end repeat;
32end $
33delimiter ;$
34
35--enable_connect_log
36--connect(con1, localhost, root)
37--disable_result_log
38--send call p1();   # run this in two connections!
39--connection default
40call p1();
41--connection con1
42--echo reap
43--reap
44--echo reap done
45--disconnect con1
46--source include/wait_until_disconnected.inc
47--enable_result_log
48--connection default
49--disable_connect_log
50
51drop procedure p1;
52drop table t1,t2;
53
54set sql_mode=default;
55