| 1 |
# Adding big test option for this test. |
| 2 |
--source include/big_test.inc |
| 3 |
|
| 4 |
# |
| 5 |
# create test-bed to run test |
| 6 |
# |
| 7 |
use test; |
| 8 |
--disable_warnings |
| 9 |
drop table if exists t1; |
| 10 |
--enable_warnings |
| 11 |
create table t1 (id int primary key, value int, value2 int, |
| 12 |
value3 int, index(value,value2)) engine=innodb; |
| 13 |
|
| 14 |
insert into t1 values |
| 15 |
(10,10,10,10),(11,11,11,11),(12,12,12,12),(13,13,13,13),(14,14,14,14), |
| 16 |
(15,15,15,15),(16,16,16,16),(17,17,17,17),(18,18,18,18),(19,19,19,19), |
| 17 |
(20,20,20,20); |
| 18 |
let $ID= `SELECT @id := CONNECTION_ID()`; |
| 19 |
|
| 20 |
# |
| 21 |
# we need multiple connections as we need to keep one connection |
| 22 |
# active with trx requesting consistent read. |
| 23 |
# |
| 24 |
connect (conn1, localhost, root,,); |
| 25 |
connect (conn2, localhost, root,,); |
| 26 |
connect (conn3, localhost, root,,); |
| 27 |
|
| 28 |
# |
| 29 |
# start trx with consistent read |
| 30 |
# |
| 31 |
connection conn1; |
| 32 |
use test; |
| 33 |
|
| 34 |
start transaction with consistent snapshot; |
| 35 |
|
| 36 |
# |
| 37 |
# update table such that secondary index is updated. |
| 38 |
# |
| 39 |
connection conn2; |
| 40 |
use test; |
| 41 |
delimiter |; |
| 42 |
CREATE PROCEDURE update_t1() |
| 43 |
BEGIN |
| 44 |
DECLARE i INT DEFAULT 1; |
| 45 |
while (i <= 28000) DO |
| 46 |
update test.t1 set value2=value2+1, value3=value3+1 where id=12; |
| 47 |
SET i = i + 1; |
| 48 |
END WHILE; |
| 49 |
END| |
| 50 |
|
| 51 |
delimiter ;| |
| 52 |
set autocommit=0; |
| 53 |
CALL update_t1(); |
| 54 |
select * from t1; |
| 55 |
set autocommit=1; |
| 56 |
select * from t1; |
| 57 |
|
| 58 |
# |
| 59 |
# Now try to fire select query from connection-1 enforcing |
| 60 |
# use of secondary index. |
| 61 |
# |
| 62 |
connection conn1; |
| 63 |
let $ID= `SELECT @id := CONNECTION_ID()`; |
| 64 |
#--error ER_QUERY_INTERRUPTED |
| 65 |
--send |
| 66 |
select * from t1 force index(value) where value=12; |
| 67 |
|
| 68 |
# |
| 69 |
# select is going to take good time so let's kill query. |
| 70 |
# |
| 71 |
connection conn3; |
| 72 |
let $wait_condition= |
| 73 |
select * from information_schema.processlist where state = 'executing' and |
| 74 |
info = 'select * from t1 force index(value) where value=12'; |
| 75 |
--source include/wait_condition.inc |
| 76 |
let $ignore= `SELECT @id := $ID`; |
| 77 |
kill query @id; |
| 78 |
|
| 79 |
# |
| 80 |
# reap the value of connection-1 |
| 81 |
# |
| 82 |
connection conn1; |
| 83 |
--error ER_QUERY_INTERRUPTED |
| 84 |
reap; |
| 85 |
|
| 86 |
# |
| 87 |
# clean test-bed. |
| 88 |
# |
| 89 |
connection default; |
| 90 |
disconnect conn1; |
| 91 |
disconnect conn2; |
| 92 |
disconnect conn3; |
| 93 |
drop procedure if exists update_t1; |
| 94 |
drop table if exists t1; |
| 95 |
|
| 96 |
|