summaryrefslogtreecommitdiff
path: root/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
blob: dcee5940907b11e9c798d16e631c5eea93c87f8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#
# MRR/Tokudb tests, taken from mysqltest/t/innodb_mrr.test
# (Turns off all other 6.0 optimizer switches than MRR)
#

--source include/have_tokudb.inc
--source include/have_mrr.inc

set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
set default_storage_engine=TokuDB;

--source include/mrr_tests.inc


# taken from include/mrr_innodb_tests.inc

--source include/count_sessions.inc

# MRR tests that are special for InnoDB (and copied for TokuDB)

--echo #
--echo # Bug#41029 "MRR: SELECT FOR UPDATE fails to lock gaps (InnoDB table)"
--echo #

# This test verifies that a SELECT FOR UPDATE statement executed in
# REPEATABLE READ isolation will lock the entire read interval by verifying
# that a second transaction trying to update data within this interval will
# be blocked.

connect (con1,localhost,root,,);
connect (con2,localhost,root,,);

connection con1;

SET AUTOCOMMIT=0;

CREATE TABLE t1 (
  dummy INT PRIMARY KEY,
  a INT UNIQUE,
  b INT
) ENGINE=TokuDB;

INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT;

SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
START TRANSACTION;

EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;

SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;

connection con2;

SET AUTOCOMMIT=0;
SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION;

--error ER_LOCK_WAIT_TIMEOUT
INSERT INTO t1 VALUES (8,8,8);
ROLLBACK;

connection con1;

ROLLBACK;
DROP TABLE t1;

connection default;
disconnect con1;
disconnect con2;

--source include/wait_until_count_sessions.inc