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 read committed;
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 read committed;
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# should get (5,50,500)
47select * from foo where b=50;
48a	b	c
495	50	500
50connection default;
51commit;
52# should use key b
53explain select * from foo where b=50;
54id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
551	SIMPLE	foo	ref	b	b	5	const	1
56# should get (5,50,1515)
57select * from foo where b=50;
58a	b	c
595	50	1515
60connection conn1;
61# should use key b
62explain select * from foo where b=50;
63id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
641	SIMPLE	foo	ref	b	b	5	const	1
65# should get (5,50,1515)
66select * from foo where b=50;
67a	b	c
685	50	1515
69commit;
70# should use key b
71explain select * from foo where b=50;
72id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
731	SIMPLE	foo	ref	b	b	5	const	1
74# should get (5,50,1515)
75select * from foo where b=50;
76a	b	c
775	50	1515
78connection default;
79disconnect conn1;
80connection default;
81set session transaction isolation level serializable;
82DROP TABLE foo;
83