1SET DEFAULT_STORAGE_ENGINE = 'tokudb';
2# Establish connection conn1 (user = root)
3connect  conn1,localhost,root,,;
4DROP TABLE IF EXISTS foo;
5connection default;
6set session transaction isolation level serializable;
7create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
8show create table foo;
9Table	Create Table
10foo	CREATE TABLE `foo` (
11  `a` int(11) NOT NULL,
12  `b` int(11) DEFAULT NULL,
13  `c` int(11) DEFAULT NULL,
14  PRIMARY KEY (`a`),
15  KEY `b` (`b`)
16) ENGINE=TokuDB DEFAULT CHARSET=latin1
17insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
18begin;
19select * from foo;
20a	b	c
211	10	100
222	20	200
233	30	300
244	40	400
255	50	500
266	60	600
277	70	700
288	80	800
299	90	900
30# should use key b
31explain select * from foo where b=50;
32id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
331	SIMPLE	foo	ref	b	b	5	const	1
34# should get (5,50,500)
35select * from foo where b=50;
36a	b	c
375	50	500
38replace into foo values (5,50,1515);
39connection conn1;
40set session transaction isolation level serializable;
41begin;
42# should use key b
43explain select * from foo where b=50;
44id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
451	SIMPLE	foo	ref	b	b	5	const	1
46# timeout
47select * from foo where b=50;
48ERROR HY000: Lock wait timeout exceeded; try restarting transaction
49connection default;
50commit;
51# should use key b
52explain select * from foo where b=50;
53id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
541	SIMPLE	foo	ref	b	b	5	const	1
55# should get (5,50,1515)
56select * from foo where b=50;
57a	b	c
585	50	1515
59connection conn1;
60# should use key b
61explain select * from foo where b=50;
62id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
631	SIMPLE	foo	ref	b	b	5	const	1
64# should get (5,50,1515)
65select * from foo where b=50;
66a	b	c
675	50	1515
68commit;
69# should use key b
70explain select * from foo where b=50;
71id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
721	SIMPLE	foo	ref	b	b	5	const	1
73# should get (5,50,1515)
74select * from foo where b=50;
75a	b	c
765	50	1515
77connection default;
78disconnect conn1;
79connection default;
80set session transaction isolation level serializable;
81DROP TABLE foo;
82