Commit 31ee9858 authored by Zardosht Kasheff's avatar Zardosht Kasheff

[t:2918], add tests to a common directory

git-svn-id: file:///svn/mysql/tests/mysql-test@23577 c7de825b-a66e-492c-adef-691d508d4ae1
parent 778fa02e
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a blob, key (a(3)))engine=tokudb;
insert into foo value ("asfdasdfasdfasdf");
explain select * from foo where a like 'asf%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a a 6 NULL 1 Using where
select * from foo where a like 'asf%';
a
asfdasdfasdfasdf
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a int, b blob)engine=tokudb;
insert into foo values (1,"one");
insert into foo values (3,"three");
insert into foo values (5,"five");
insert into foo values (2,"two");
insert into foo values (4,"four");
alter table foo add clustering key a(a);
explain select * From foo where a > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a a 5 NULL 5 Using where
select * From foo where a > 0;
a b
1 one
2 two
3 three
4 four
5 five
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a int, b int, c int, clustering key (a))engine=tokudb;
insert into foo values (1,1,1),(1,2,2),(1,3,3),(2,1,4),(2,2,5),(2,3,6),(3,1,7),(3,2,8);
explain select * From foo where a = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref a a 5 const 3 Using where
select * From foo where a = 2;
a b c
2 1 4
2 2 5
2 3 6
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a int, b int, c blob, primary key (a))engine=tokudb;
insert into foo values (1,10,"100");
select * from foo;
a b c
1 10 100
replace into foo values (1,100,"aaaaa");
select * from foo;
a b c
1 100 aaaaa
drop table foo;
create table foo (a int, b blob, c int, d blob, primary key (a));
insert into foo values (1,"10",100,"1000"),(4,"40",400,"4000"),(6,"60",600,"6000"),(2,"20",200,"2000"),(5,"50",500,"5000"),(3,"30",300,"3000");
select * from foo;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
update foo set b="alpha" where a=4;
select * From foo;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 alpha 400 4000
5 50 500 5000
6 60 600 6000
update foo set b="beta", d="gamma" where a=2;
select * From foo;
a b c d
1 10 100 1000
2 beta 200 gamma
3 30 300 3000
4 alpha 400 4000
5 50 500 5000
6 60 600 6000
update foo set b=d where a>4;
select * from foo;
a b c d
1 10 100 1000
2 beta 200 gamma
3 30 300 3000
4 alpha 400 4000
5 5000 500 5000
6 6000 600 6000
update foo set b="holy" where c > 100;
select * from foo;
a b c d
1 10 100 1000
2 holy 200 gamma
3 holy 300 3000
4 holy 400 4000
5 holy 500 5000
6 holy 600 6000
delete from foo;
insert into foo values (1,"10",100,"1000"),(4,"40",400,"4000"),(6,"60",600,"6000"),(2,"20",200,"2000"),(5,"50",500,"5000"),(3,"30",300,"3000");
select * from foo;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
replace into foo values (2,"twenty",200,"two thousand"),(3,"thirty",300,"three grand");
select * from foo;
a b c d
1 10 100 1000
2 twenty 200 two thousand
3 thirty 300 three grand
4 40 400 4000
5 50 500 5000
6 60 600 6000
delete from foo;
insert into foo values (1,"10",100,"1000"),(4,"40",400,"4000"),(6,"60",600,"6000"),(2,"20",200,"2000"),(5,"50",500,"5000"),(3,"30",300,"3000");
select * from foo;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
insert into foo values (2,"twenty",200,"two thousand"),(3,"thirty",300,"three grand") on duplicate key update a = a*1000, b = "updated", d = "column";
select * from foo;
a b c d
1 10 100 1000
4 40 400 4000
5 50 500 5000
6 60 600 6000
2000 updated 200 column
3000 updated 300 column
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a int, b int, primary key (a))engine=tokudb;
insert into foo values (1,10),(2,2),(3,300),(4,40);
select * from foo;
a b
1 10
2 2
3 300
4 40
replace into foo values (5,50),(10,1000);
select * from foo;
a b
1 10
2 2
3 300
4 40
5 50
10 1000
replace into foo (a) values (1),(3);
select * from foo;
a b
1 NULL
2 2
3 NULL
4 40
5 50
10 1000
replace into foo values (1,1),(3,3),(6,60);
select * from foo;
a b
1 1
2 2
3 3
4 40
5 50
6 60
10 1000
alter table foo add index (b);
select b from foo;
b
1
2
3
40
50
60
1000
select * from foo;
a b
1 1
2 2
3 3
4 40
5 50
6 60
10 1000
delete from foo where a > 4;
replace into foo values (1,10),(2,2),(3,300),(4,40);
select * from foo use index (primary);
a b
1 10
2 2
3 300
4 40
replace into foo values (5,50),(10,1000);
select * from foo use index (primary);
a b
1 10
2 2
3 300
4 40
5 50
10 1000
replace into foo (a) values (1),(2),(3),(4);
select * from foo use index (primary);
a b
1 NULL
2 NULL
3 NULL
4 NULL
5 50
10 1000
DROP TABLE foo;
# Establish connection conn1 (user = root)
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session transaction isolation level serializable;
create table foo ( a double, b double, c double, primary key (a,b));
insert into foo values (4,4,4),(4,5,5),(4,6,6),(5,4,4),(5,5,5),(5,6,6),(6,4,4),(6,5,5),(6,6,6);
begin;
select * from foo where a > 5;
a b c
6 4 4
6 5 5
6 6 6
set session transaction isolation level serializable;
insert into foo values (5,10,10);
insert into foo values (5.0001,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
begin;
select * from foo where a >= 5;
a b c
5 4 4
5 5 5
5 6 6
5 10 10
6 4 4
6 5 5
6 6 6
insert into foo values (5,1,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (4.999,10,10);
commit;
begin;
select * from foo where a < 5;
a b c
4 4 4
4 5 5
4 6 6
4.999 10 10
insert into foo values (5,0.1,10);
insert into foo values (4.9999,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
begin;
select * from foo where a <= 5;
a b c
4 4 4
4 5 5
4 6 6
4.999 10 10
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
insert into foo values (5,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.001,10,10);
commit;
begin;
select * from foo where a = 5;
a b c
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
insert into foo values (5,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.0001,10,10);
insert into foo values (4.99999,1,10);
commit;
begin;
select * from foo where a > 4 and a < 6;
a b c
4.999 10 10
4.99999 1 10
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
5.0001 10 10
5.001 10 10
insert into foo values (4.1,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.9,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,10,10);
insert into foo values (4,10,10);
commit;
begin;
select * from foo where a >= 4 and a < 6;
a b c
4 4 4
4 5 5
4 6 6
4 10 10
4.999 10 10
4.99999 1 10
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
5.0001 10 10
5.001 10 10
insert into foo values (4,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.9,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,1.1,10);
insert into foo values (3.99,10,10);
commit;
begin;
select * from foo where a > 4 and a <= 6;
a b c
4.999 10 10
4.99999 1 10
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
5.0001 10 10
5.001 10 10
6 1.1 10
6 4 4
6 5 5
6 6 6
6 10 10
insert into foo values (4.0001,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,1110,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6.001,1.1,10);
insert into foo values (4,1110,10);
commit;
begin;
select * from foo where a >= 4 and a <= 6;
a b c
4 4 4
4 5 5
4 6 6
4 10 10
4 1110 10
4.999 10 10
4.99999 1 10
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
5.0001 10 10
5.001 10 10
6 1.1 10
6 4 4
6 5 5
6 6 6
6 10 10
insert into foo values (4,0.001,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,11110,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6.0001,1.1,10);
insert into foo values (3.99,10110,10);
commit;
delete from foo;
insert into foo values (4,4,4),(4,5,5),(4,6,6),(5,4,4),(5,5,5),(5,6,6),(6,4,4),(6,5,5),(6,6,6);
begin;
select * from foo where a > 5 order by a desc;
a b c
6 6 6
6 5 5
6 4 4
insert into foo values (5,10,10);
insert into foo values (5.0001,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
begin;
select * from foo where a >= 5 order by a desc;
a b c
6 6 6
6 5 5
6 4 4
5 10 10
5 6 6
5 5 5
5 4 4
insert into foo values (5,1,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (4.999,10,10);
commit;
begin;
select * from foo where a < 5 order by a desc;
a b c
4.999 10 10
4 6 6
4 5 5
4 4 4
insert into foo values (5,0.1,10);
insert into foo values (4.9999,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
begin;
select * from foo where a <= 5 order by a desc;
a b c
5 10 10
5 6 6
5 5 5
5 4 4
5 0.1 10
4.999 10 10
4 6 6
4 5 5
4 4 4
insert into foo values (5,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.001,10,10);
commit;
begin;
select * from foo where a = 5 order by a desc;
a b c
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
insert into foo values (5,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.0001,10,10);
insert into foo values (4.99999,1,10);
commit;
begin;
select * from foo where a > 4 and a < 6 order by a desc;
a b c
5.001 10 10
5.0001 10 10
5 10 10
5 6 6
5 5 5
5 4 4
5 0.1 10
4.99999 1 10
4.999 10 10
insert into foo values (4.1,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.9,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,10,10);
insert into foo values (4,10,10);
commit;
begin;
select * from foo where a >= 4 and a < 6 order by a desc;
a b c
5.001 10 10
5.0001 10 10
5 10 10
5 6 6
5 5 5
5 4 4
5 0.1 10
4.99999 1 10
4.999 10 10
4 10 10
4 6 6
4 5 5
4 4 4
insert into foo values (4,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (5.9,10,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,1.1,10);
insert into foo values (3.99,10,10);
commit;
begin;
select * from foo where a > 4 and a <= 6 order by a desc;
a b c
6 10 10
6 6 6
6 5 5
6 4 4
6 1.1 10
5.001 10 10
5.0001 10 10
5 10 10
5 6 6
5 5 5
5 4 4
5 0.1 10
4.99999 1 10
4.999 10 10
insert into foo values (4.0001,0.01,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,1110,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6.001,1.1,10);
insert into foo values (4,1110,10);
commit;
begin;
select * from foo where a >= 4 and a <= 6 order by a desc;
a b c
6 10 10
6 6 6
6 5 5
6 4 4
6 1.1 10
5.001 10 10
5.0001 10 10
5 10 10
5 6 6
5 5 5
5 4 4
5 0.1 10
4.99999 1 10
4.999 10 10
4 1110 10
4 10 10
4 6 6
4 5 5
4 4 4
insert into foo values (4,0.001,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6,11110,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (6.0001,1.1,10);
insert into foo values (3.99,10110,10);
commit;
begin;
select count(*) from foo;
count(*)
23
insert into foo values (0,0.001,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (9999999,11110,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
begin;
select * from foo order by a desc;
a b c
6.001 1.1 10
6.0001 1.1 10
6 10 10
6 6 6
6 5 5
6 4 4
6 1.1 10
5.001 10 10
5.0001 10 10
5 10 10
5 6 6
5 5 5
5 4 4
5 0.1 10
4.99999 1 10
4.999 10 10
4 1110 10
4 10 10
4 6 6
4 5 5
4 4 4
3.99 10110 10
3.99 10 10
insert into foo values (0,0.001,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (9999999,11110,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
alter table foo drop primary key;
begin;
select * from foo;
a b c
3.99 10 10
3.99 10110 10
4 4 4
4 5 5
4 6 6
4 10 10
4 1110 10
4.999 10 10
4.99999 1 10
5 0.1 10
5 4 4
5 5 5
5 6 6
5 10 10
5.0001 10 10
5.001 10 10
6 1.1 10
6 4 4
6 5 5
6 6 6
6 10 10
6.0001 1.1 10
6.001 1.1 10
insert into foo values (0,0.001,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
insert into foo values (9999999,11110,10);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo ( a int, b int, c int);
insert into foo values (1,1,1),(1,2,2),(1,3,3),(2,1,1),(2,2,2),(2,3,3),(3,1,1),(3,2,2),(3,3,3);
insert into foo values (4,4,1),(4,5,2),(4,6,3),(5,4,1),(5,5,2),(5,6,3),(6,4,1),(6,5,2),(6,6,3);
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
select count(*) from foo;
count(*)
36864
alter table foo add index (a), add index (b);
explain select * from foo where a=2 and b=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index_merge a,b a,b 5,5 NULL 1024 Using intersect(a,b); Using where
alter table foo drop index a;
alter table foo add clustering index (a);
explain select * from foo where a=2 and b=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range b,a a 5 NULL 6144 Using where
alter table foo drop index a;
alter table foo drop index b;
alter table foo add index (a);
alter table foo add clustering index(b);
explain select * from foo where a=2 and b=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a,b b 5 NULL 6144 Using where
alter table foo drop index a;
alter table foo drop index b;
alter table foo add clustering index (a), add clustering index (b);
explain select * from foo where a=2 and b=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref a,b a 5 const 6144 Using where
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo ( a int, b bigint auto_increment, primary key (a,b));
insert into foo values (1,4444000000);
insert into foo (a) values (1),(1);
select * from foo;
a b
1 4444000000
1 4444000001
1 4444000002
flush table foo;
insert into foo (a) values (1),(1);
select * from foo;
a b
1 4444000000
1 4444000001
1 4444000002
1 4444000003
1 4444000004
drop table foo;
create table foo (a bigint auto_increment, primary key (a))engine=tokudb, auto_increment=4444000000;
insert into foo values (),();
select * from foo;
a
4444000000
4444000001
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session unique_checks=off;
create table foo (a int, b int, c int, primary key (a), key(b));
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600);
explain select * from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ALL NULL NULL NULL NULL 6
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
explain select b from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL b 5 NULL 6 Using index
select b from foo;
b
10
20
30
40
50
60
replace into foo values (1,1,1);
explain select * from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ALL NULL NULL NULL NULL 6
select * from foo;
a b c
1 1 1
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
explain select b from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL b 5 NULL 6 Using index
select b from foo;
b
1
20
30
40
50
60
set session unique_checks=on;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo ( a int);
insert into foo values (1),(2),(22),(3),(4);
select * from foo;
a
1
2
22
3
4
begin;
delete from foo;
select * from foo;
a
rollback;
select * from foo;
a
1
2
22
3
4
insert into foo values (1),(2),(22),(3),(4);
select * from foo;
a
1
2
22
3
4
1
2
22
3
4
begin;
delete from foo;
select * from foo;
a
commit;
select * from foo;
a
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set autocommit=off;
create table foo ( a int);
select * from foo;
a
lock tables foo write;
insert into foo values (1);
select * from foo;
a
1
rollback;
select * From foo;
a
insert into foo values (2);
select * from foo;
a
2
commit;
select * From foo;
a
2
insert into foo values (3);
select * from foo;
a
2
3
rollback;
select * From foo;
a
2
unlock tables;
set autocommit=on;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
checkpoint_unlock tokudb;
Type Name Status
TokuDB checkpoint unlock Lock never taken
checkpoint_lock tokudb;
Type Name Status
TokuDB checkpoint lock Lock successfully taken
checkpoint_unlock tokudb;
Type Name Status
TokuDB checkpoint unlock Successfully unlocked
checkpoint_lock tokudb;
Type Name Status
TokuDB checkpoint lock Lock successfully taken
checkpoint_lock tokudb;
Type Name Status
TokuDB checkpoint lock Lock already taken
checkpoint_unlock tokudb;
Type Name Status
TokuDB checkpoint unlock Successfully unlocked
checkpoint_unlock tokudb;
Type Name Status
TokuDB checkpoint unlock Lock never taken
create table foo ( a int);
insert into foo values (1);
checkpoint_lock tokudb;
Type Name Status
TokuDB checkpoint lock Lock successfully taken
checkpoint_lock tokudb;
Type Name Status
TokuDB checkpoint lock Lock already taken
checkpoint_unlock tokudb;
Type Name Status
TokuDB checkpoint unlock Successfully unlocked
checkpoint_unlock tokudb;
Type Name Status
TokuDB checkpoint unlock Lock never taken
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session transaction isolation level read uncommitted;
create table foo (a int) engine=TokuDB;
insert into foo values (1),(2),(3);
select * from foo;
a
1
2
3
update foo set a=a+1;
select * from foo;
a
2
3
4
delete from foo;
select * from foo;
a
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a int, b int, c int, d int, primary key (a), key (b), clustering key (c)) engine=TokuDB;
insert into foo values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000);
select * from foo use index ();
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
select b,a from foo;
b a
10 1
20 2
30 3
40 4
50 5
select * from foo order by c desc;
a b c d
5 50 500 5000
4 40 400 4000
3 30 300 3000
2 20 200 2000
1 10 100 1000
alter table foo drop primary key;
select * from foo use index ();
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
select b from foo;
b
10
20
30
40
50
select * from foo order by c desc;
a b c d
5 50 500 5000
4 40 400 4000
3 30 300 3000
2 20 200 2000
1 10 100 1000
drop table foo;
create table foo (a int, primary key (a))engine=TOkuDB;
insert into foo values (1),(2),(3),(4);
select * from foo;
a
1
2
3
4
insert into foo values (2);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
insert ignore into foo values (5),(2),(6);
select * From foo;
a
1
2
3
4
5
6
alter table foo drop primary key;
alter table foo add unique index (a);
insert into foo values (3);
ERROR 23000: Duplicate entry '3' for key 'a'
insert ignore into foo values (7),(2),(8);
select * from foo;
a
1
2
3
4
5
6
7
8
drop table foo;
create table foo (a int, b int, c int, d int, primary key (a), key (b), clustering key (c))engine=TokuDB;
insert into foo values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000);
select * from foo;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
update foo set b=b+1;
select * From foo;
a b c d
1 11 100 1000
2 21 200 2000
3 31 300 3000
4 41 400 4000
5 51 500 5000
select b,a from foo;
b a
11 1
21 2
31 3
41 4
51 5
update foo set c=c+1;
select * from foo;
a b c d
1 11 101 1000
2 21 201 2000
3 31 301 3000
4 41 401 4000
5 51 501 5000
select c,a from foo order by c desc;
c a
501 5
401 4
301 3
201 2
101 1
update foo set a=a+1 where a=5;
select * from foo;
a b c d
1 11 101 1000
2 21 201 2000
3 31 301 3000
4 41 401 4000
6 51 501 5000
select a from foo;
a
1
2
3
4
6
delete from foo where a > 3;
select * from foo;
a b c d
1 11 101 1000
2 21 201 2000
3 31 301 3000
select b,a from foo;
b a
11 1
21 2
31 3
select * from foo order by c desc;
a b c d
3 31 301 3000
2 21 201 2000
1 11 101 1000
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS test_bug;
create table test_bug (
id INT NOT NULL PRIMARY KEY,
foo CHAR(10)
) ENGINE=TokuDB;
set session transaction isolation level read uncommitted;
replace into test_bug (id, foo) VALUES (1, "bar");
insert ignore into test_bug (id, foo) VALUES (1, "bar");
insert into test_bug (id, foo) VALUES (1, "bar") ON DUPLICATE KEY UPDATE foo='baz';
set session transaction isolation level serializable;
DROP TABLE test_bug;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a char (255), primary key (a))charset=utf8;
insert into foo values (repeat('A', 255));
select * from foo;
a
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
drop table foo;
create table foo (a char (255), key (a))charset=utf8;
insert into foo values (repeat('A', 255));
explain select a from foo where a > "a";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index a a 766 NULL 1 Using where; Using index
select a from foo where a > "a";
a
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
drop table foo;
create table foo (a char (255), b int, clustering key (a))charset=utf8;
insert into foo values (repeat('A', 255), 100);
explain select a from foo where a > "a";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index a a 766 NULL 1 Using where; Using index
select a from foo where a > "a";
a
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
drop table foo;
create table foo (a char (255), b int, primary key (a), clustering key (a))charset=utf8;
insert into foo values (repeat('A', 255), 100);
explain select a from foo use index (a) where a > "a";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index a a 765 NULL 1 Using where; Using index
select a from foo use index (a) where a > "a";
a
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
drop table foo;
create table foo (a char (255))charset=utf8;
insert into foo values (repeat('A', 255));
select * from foo;
a
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
drop table foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS t1,t2;
#
# Bug#50843: Filesort used instead of clustered index led to
# performance degradation.
#
create table t1(f1 int not null primary key, f2 int);
create table t2(f1 int not null, key (f1));
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1),(2),(3);
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 1
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 2 Using index
alter table t1 drop primary key;
alter table t1 add clustering index (f1);
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL f1 4 NULL 1
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 2 Using index
drop table t1,t2;
#
# Establish connection conn1 (user = root)
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session transaction isolation level read committed;
create table foo ( a int, b int, primary key (a));
insert into foo values (1,1),(2,2),(3,1),(4,3);
select * from foo;
a b
1 1
2 2
3 1
4 3
begin;
update foo set b=10 where b=1;
select * from foo;
a b
1 10
2 2
3 10
4 3
set session transaction isolation level read committed;
select * from foo;
a b
1 1
2 2
3 1
4 3
set session transaction isolation level read uncommitted;
select * from foo;
a b
1 10
2 2
3 10
4 3
rollback;
begin;
insert into foo values (5,1),(6,2),(7,1),(8,3);
select * from foo;
a b
1 1
2 2
3 1
4 3
5 1
6 2
7 1
8 3
set session transaction isolation level read committed;
select * from foo;
a b
1 1
2 2
3 1
4 3
set session transaction isolation level read uncommitted;
select * from foo;
a b
1 1
2 2
3 1
4 3
5 1
6 2
7 1
8 3
commit;
begin;
delete from foo where b=1;
select * from foo;
a b
2 2
4 3
6 2
8 3
set session transaction isolation level read committed;
select * from foo;
a b
1 1
2 2
3 1
4 3
5 1
6 2
7 1
8 3
set session transaction isolation level read uncommitted;
select * from foo;
a b
2 2
4 3
6 2
8 3
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a int, b int, c int, primary key (a), clustering key (b));
replace into foo values (1,10,100), (2,20,200), (1,10,1000);
explain select * from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ALL NULL NULL NULL NULL 2
select * from foo;
a b c
1 10 1000
2 20 200
explain select * from foo order by b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL b 5 NULL 2
select * from foo order by b desc;
a b c
2 20 200
1 10 1000
insert ignore into foo values (3,30,300), (1,10,1);
explain select * from foo;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ALL NULL NULL NULL NULL 3
select * from foo;
a b c
1 10 1000
2 20 200
3 30 300
explain select * from foo order by b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo index NULL b 5 NULL 3
select * from foo order by b desc;
a b c
3 30 300
2 20 200
1 10 1000
drop table foo;
# Establish connection conn1 (user = root)
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session transaction isolation level read committed;
create table foo ( a int, b int, primary key (a));
begin;
insert into foo values (1,1),(2,2),(3,1),(4,3);
set session transaction isolation level read committed;
select * from foo;
a b
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT PRIMARY KEY);
INSERT INTO t1 VALUES (0);
INSERT INTO t1 VALUES (256);
COMMIT;
SELECT c1 from t1;
c1
2
258
DROP TABLE t1;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS t;
CREATE TABLE t (r INT, s INT, t BIGINT, PRIMARY KEY (r, s));
INSERT INTO t VALUES (1,2,3),(4,5,6);
EXPLAIN SELECT * FROM t WHERE r > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range PRIMARY PRIMARY 4 NULL 2 Using where
CREATE INDEX it on t(t);
EXPLAIN SELECT * FROM t WHERE r > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t index PRIMARY it 9 NULL 2 Using where; Using index
DROP TABLE t;
# Establish connection conn1 (user = root)
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo ( a int, b int, c int, key (a), key (b));
insert into foo values (1,10,100);
begin;
insert into foo values(2,20,200);
select * from foo;
a b c
1 10 100
drop table foo;
ERROR 42S02: Unknown table 'foo'
rename table foo to bar;
ERROR HY000: Error on rename of './test/foo' to './test/bar' (errno: -30994)
truncate table foo;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
alter table foo add index (c);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
alter table foo drop index a;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS t1,t2;
create table t1 (a int, b int, c int, key(a), key(b));
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
a b c
1 10 100
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
a b c
1 10 100
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
rename table t1 to t2;
DROP TABLE t2;
create table t1 (a int, b int, c int, primary key(a), key(b));
rename table t1 to t2;
DROP TABLE t2;
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
a b c
1 10 100
rename table t1 to t2;
select * from t2;
a b c
1 10 100
DROP TABLE t2;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
a b c
1 10 100
rename table t1 to t2;
select * from t2;
a b c
1 10 100
DROP TABLE t2;
create table t1 (a int, b int, c int, key(a), key(b));
rename table t1 to t2;
insert into t2 values (1,10,100);
select * from t2;
a b c
1 10 100
DROP TABLE t2;
create table t1 (a int, b int, c int, primary key(a), key(b));
rename table t1 to t2;
insert into t2 values (1,10,100);
select * from t2;
a b c
1 10 100
DROP TABLE t2;
create table t1 (a int, b int, c int, key(a), key(b));
alter table t1 add index (c), add index (a,b);
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
alter table t1 add index (c), add index (a,b);
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
alter table t1 drop index b;
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
alter table t1 drop index b;
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index (a,b);
select c from t1;
c
100
select a,b from t1;
a b
1 10
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index (a,b);
select c from t1;
c
100
select a,b from t1;
a b
1 10
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
alter table t1 add index (c), add index (a,b), drop index b;
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
alter table t1 add index (c), add index (a,b), drop index b;
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index foo (a,b), drop index b;
select c from t1;
c
100
select a,b from t1 use index (foo);
a b
1 10
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index foo (a,b), drop index b;
select c from t1;
c
100
select a,b from t1 use index (foo);
a b
1 10
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
a b c
1 10 100
truncate table t1;
insert into t1 values (2,20,200);
select * from t1;
a b c
2 20 200
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
a b c
1 10 100
truncate table t1;
insert into t1 values (2,20,200);
select * from t1;
a b c
2 20 200
DROP TABLE t1;
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
a b c
1 10 100
alter table t1 add index (c), drop index b;
select c from t1;
c
100
rename table t1 to t2;
select * from t2;
a b c
1 10 100
alter table t2 add index (b), drop index c;
select b from t2;
b
10
truncate table t2;
insert into t2 values (2,20,200);
select * From t2;
a b c
2 20 200
drop table t2;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
create table foo (a int, b int, c int, primary key (a,b));
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600);
insert into foo values (1,100,100),(2,200,200),(3,300,300),(4,400,400),(5,500,500),(6,600,600);
select * from foo;
a b c
1 10 100
1 100 100
2 20 200
2 200 200
3 30 300
3 300 300
4 40 400
4 400 400
5 50 500
5 500 500
6 60 600
6 600 600
explain select * from foo where a=4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref PRIMARY PRIMARY 4 const 2
select * from foo where a=4;
a b c
4 40 400
4 400 400
explain select * from foo where a>4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 4 Using where
select * from foo where a>4;
a b c
5 50 500
5 500 500
6 60 600
6 600 600
explain select * from foo where a<3 order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 4 Using where
select * from foo where a<3 order by a desc;
a b c
2 200 200
2 20 200
1 100 100
1 10 100
explain select * from foo where a>=4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 6 Using where
select * from foo where a>=4;
a b c
4 40 400
4 400 400
5 50 500
5 500 500
6 60 600
6 600 600
explain select * from foo where a<=2 order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 4 Using where
select * from foo where a<=2 order by a desc;
a b c
2 200 200
2 20 200
1 100 100
1 10 100
explain select * from foo where a=4 order by b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref PRIMARY PRIMARY 4 const 2 Using where
select * from foo where a=4 order by b desc;
a b c
4 400 400
4 40 400
alter table foo drop primary key;
alter table foo add clustering index clst_a(a,b);
explain select * from foo where a=4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref clst_a clst_a 4 const 2
select * from foo where a=4;
a b c
4 40 400
4 400 400
explain select * from foo where a>4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range clst_a clst_a 4 NULL 4 Using where
select * from foo where a>4;
a b c
5 50 500
5 500 500
6 60 600
6 600 600
explain select * from foo where a<3 order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range clst_a clst_a 4 NULL 4 Using where
select * from foo where a<3 order by a desc;
a b c
2 200 200
2 20 200
1 100 100
1 10 100
explain select * from foo where a>=4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range clst_a clst_a 4 NULL 6 Using where
select * from foo where a>=4;
a b c
4 40 400
4 400 400
5 50 500
5 500 500
6 60 600
6 600 600
explain select * from foo where a<=2 order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range clst_a clst_a 4 NULL 4 Using where
select * from foo where a<=2 order by a desc;
a b c
2 200 200
2 20 200
1 100 100
1 10 100
explain select * from foo where a=4 order by b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref clst_a clst_a 4 const 2 Using where
select * from foo where a=4 order by b desc;
a b c
4 400 400
4 40 400
alter table foo drop index clst_a;
alter table foo add index (a,b);
explain select * from foo where a=4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref a a 4 const 2
select * from foo where a=4;
a b c
4 40 400
4 400 400
explain select * from foo where a>4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a a 4 NULL 4 Using where
select * from foo where a>4;
a b c
5 50 500
5 500 500
6 60 600
6 600 600
explain select * from foo where a<3 order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a a 4 NULL 4 Using where
select * from foo where a<3 order by a desc;
a b c
2 200 200
2 20 200
1 100 100
1 10 100
explain select * from foo where a>=4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a a 4 NULL 6 Using where
select * from foo where a>=4;
a b c
4 40 400
4 400 400
5 50 500
5 500 500
6 60 600
6 600 600
explain select * from foo where a<=2 order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a a 4 NULL 4 Using where
select * from foo where a<=2 order by a desc;
a b c
2 200 200
2 20 200
1 100 100
1 10 100
explain select * from foo where a=4 order by b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref a a 4 const 2 Using where
select * from foo where a=4 order by b desc;
a b c
4 400 400
4 40 400
DROP TABLE foo;
--source include/have_tokudb.inc
#
# Record inconsistency.
#
#
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a blob, key (a(3)))engine=tokudb;
insert into foo value ("asfdasdfasdfasdf");
explain select * from foo where a like 'asf%';
select * from foo where a like 'asf%';
# Final cleanup.
DROP TABLE foo;
--source include/have_tokudb.inc
#
# Record inconsistency.
#
#
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b blob)engine=tokudb;
insert into foo values (1,"one");
insert into foo values (3,"three");
insert into foo values (5,"five");
insert into foo values (2,"two");
insert into foo values (4,"four");
alter table foo add clustering key a(a);
explain select * From foo where a > 0;
select * From foo where a > 0;
# Final cleanup.
DROP TABLE foo;
--source include/have_tokudb.inc
#
# Record inconsistency.
#
#
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b int, c int, clustering key (a))engine=tokudb;
insert into foo values (1,1,1),(1,2,2),(1,3,3),(2,1,4),(2,2,5),(2,3,6),(3,1,7),(3,2,8);
explain select * From foo where a = 2;
select * From foo where a = 2;
# Final cleanup.
DROP TABLE foo;
--source include/have_tokudb.inc
#
# Record inconsistency.
#
#
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b int, c blob, primary key (a))engine=tokudb;
insert into foo values (1,10,"100");
select * from foo;
replace into foo values (1,100,"aaaaa");
select * from foo;
drop table foo;
create table foo (a int, b blob, c int, d blob, primary key (a));
insert into foo values (1,"10",100,"1000"),(4,"40",400,"4000"),(6,"60",600,"6000"),(2,"20",200,"2000"),(5,"50",500,"5000"),(3,"30",300,"3000");
select * from foo;
update foo set b="alpha" where a=4;
select * From foo;
update foo set b="beta", d="gamma" where a=2;
select * From foo;
update foo set b=d where a>4;
select * from foo;
update foo set b="holy" where c > 100;
select * from foo;
delete from foo;
insert into foo values (1,"10",100,"1000"),(4,"40",400,"4000"),(6,"60",600,"6000"),(2,"20",200,"2000"),(5,"50",500,"5000"),(3,"30",300,"3000");
select * from foo;
replace into foo values (2,"twenty",200,"two thousand"),(3,"thirty",300,"three grand");
select * from foo;
delete from foo;
insert into foo values (1,"10",100,"1000"),(4,"40",400,"4000"),(6,"60",600,"6000"),(2,"20",200,"2000"),(5,"50",500,"5000"),(3,"30",300,"3000");
select * from foo;
insert into foo values (2,"twenty",200,"two thousand"),(3,"thirty",300,"three grand") on duplicate key update a = a*1000, b = "updated", d = "column";
select * from foo;
# Final cleanup.
DROP TABLE foo;
--source include/have_tokudb.inc
#
# Record inconsistency.
#
#
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b int, primary key (a))engine=tokudb;
insert into foo values (1,10),(2,2),(3,300),(4,40);
select * from foo;
replace into foo values (5,50),(10,1000);
select * from foo;
replace into foo (a) values (1),(3);
select * from foo;
replace into foo values (1,1),(3,3),(6,60);
select * from foo;
alter table foo add index (b);
select b from foo;
select * from foo;
delete from foo where a > 4;
replace into foo values (1,10),(2,2),(3,300),(4,40);
select * from foo use index (primary);
replace into foo values (5,50),(10,1000);
select * from foo use index (primary);
replace into foo (a) values (1),(2),(3),(4);
select * from foo use index (primary);
# Final cleanup.
DROP TABLE foo;
# ticket 895 is a query optimization problem with the primary key
--source include/have_tokudb.inc
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level serializable;
create table foo ( a double, b double, c double, primary key (a,b));
insert into foo values (4,4,4),(4,5,5),(4,6,6),(5,4,4),(5,5,5),(5,6,6),(6,4,4),(6,5,5),(6,6,6);
begin;
select * from foo where a > 5;
connection default;
set session transaction isolation level serializable;
insert into foo values (5,10,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5.0001,10,10);
connection conn1;
commit;
begin;
select * from foo where a >= 5;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,1,10);
insert into foo values (4.999,10,10);
connection conn1;
commit;
begin;
select * from foo where a < 5;
connection default;
insert into foo values (5,0.1,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4.9999,10,10);
connection conn1;
commit;
begin;
select * from foo where a <= 5;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,0.01,10);
insert into foo values (5.001,10,10);
connection conn1;
commit;
begin;
select * from foo where a = 5;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,0.01,10);
insert into foo values (5.0001,10,10);
insert into foo values (4.99999,1,10);
connection conn1;
commit;
begin;
select * from foo where a > 4 and a < 6;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4.1,0.01,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5.9,10,10);
insert into foo values (6,10,10);
insert into foo values (4,10,10);
connection conn1;
commit;
begin;
select * from foo where a >= 4 and a < 6;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4,0.01,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5.9,10,10);
insert into foo values (6,1.1,10);
insert into foo values (3.99,10,10);
connection conn1;
commit;
begin;
select * from foo where a > 4 and a <= 6;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4.0001,0.01,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (6,1110,10);
insert into foo values (6.001,1.1,10);
insert into foo values (4,1110,10);
connection conn1;
commit;
begin;
select * from foo where a >= 4 and a <= 6;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4,0.001,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (6,11110,10);
insert into foo values (6.0001,1.1,10);
insert into foo values (3.99,10110,10);
connection conn1;
commit;
delete from foo;
insert into foo values (4,4,4),(4,5,5),(4,6,6),(5,4,4),(5,5,5),(5,6,6),(6,4,4),(6,5,5),(6,6,6);
begin;
select * from foo where a > 5 order by a desc;
connection default;
insert into foo values (5,10,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5.0001,10,10);
connection conn1;
commit;
begin;
select * from foo where a >= 5 order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,1,10);
insert into foo values (4.999,10,10);
connection conn1;
commit;
begin;
select * from foo where a < 5 order by a desc;
connection default;
insert into foo values (5,0.1,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4.9999,10,10);
connection conn1;
commit;
begin;
select * from foo where a <= 5 order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,0.01,10);
insert into foo values (5.001,10,10);
connection conn1;
commit;
begin;
select * from foo where a = 5 order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,0.01,10);
insert into foo values (5.0001,10,10);
insert into foo values (4.99999,1,10);
connection conn1;
commit;
begin;
select * from foo where a > 4 and a < 6 order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4.1,0.01,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5.9,10,10);
insert into foo values (6,10,10);
insert into foo values (4,10,10);
connection conn1;
commit;
begin;
select * from foo where a >= 4 and a < 6 order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4,0.01,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5.9,10,10);
insert into foo values (6,1.1,10);
insert into foo values (3.99,10,10);
connection conn1;
commit;
begin;
select * from foo where a > 4 and a <= 6 order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4.0001,0.01,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (6,1110,10);
insert into foo values (6.001,1.1,10);
insert into foo values (4,1110,10);
connection conn1;
commit;
begin;
select * from foo where a >= 4 and a <= 6 order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (4,0.001,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (6,11110,10);
insert into foo values (6.0001,1.1,10);
insert into foo values (3.99,10110,10);
connection conn1;
commit;
begin;
select count(*) from foo;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (0,0.001,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (9999999,11110,10);
connection conn1;
commit;
begin;
select * from foo order by a desc;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (0,0.001,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (9999999,11110,10);
connection conn1;
commit;
alter table foo drop primary key;
begin;
select * from foo;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (0,0.001,10);
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (9999999,11110,10);
connection conn1;
commit;
disconnect conn1;
connection default;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo ( a int, b int, c int);
insert into foo values (1,1,1),(1,2,2),(1,3,3),(2,1,1),(2,2,2),(2,3,3),(3,1,1),(3,2,2),(3,3,3);
insert into foo values (4,4,1),(4,5,2),(4,6,3),(5,4,1),(5,5,2),(5,6,3),(6,4,1),(6,5,2),(6,6,3);
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
insert into foo select * from foo;
select count(*) from foo;
alter table foo add index (a), add index (b);
explain select * from foo where a=2 and b=2;
alter table foo drop index a;
alter table foo add clustering index (a);
explain select * from foo where a=2 and b=2;
alter table foo drop index a;
alter table foo drop index b;
alter table foo add index (a);
alter table foo add clustering index(b);
explain select * from foo where a=2 and b=2;
alter table foo drop index a;
alter table foo drop index b;
alter table foo add clustering index (a), add clustering index (b);
explain select * from foo where a=2 and b=2;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo ( a int, b bigint auto_increment, primary key (a,b));
insert into foo values (1,4444000000);
insert into foo (a) values (1),(1);
select * from foo;
flush table foo;
insert into foo (a) values (1),(1);
select * from foo;
drop table foo;
create table foo (a bigint auto_increment, primary key (a))engine=tokudb, auto_increment=4444000000;
insert into foo values (),();
select * from foo;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
set session unique_checks=off;
create table foo (a int, b int, c int, primary key (a), key(b));
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600);
explain select * from foo;
select * from foo;
explain select b from foo;
select b from foo;
replace into foo values (1,1,1);
explain select * from foo;
select * from foo;
explain select b from foo;
select b from foo;
set session unique_checks=on;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo ( a int);
insert into foo values (1),(2),(22),(3),(4);
select * from foo;
begin;
delete from foo;
select * from foo;
rollback;
select * from foo;
insert into foo values (1),(2),(22),(3),(4);
select * from foo;
begin;
delete from foo;
select * from foo;
commit;
select * from foo;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
set autocommit=off;
create table foo ( a int);
select * from foo;
lock tables foo write;
insert into foo values (1);
select * from foo;
rollback;
select * From foo;
insert into foo values (2);
select * from foo;
commit;
select * From foo;
insert into foo values (3);
select * from foo;
rollback;
select * From foo;
unlock tables;
# Final cleanup.
set autocommit=on;
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
checkpoint_unlock tokudb;
checkpoint_lock tokudb;
checkpoint_unlock tokudb;
checkpoint_lock tokudb;
checkpoint_lock tokudb;
checkpoint_unlock tokudb;
checkpoint_unlock tokudb;
create table foo ( a int);
insert into foo values (1);
checkpoint_lock tokudb;
checkpoint_lock tokudb;
checkpoint_unlock tokudb;
checkpoint_unlock tokudb;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
set session transaction isolation level read uncommitted;
create table foo (a int) engine=TokuDB;
insert into foo values (1),(2),(3);
select * from foo;
update foo set a=a+1;
select * from foo;
delete from foo;
select * from foo;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b int, c int, d int, primary key (a), key (b), clustering key (c)) engine=TokuDB;
insert into foo values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000);
select * from foo use index ();
select b,a from foo;
select * from foo order by c desc;
alter table foo drop primary key;
select * from foo use index ();
select b from foo;
select * from foo order by c desc;
drop table foo;
create table foo (a int, primary key (a))engine=TOkuDB;
insert into foo values (1),(2),(3),(4);
select * from foo;
--error ER_DUP_ENTRY
insert into foo values (2);
insert ignore into foo values (5),(2),(6);
select * From foo;
alter table foo drop primary key;
alter table foo add unique index (a);
--error ER_DUP_ENTRY
insert into foo values (3);
insert ignore into foo values (7),(2),(8);
select * from foo;
drop table foo;
create table foo (a int, b int, c int, d int, primary key (a), key (b), clustering key (c))engine=TokuDB;
insert into foo values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000);
select * from foo;
update foo set b=b+1;
select * From foo;
select b,a from foo;
update foo set c=c+1;
select * from foo;
select c,a from foo order by c desc;
update foo set a=a+1 where a=5;
select * from foo;
select a from foo;
delete from foo where a > 3;
select * from foo;
select b,a from foo;
select * from foo order by c desc;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS test_bug;
--enable_warnings
create table test_bug (
id INT NOT NULL PRIMARY KEY,
foo CHAR(10)
) ENGINE=TokuDB;
set session transaction isolation level read uncommitted;
replace into test_bug (id, foo) VALUES (1, "bar");
insert ignore into test_bug (id, foo) VALUES (1, "bar");
insert into test_bug (id, foo) VALUES (1, "bar") ON DUPLICATE KEY UPDATE foo='baz';
set session transaction isolation level serializable;
# Final cleanup.
DROP TABLE test_bug;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a char (255), primary key (a))charset=utf8;
insert into foo values (repeat('A', 255));
select * from foo;
drop table foo;
create table foo (a char (255), key (a))charset=utf8;
insert into foo values (repeat('A', 255));
explain select a from foo where a > "a";
select a from foo where a > "a";
drop table foo;
create table foo (a char (255), b int, clustering key (a))charset=utf8;
insert into foo values (repeat('A', 255), 100);
explain select a from foo where a > "a";
select a from foo where a > "a";
drop table foo;
create table foo (a char (255), b int, primary key (a), clustering key (a))charset=utf8;
insert into foo values (repeat('A', 255), 100);
explain select a from foo use index (a) where a > "a";
select a from foo use index (a) where a > "a";
drop table foo;
create table foo (a char (255))charset=utf8;
insert into foo values (repeat('A', 255));
select * from foo;
drop table foo;
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
--echo #
--echo # Bug#50843: Filesort used instead of clustered index led to
--echo # performance degradation.
--echo #
create table t1(f1 int not null primary key, f2 int);
create table t2(f1 int not null, key (f1));
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1),(2),(3);
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
alter table t1 drop primary key;
alter table t1 add clustering index (f1);
explain select t1.* from t1 left join t2 using(f1) group by t1.f1;
drop table t1,t2;
--echo #
# ticket 895 is a query optimization problem with the primary key
--source include/have_tokudb.inc
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level read committed;
create table foo ( a int, b int, primary key (a));
insert into foo values (1,1),(2,2),(3,1),(4,3);
select * from foo;
begin;
update foo set b=10 where b=1;
select * from foo;
connection default;
set session transaction isolation level read committed;
select * from foo;
set session transaction isolation level read uncommitted;
select * from foo;
connection conn1;
rollback;
begin;
insert into foo values (5,1),(6,2),(7,1),(8,3);
select * from foo;
connection default;
set session transaction isolation level read committed;
select * from foo;
set session transaction isolation level read uncommitted;
select * from foo;
connection conn1;
commit;
begin;
delete from foo where b=1;
select * from foo;
connection default;
set session transaction isolation level read committed;
select * from foo;
set session transaction isolation level read uncommitted;
select * from foo;
connection conn1;
commit;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b int, c int, primary key (a), clustering key (b));
replace into foo values (1,10,100), (2,20,200), (1,10,1000);
explain select * from foo;
select * from foo;
explain select * from foo order by b desc;
select * from foo order by b desc;
insert ignore into foo values (3,30,300), (1,10,1);
explain select * from foo;
select * from foo;
explain select * from foo order by b desc;
select * from foo order by b desc;
drop table foo;
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level read committed;
create table foo ( a int, b int, primary key (a));
begin;
insert into foo values (1,1),(2,2),(3,1),(4,3);
connection default;
set session transaction isolation level read committed;
select * from foo;
connection conn1;
commit;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
--source include/have_tokudb.inc
#
# Record inconsistency.
#
#
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (c1 INT PRIMARY KEY);
INSERT INTO t1 VALUES (0);
INSERT INTO t1 VALUES (256);
COMMIT;
--disable_query_log
BEGIN;
UPDATE t1 SET c1 = c1 + 2;
COMMIT;
--enable_query_log
SELECT c1 from t1;
# Final cleanup.
DROP TABLE t1;
# ticket 895 is a query optimization problem with the primary key
--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS t;
--enable_warnings
CREATE TABLE t (r INT, s INT, t BIGINT, PRIMARY KEY (r, s));
INSERT INTO t VALUES (1,2,3),(4,5,6);
EXPLAIN SELECT * FROM t WHERE r > 0;
CREATE INDEX it on t(t);
EXPLAIN SELECT * FROM t WHERE r > 0;
# Final cleanup.
DROP TABLE t;
# ticket 895 is a query optimization problem with the primary key
--source include/have_tokudb.inc
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
create table foo ( a int, b int, c int, key (a), key (b));
insert into foo values (1,10,100);
begin;
insert into foo values(2,20,200);
connection default;
select * from foo;
--error ER_BAD_TABLE_ERROR
drop table foo;
--error ER_ERROR_ON_RENAME
rename table foo to bar;
--error ER_LOCK_WAIT_TIMEOUT
truncate table foo;
--error ER_LOCK_WAIT_TIMEOUT
alter table foo add index (c);
--error ER_LOCK_WAIT_TIMEOUT
alter table foo drop index a;
connection conn1;
commit;
disconnect conn1;
connection default;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
#
# test create and drop
#
create table t1 (a int, b int, c int, key(a), key(b));
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
DROP TABLE t1;
#
# test create, open and drop
#
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
DROP TABLE t1;
#
# test create, rename, drop
#
create table t1 (a int, b int, c int, key(a), key(b));
rename table t1 to t2;
DROP TABLE t2;
create table t1 (a int, b int, c int, primary key(a), key(b));
rename table t1 to t2;
DROP TABLE t2;
#
# test create, open, rename, drop
#
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
rename table t1 to t2;
select * from t2;
DROP TABLE t2;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
rename table t1 to t2;
select * from t2;
DROP TABLE t2;
#
# test create, rename, open, drop
#
create table t1 (a int, b int, c int, key(a), key(b));
rename table t1 to t2;
insert into t2 values (1,10,100);
select * from t2;
DROP TABLE t2;
create table t1 (a int, b int, c int, primary key(a), key(b));
rename table t1 to t2;
insert into t2 values (1,10,100);
select * from t2;
DROP TABLE t2;
#
# test create, add index, drop
#
create table t1 (a int, b int, c int, key(a), key(b));
alter table t1 add index (c), add index (a,b);
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
alter table t1 add index (c), add index (a,b);
DROP TABLE t1;
#
# test create, drop index, drop
#
create table t1 (a int, b int, c int, key(a), key(b));
alter table t1 drop index b;
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
alter table t1 drop index b;
DROP TABLE t1;
#
# test add index, but with elements inserted and checked
#
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index (a,b);
select c from t1;
select a,b from t1;
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index (a,b);
select c from t1;
select a,b from t1;
DROP TABLE t1;
#
# test create, add index, drop index, drop
#
create table t1 (a int, b int, c int, key(a), key(b));
alter table t1 add index (c), add index (a,b), drop index b;
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
alter table t1 add index (c), add index (a,b), drop index b;
DROP TABLE t1;
#
# test create, add index, drop index, drop, with elements
#
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index foo (a,b), drop index b;
select c from t1;
select a,b from t1 use index (foo);
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
alter table t1 add index (c), add index foo (a,b), drop index b;
select c from t1;
select a,b from t1 use index (foo);
DROP TABLE t1;
#
# truncate
#
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
truncate table t1;
insert into t1 values (2,20,200);
select * from t1;
DROP TABLE t1;
create table t1 (a int, b int, c int, primary key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
truncate table t1;
insert into t1 values (2,20,200);
select * from t1;
DROP TABLE t1;
#
# do everything
#
create table t1 (a int, b int, c int, key(a), key(b));
insert into t1 values (1,10,100);
select * from t1;
alter table t1 add index (c), drop index b;
select c from t1;
rename table t1 to t2;
select * from t2;
alter table t2 add index (b), drop index c;
select b from t2;
truncate table t2;
insert into t2 values (2,20,200);
select * From t2;
drop table t2;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b int, c int, primary key (a,b));
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600);
insert into foo values (1,100,100),(2,200,200),(3,300,300),(4,400,400),(5,500,500),(6,600,600);
select * from foo;
#HA_READ_KEY_EXACT
explain select * from foo where a=4;
select * from foo where a=4;
#HA_READ_AFTER_KEY
explain select * from foo where a>4;
select * from foo where a>4;
#HA_READ_BEFORE_KEY
explain select * from foo where a<3 order by a desc;
select * from foo where a<3 order by a desc;
#HA_READ_KEY_OR_NEXT
explain select * from foo where a>=4;
select * from foo where a>=4;
#HA_READ_KEY_OR_PREV not used anymore
#HA_READ_PREFIX_LAST_OR_PREV
explain select * from foo where a<=2 order by a desc;
select * from foo where a<=2 order by a desc;
#HA_READ_PREFIX_LAST
explain select * from foo where a=4 order by b desc;
select * from foo where a=4 order by b desc;
alter table foo drop primary key;
alter table foo add clustering index clst_a(a,b);
#HA_READ_KEY_EXACT
explain select * from foo where a=4;
select * from foo where a=4;
#HA_READ_AFTER_KEY
explain select * from foo where a>4;
select * from foo where a>4;
#HA_READ_BEFORE_KEY
explain select * from foo where a<3 order by a desc;
select * from foo where a<3 order by a desc;
#HA_READ_KEY_OR_NEXT
explain select * from foo where a>=4;
select * from foo where a>=4;
#HA_READ_KEY_OR_PREV not used anymore
#HA_READ_PREFIX_LAST_OR_PREV
explain select * from foo where a<=2 order by a desc;
select * from foo where a<=2 order by a desc;
#HA_READ_PREFIX_LAST
explain select * from foo where a=4 order by b desc;
select * from foo where a=4 order by b desc;
alter table foo drop index clst_a;
alter table foo add index (a,b);
#HA_READ_KEY_EXACT
explain select * from foo where a=4;
select * from foo where a=4;
#HA_READ_AFTER_KEY
explain select * from foo where a>4;
select * from foo where a>4;
#HA_READ_BEFORE_KEY
explain select * from foo where a<3 order by a desc;
select * from foo where a<3 order by a desc;
#HA_READ_KEY_OR_NEXT
explain select * from foo where a>=4;
select * from foo where a>=4;
#HA_READ_KEY_OR_PREV not used anymore
#HA_READ_PREFIX_LAST_OR_PREV
explain select * from foo where a<=2 order by a desc;
select * from foo where a<=2 order by a desc;
#HA_READ_PREFIX_LAST
explain select * from foo where a=4 order by b desc;
select * from foo where a=4 order by b desc;
# Final cleanup.
DROP TABLE foo;
\ No newline at end of file
SET STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS z1;
create table z1 (a int, b int, c int, d int, e int, clustering key (a));
insert into z1 values (1,1,1,1,1),(7,7,7,7,7),(4,4,4,4,4),(3,3,3,3,3),(5,5,5,5,5),(2,2,2,2,2),(6,6,6,6,6);
explain select * From z1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 index NULL a 5 NULL 7
select * from z1 order by a;
a b c d e
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
6 6 6 6 6
7 7 7 7 7
explain select * From z1 order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 index NULL a 5 NULL 7
select * from z1 order by a desc;
a b c d e
7 7 7 7 7
6 6 6 6 6
5 5 5 5 5
4 4 4 4 4
3 3 3 3 3
2 2 2 2 2
1 1 1 1 1
DROP TABLE z1;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
select * from t1 where a > 5;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY b 5 NULL 9 Using where; Using index
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where; Using index
select a,b from t1 where b > 30;
a b
4 40
5 50
6 60
7 70
8 80
9 90
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 800
9 900
alter table t1 add clustering index bdca(b,d,c,a);
insert into t1 values (10,10,10,10);
alter table t1 drop index bdca;
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
select * from t1 where a > 5;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
10 10 10 10
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
explain select b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where; Using index
select b from t1 where b > 30;
b
40
50
60
70
80
90
explain select b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select c from t1 where c > 750;
c
800
900
alter table t1 add e varchar(20);
alter table t1 add primary key (a);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 5 Using where
select * from t1 where a > 5;
a b c d e
6 60 600 6000 NULL
7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d e
4 40 400 4000 NULL
5 50 500 5000 NULL
6 60 600 6000 NULL
7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d e
8 80 800 8000 NULL
9 90 900 9000 NULL
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY b 5 NULL 10 Using where; Using index
select a from t1 where a > 5;
a
10
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where; Using index
select a,b from t1 where b > 30;
a b
4 40
5 50
6 60
7 70
8 80
9 90
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 800
9 900
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
select * from t1 where a > 5;
a b c d e
6 60 600 6000 NULL
7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d e
4 40 400 4000 NULL
5 50 500 5000 NULL
6 60 600 6000 NULL
7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d e
8 80 800 8000 NULL
9 90 900 9000 NULL
explain select b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where; Using index
select b from t1 where b > 30;
b
40
50
60
70
80
90
explain select b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select c from t1 where c > 750;
c
800
900
drop table t1;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b))engine=tokudb;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
CLUSTERING KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
create clustering index foo on t1(c,d);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
CLUSTERING KEY `b` (`b`),
CLUSTERING KEY `foo` (`c`,`d`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
alter table t1 drop primary key;
alter table t1 add primary key (a,b,c,d);
alter table t1 add clustering key bar(d,c,b,a);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) NOT NULL DEFAULT '0',
`c` int(11) NOT NULL DEFAULT '0',
`d` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`a`,`b`,`c`,`d`),
CLUSTERING KEY `b` (`b`),
CLUSTERING KEY `foo` (`c`,`d`),
CLUSTERING KEY `bar` (`d`,`c`,`b`,`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL b 4 NULL 5 Using index
select * from t1;
a b c d
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
32 54 12 56
explain select d from t1 where d > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range bar bar 4 NULL 1 Using where; Using index
select * from t1 where d > 30;
a b c d
32 54 12 56
drop table t1;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
select * from t1 where a > 5;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY b 5 NULL 9 Using where; Using index
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where; Using index
select a,b from t1 where b > 30;
a b
4 40
5 50
6 60
7 70
8 80
9 90
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 800
9 900
delete from t1 where b>30 and b < 60;
select * from t1;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
select * from t1 where a > 5;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 4 Using where
select * from t1 where b > 30;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY b 5 NULL 7 Using where; Using index
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 4 Using where; Using index
select a,b from t1 where b > 30;
a b
6 60
7 70
8 80
9 90
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 800
9 900
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
select * from t1 where a > 5;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 4 Using where
select * from t1 where b > 30;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 4 Using where
select a,b from t1 where b > 30;
a b
6 60
7 70
8 80
9 90
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 800
9 900
delete from t1 where b > 10 and b < 90;
select * from t1;
a b c d
1 10 100 1000
9 90 900 9000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
select * from t1 where a > 5;
a b c d
9 90 900 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 1 Using where
select * from t1 where b > 30;
a b c d
9 90 900 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 1 Using where
select * from t1 where c > 750;
a b c d
9 90 900 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
select a from t1 where a > 5;
a
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 1 Using where
select a,b from t1 where b > 30;
a b
9 90
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 1 Using where
select a,c from t1 where c > 750;
a c
9 900
drop table t1;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
select * from t1;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
delete from t1 where d > 8000;
select * from t1;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 8 Using where
select * From t1 where b > 0;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
delete from t1 where a > 7;
select * from t1;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 7 Using where
select * From t1 where b > 0;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
delete from t1 where b > 30;
select * from t1;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 3 Using where
select * From t1 where b > 0;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
drop table t1;
create table t1(a int, b int, c int, d int, clustering key(b))engine=tokudb;
insert into t1 values (2,20,200,2000),(4,40,400,4000),(1,10,100,1000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(3,30,300,3000),(9,90,900,9000);
select * from t1;
a b c d
2 20 200 2000
4 40 400 4000
1 10 100 1000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
3 30 300 3000
9 90 900 9000
delete from t1 where d > 8000;
select * from t1;
a b c d
2 20 200 2000
4 40 400 4000
1 10 100 1000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
3 30 300 3000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 8 Using where
select * From t1 where b > 0;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
delete from t1 where b > 30;
select * from t1;
a b c d
2 20 200 2000
1 10 100 1000
3 30 300 3000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 3 Using where
select * From t1 where b > 0;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
drop table t1;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9);
explain select * from t1 where b > 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 7 Using where
explain select * from t1 where c > 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL 9 Using where
explain select * from t1 where a > 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 5 Using where
explain select * from t1 where c > 7;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
explain select * from t1 where b > 7;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 2 Using where
explain select a from t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL 9 Using where; Using index
explain select a from t1 where c > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 5 NULL 9 Using where; Using index
drop table t1;
SET STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS z1;
create table z1 (a int, b int, c int, d int, e int, primary key (c,d), clustering key (a,b));
insert into z1 values (1,1,1,1,1), (1,2,3,4,5), (3,4,1,100,1),(3,4,1,2,3),(3,5,1,21,1),(7,8,4,2,6),(9,10,34,3,2);
insert into z1 values (-1,-1,-1,-1,-1), (-1,-2,-3,-4,-5), (-3,-4,-1,-100,-1),(-3,-4,-1,-2,-3),(-3,-5,-1,-21,-1),(-7,-8,-4,-2,-6),(-9,-10,-34,-3,-2);
select * from z1 group by a,b;
a b c d e
-9 -10 -34 -3 -2
-7 -8 -4 -2 -6
-3 -5 -1 -21 -1
-3 -4 -1 -100 -1
-1 -2 -3 -4 -5
-1 -1 -1 -1 -1
1 1 1 1 1
1 2 3 4 5
3 4 1 2 3
3 5 1 21 1
7 8 4 2 6
9 10 34 3 2
explain select a,b from z1 where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 5 Using where; Using index
select a,b from z1 where a > 1;
a b
3 4
3 4
3 5
7 8
9 10
explain select a,b from z1 where a >=1 and b > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 10 NULL 6 Using where; Using index
select a,b from z1 where a >=1 and b > 1;
a b
1 2
3 4
3 4
3 5
7 8
9 10
explain select a,b from z1 where a > 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 2 Using where; Using index
select a,b from z1 where a > 3;
a b
7 8
9 10
explain select a,b from z1 where a >=3 and b > 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 10 NULL 3 Using where; Using index
select a,b from z1 where a >=3 and b > 4;
a b
3 5
7 8
9 10
select distinct a from z1;
a
-9
-7
-3
-1
1
3
7
9
DROP TABLE z1;
SET STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS z1;
create table z1 (a int, b int, c int, d int, e int, primary key (c,d), clustering key (a,b));
insert into z1 values (1,1,1,1,1), (1,2,3,4,5), (3,4,1,100,1),(3,4,1,2,3),(3,5,1,21,1),(7,8,4,2,6),(9,10,34,3,2);
insert into z1 values (-1,-1,-1,-1,-1), (-1,-2,-3,-4,-5), (-3,-4,-1,-100,-1),(-3,-4,-1,-2,-3),(-3,-5,-1,-21,-1),(-7,-8,-4,-2,-6),(-9,-10,-34,-3,-2);
select * from z1 group by a,b;
a b c d e
-9 -10 -34 -3 -2
-7 -8 -4 -2 -6
-3 -5 -1 -21 -1
-3 -4 -1 -100 -1
-1 -2 -3 -4 -5
-1 -1 -1 -1 -1
1 1 1 1 1
1 2 3 4 5
3 4 1 2 3
3 5 1 21 1
7 8 4 2 6
9 10 34 3 2
explain select a,b from z1 where a < 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 7 Using where; Using index
select max(a) from z1 where a < 1;
max(a)
-1
explain select a,b from z1 where a < 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 13 Using where; Using index
select max(a) from z1 where a < 9;
max(a)
7
explain select a,b from z1 where a < 7;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 12 Using where; Using index
select max(a) from z1 where a < 7;
max(a)
3
explain select a,b from z1 where a < 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 9 Using where; Using index
select max(a) from z1 where a < 3;
max(a)
1
explain select max(b) from z1 where a = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select max(b) from z1 where a = 1;
max(b)
2
explain select max(b) from z1 where a = 3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select max(b) from z1 where a = 3;
max(b)
5
explain select max(b) from z1 where a = 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select max(b) from z1 where a = 9;
max(b)
10
DROP TABLE z1;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
select * from t1 where a > 5;
a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY b 5 NULL 9 Using where; Using index
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where; Using index
select a,b from t1 where b > 30;
a b
4 40
5 50
6 60
7 70
8 80
9 90
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 800
9 900
update t1 set c = c+5, b = b+5 where b>30;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where
select * from t1 where a > 5;
a b c d
6 65 605 6000
7 75 705 7000
8 85 805 8000
9 95 905 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d
4 45 405 4000
5 55 505 5000
6 65 605 6000
7 75 705 7000
8 85 805 8000
9 95 905 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 85 805 8000
9 95 905 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY b 5 NULL 9 Using where; Using index
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where; Using index
select a,b from t1 where b > 30;
a b
4 45
5 55
6 65
7 75
8 85
9 95
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 805
9 905
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using where
select * from t1 where a > 5;
a b c d
6 65 605 6000
7 75 705 7000
8 85 805 8000
9 95 905 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d
4 45 405 4000
5 55 505 5000
6 65 605 6000
7 75 705 7000
8 85 805 8000
9 95 905 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 85 805 8000
9 95 905 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using where
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select a,b from t1 where b > 30;
a b
4 45
5 55
6 65
7 75
8 85
9 95
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 805
9 905
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 50 410 4000
5 60 510 5000
6 70 610 6000
7 80 710 7000
8 90 810 8000
9 100 910 9000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using where
select * from t1 where a > 5;
a b c d
6 70 610 6000
7 80 710 7000
8 90 810 8000
9 100 910 9000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select * from t1 where b > 30;
a b c d
4 50 410 4000
5 60 510 5000
6 70 610 6000
7 80 710 7000
8 90 810 8000
9 100 910 9000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select * from t1 where c > 750;
a b c d
8 90 810 8000
9 100 910 9000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using where
select a from t1 where a > 5;
a
6
7
8
9
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 6 Using where
select a,b from t1 where b > 30;
a b
4 50
5 60
6 70
7 80
8 90
9 100
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL 2 Using where
select a,c from t1 where c > 750;
a c
8 810
9 910
drop table t1;
SET STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
select * from t1;
a b c d
1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000
update t1 set d=d+10000;
select * from t1;
a b c d
1 10 100 11000
2 20 200 12000
3 30 300 13000
4 40 400 14000
5 50 500 15000
6 60 600 16000
7 70 700 17000
8 80 800 18000
9 90 900 19000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 9 Using where
select * From t1 where b > 0;
a b c d
1 10 100 11000
2 20 200 12000
3 30 300 13000
4 40 400 14000
5 50 500 15000
6 60 600 16000
7 70 700 17000
8 80 800 18000
9 90 900 19000
update t1 set a=a+10000;
select * from t1;
a b c d
10001 10 100 11000
10002 20 200 12000
10003 30 300 13000
10004 40 400 14000
10005 50 500 15000
10006 60 600 16000
10007 70 700 17000
10008 80 800 18000
10009 90 900 19000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 9 Using where
select * From t1 where b > 0;
a b c d
10001 10 100 11000
10002 20 200 12000
10003 30 300 13000
10004 40 400 14000
10005 50 500 15000
10006 60 600 16000
10007 70 700 17000
10008 80 800 18000
10009 90 900 19000
update t1 set b=b+10000;
select * from t1;
a b c d
10001 10010 100 11000
10002 10020 200 12000
10003 10030 300 13000
10004 10040 400 14000
10005 10050 500 15000
10006 10060 600 16000
10007 10070 700 17000
10008 10080 800 18000
10009 10090 900 19000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 9 Using where
select * From t1 where b > 0;
a b c d
10001 10010 100 11000
10002 10020 200 12000
10003 10030 300 13000
10004 10040 400 14000
10005 10050 500 15000
10006 10060 600 16000
10007 10070 700 17000
10008 10080 800 18000
10009 10090 900 19000
drop table t1;
create table t1(a int, b int, c int, d int, clustering key(b))engine=tokudb;
insert into t1 values (2,20,200,2000),(4,40,400,4000),(1,10,100,1000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(3,30,300,3000),(9,90,900,9000);
select * from t1;
a b c d
2 20 200 2000
4 40 400 4000
1 10 100 1000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000
3 30 300 3000
9 90 900 9000
update t1 set d=d+10000;
select * from t1;
a b c d
2 20 200 12000
4 40 400 14000
1 10 100 11000
5 50 500 15000
6 60 600 16000
7 70 700 17000
8 80 800 18000
3 30 300 13000
9 90 900 19000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 9 Using where
select * From t1 where b > 0;
a b c d
1 10 100 11000
2 20 200 12000
3 30 300 13000
4 40 400 14000
5 50 500 15000
6 60 600 16000
7 70 700 17000
8 80 800 18000
9 90 900 19000
update t1 set b=b+10000;
select * from t1;
a b c d
2 10020 200 12000
4 10040 400 14000
1 10010 100 11000
5 10050 500 15000
6 10060 600 16000
7 10070 700 17000
8 10080 800 18000
3 10030 300 13000
9 10090 900 19000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 9 Using where
select * From t1 where b > 0;
a b c d
1 10010 100 11000
2 10020 200 12000
3 10030 300 13000
4 10040 400 14000
5 10050 500 15000
6 10060 600 16000
7 10070 700 17000
8 10080 800 18000
9 10090 900 19000
alter table t1 drop key b;
alter table t1 add clustering key b(b);
select * from t1;
a b c d
2 10020 200 12000
4 10040 400 14000
1 10010 100 11000
5 10050 500 15000
6 10060 600 16000
7 10070 700 17000
8 10080 800 18000
3 10030 300 13000
9 10090 900 19000
explain select * From t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 9 Using where
select * From t1 where b > 0;
a b c d
1 10010 100 11000
2 10020 200 12000
3 10030 300 13000
4 10040 400 14000
5 10050 500 15000
6 10060 600 16000
7 10070 700 17000
8 10080 800 18000
9 10090 900 19000
drop table t1;
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS z1;
--enable_warnings
create table z1 (a int, b int, c int, d int, e int, clustering key (a));
insert into z1 values (1,1,1,1,1),(7,7,7,7,7),(4,4,4,4,4),(3,3,3,3,3),(5,5,5,5,5),(2,2,2,2,2),(6,6,6,6,6);
explain select * From z1 order by a;
select * from z1 order by a;
explain select * From z1 order by a desc;
select * from z1 order by a desc;
DROP TABLE z1;
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
#normal queries
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
alter table t1 add clustering index bdca(b,d,c,a);
insert into t1 values (10,10,10,10);
alter table t1 drop index bdca;
alter table t1 drop primary key;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select b from t1 where b > 30;
select b from t1 where b > 30;
explain select b from t1 where c > 750;
select c from t1 where c > 750;
alter table t1 add e varchar(20);
alter table t1 add primary key (a);
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
alter table t1 drop primary key;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select b from t1 where b > 30;
select b from t1 where b > 30;
explain select b from t1 where c > 750;
select c from t1 where c > 750;
drop table t1;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b))engine=tokudb;
show create table t1;
create clustering index foo on t1(c,d);
show create table t1;
alter table t1 drop primary key;
alter table t1 add primary key (a,b,c,d);
alter table t1 add clustering key bar(d,c,b,a);
show create table t1;
insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
explain select * from t1;
select * from t1;
explain select d from t1 where d > 30;
select * from t1 where d > 30;
drop table t1;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
#normal queries
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
delete from t1 where b>30 and b < 60;
select * from t1;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
alter table t1 drop primary key;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
delete from t1 where b > 10 and b < 90;
select * from t1;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
drop table t1;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
select * from t1;
#delete on non-index column
delete from t1 where d > 8000;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
#delete on prim_key
delete from t1 where a > 7;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
#delete on clustering key
delete from t1 where b > 30;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
drop table t1;
create table t1(a int, b int, c int, d int, clustering key(b))engine=tokudb;
insert into t1 values (2,20,200,2000),(4,40,400,4000),(1,10,100,1000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(3,30,300,3000),(9,90,900,9000);
select * from t1;
#delete on non-index column
delete from t1 where d > 8000;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
#delete on clustering key
delete from t1 where b > 30;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
drop table t1;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9);
explain select * from t1 where b > 2;
explain select * from t1 where c > 2;
explain select * from t1 where a > 4;
explain select * from t1 where c > 7;
explain select * from t1 where b > 7;
explain select a from t1 where b > 0;
explain select a from t1 where c > 0;
drop table t1;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS z1;
--enable_warnings
create table z1 (a int, b int, c int, d int, e int, primary key (c,d), clustering key (a,b));
insert into z1 values (1,1,1,1,1), (1,2,3,4,5), (3,4,1,100,1),(3,4,1,2,3),(3,5,1,21,1),(7,8,4,2,6),(9,10,34,3,2);
insert into z1 values (-1,-1,-1,-1,-1), (-1,-2,-3,-4,-5), (-3,-4,-1,-100,-1),(-3,-4,-1,-2,-3),(-3,-5,-1,-21,-1),(-7,-8,-4,-2,-6),(-9,-10,-34,-3,-2);
select * from z1 group by a,b;
explain select a,b from z1 where a > 1;
select a,b from z1 where a > 1;
explain select a,b from z1 where a >=1 and b > 1;
select a,b from z1 where a >=1 and b > 1;
explain select a,b from z1 where a > 3;
select a,b from z1 where a > 3;
explain select a,b from z1 where a >=3 and b > 4;
select a,b from z1 where a >=3 and b > 4;
select distinct a from z1;
DROP TABLE z1;
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
#
# Bug #22169: Crash with count(distinct)
#
--echo *** Bug #22169 ***
--disable_warnings
DROP TABLE IF EXISTS z1;
--enable_warnings
create table z1 (a int, b int, c int, d int, e int, primary key (c,d), clustering key (a,b));
insert into z1 values (1,1,1,1,1), (1,2,3,4,5), (3,4,1,100,1),(3,4,1,2,3),(3,5,1,21,1),(7,8,4,2,6),(9,10,34,3,2);
insert into z1 values (-1,-1,-1,-1,-1), (-1,-2,-3,-4,-5), (-3,-4,-1,-100,-1),(-3,-4,-1,-2,-3),(-3,-5,-1,-21,-1),(-7,-8,-4,-2,-6),(-9,-10,-34,-3,-2);
#let $1 = 2048;
#SET @a=1;
#while ($1)
#{
# insert into z1 values (@a * -100, @a*-200, @a*-300, @a*-400, @a*-500);
# dec $1;
# SET @a = @a+1;
#}
select * from z1 group by a,b;
explain select a,b from z1 where a < 1;
select max(a) from z1 where a < 1;
explain select a,b from z1 where a < 9;
select max(a) from z1 where a < 9;
explain select a,b from z1 where a < 7;
select max(a) from z1 where a < 7;
explain select a,b from z1 where a < 3;
select max(a) from z1 where a < 3;
explain select max(b) from z1 where a = 1;
select max(b) from z1 where a = 1;
explain select max(b) from z1 where a = 3;
select max(b) from z1 where a = 3;
explain select max(b) from z1 where a = 9;
select max(b) from z1 where a = 9;
DROP TABLE z1;
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b), key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
#normal queries
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
update t1 set c = c+5, b = b+5 where b>30;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
alter table t1 drop primary key;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
explain select * from t1 where a > 5;
select * from t1 where a > 5;
explain select * from t1 where b > 30;
select * from t1 where b > 30;
explain select * from t1 where c > 750;
select * from t1 where c > 750;
#covering indexes
explain select a from t1 where a > 5;
select a from t1 where a > 5;
explain select a,b from t1 where b > 30;
select a,b from t1 where b > 30;
explain select a,b from t1 where c > 750;
select a,c from t1 where c > 750;
drop table t1;
\ No newline at end of file
#--source include/have_tokudb.inc
SET STORAGE_ENGINE='tokudb';
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
create table t1(a int, b int, c int, d int, primary key(a), clustering key(b))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
select * from t1;
#update non-index column
update t1 set d=d+10000;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
#update prim_key
update t1 set a=a+10000;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
#update clustering key
update t1 set b=b+10000;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
drop table t1;
create table t1(a int, b int, c int, d int, clustering key(b))engine=tokudb;
insert into t1 values (2,20,200,2000),(4,40,400,4000),(1,10,100,1000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(3,30,300,3000),(9,90,900,9000);
select * from t1;
#update non-index column
update t1 set d=d+10000;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
#update clustering key
update t1 set b=b+10000;
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
alter table t1 drop key b;
alter table t1 add clustering key b(b);
select * from t1;
explain select * From t1 where b > 0;
select * From t1 where b > 0;
drop table t1;
\ No newline at end of file
SET STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
create table t1 (a int, b int, c int, d int, e int, f int, primary key (c), clustering key (b), clustering key (d,a));
insert into t1 values (1,10,100,1000,10000,100000);
insert into t1 values (2,20,200,2000,20000,200000);
insert into t1 values (3,30,300,3000,30000,300000);
insert into t1 values (4,40,400,4000,40000,400000);
insert into t1 values (5,50,500,5000,50000,500000);
explain select * from t1 where c > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 5 Using where
select * from t1 where c > 0;
a b c d e f
1 10 100 1000 10000 100000
2 20 200 2000 20000 200000
3 30 300 3000 30000 300000
4 40 400 4000 40000 400000
5 50 500 5000 50000 500000
explain select * from t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 5 Using where
select * from t1 where b > 0;
a b c d e f
1 10 100 1000 10000 100000
2 20 200 2000 20000 200000
3 30 300 3000 30000 300000
4 40 400 4000 40000 400000
5 50 500 5000 50000 500000
explain select * from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range d d 5 NULL 5 Using where
select * from t1 where d > 0;
a b c d e f
1 10 100 1000 10000 100000
2 20 200 2000 20000 200000
3 30 300 3000 30000 300000
4 40 400 4000 40000 400000
5 50 500 5000 50000 500000
explain select a from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index d d 10 NULL 5 Using where; Using index
select a from t1 where d > 0;
a
1
2
3
4
5
select e,f from t1 where c > 0;
e f
10000 100000
20000 200000
30000 300000
40000 400000
50000 500000
select e,f from t1 where b > 0;
e f
10000 100000
20000 200000
30000 300000
40000 400000
50000 500000
select e,f from t1 where d > 0;
e f
10000 100000
20000 200000
30000 300000
40000 400000
50000 500000
update t1 set a = a+1, b = b+10;
explain select * from t1 where c > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 5 Using where
select * from t1 where c > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
4 40 300 3000 30000 300000
5 50 400 4000 40000 400000
6 60 500 5000 50000 500000
explain select * from t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 5 Using where
select * from t1 where b > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
4 40 300 3000 30000 300000
5 50 400 4000 40000 400000
6 60 500 5000 50000 500000
explain select * from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range d d 5 NULL 5 Using where
select * from t1 where d > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
4 40 300 3000 30000 300000
5 50 400 4000 40000 400000
6 60 500 5000 50000 500000
explain select a from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index d d 10 NULL 5 Using where; Using index
select a from t1 where d > 0;
a
2
3
4
5
6
select e,f from t1 where c > 0;
e f
10000 100000
20000 200000
30000 300000
40000 400000
50000 500000
select e,f from t1 where b > 0;
e f
10000 100000
20000 200000
30000 300000
40000 400000
50000 500000
select e,f from t1 where d > 0;
e f
10000 100000
20000 200000
30000 300000
40000 400000
50000 500000
delete from t1 where b > 35;
explain select * from t1 where c > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
select * from t1 where c > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
explain select * from t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 2 Using where
select * from t1 where b > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
explain select * from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range d d 5 NULL 2 Using where
select * from t1 where d > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
explain select a from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index d d 10 NULL 2 Using where; Using index
select a from t1 where d > 0;
a
2
3
select e,f from t1 where c > 0;
e f
10000 100000
20000 200000
select e,f from t1 where b > 0;
e f
10000 100000
20000 200000
select e,f from t1 where d > 0;
e f
10000 100000
20000 200000
alter table t1 drop index b, drop index d;
alter table t1 add clustering key d(d,a), add clustering key b(b);
explain select * from t1 where c > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
select * from t1 where c > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
explain select * from t1 where b > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL 2 Using where
select * from t1 where b > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
explain select * from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range d d 5 NULL 2 Using where
select * from t1 where d > 0;
a b c d e f
2 20 100 1000 10000 100000
3 30 200 2000 20000 200000
explain select a from t1 where d > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index d d 10 NULL 2 Using where; Using index
select a from t1 where d > 0;
a
2
3
select e,f from t1 where c > 0;
e f
10000 100000
20000 200000
select e,f from t1 where b > 0;
e f
10000 100000
20000 200000
select e,f from t1 where d > 0;
e f
10000 100000
20000 200000
DROP TABLE t1;
SET STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
create table t1 (a int, b varchar(20), c int, key (a));
insert into t1 values (1,"10",100);
insert into t1 values (2,"20",200);
insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500);
explain select * from t1 where a > 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 3 Using where
select * from t1 where a > 2;
a b c
3 30 300
4 40 400
5 50 500
select b from t1 where a > 2;
b
30
40
50
select c from t1 where a > 2;
c
300
400
500
delete from t1 where a <2;
explain select * from t1 where a >= 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where
select * from t1 where a >= 4;
a b c
4 40 400
5 50 500
select b from t1 where a >= 4;
b
40
50
select c from t1 where a >= 4;
c
400
500
update t1 set c = c+1000;
explain select * from t1 where a >= 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where
select * from t1 where a >= 4;
a b c
4 40 1400
5 50 1500
select b from t1 where a >= 4;
b
40
50
select c from t1 where a >= 4;
c
1400
1500
DROP TABLE t1;
SET STORAGE_ENGINE='tokudb';
*** Bug #22169 ***
DROP TABLE IF EXISTS t1;
create table t1 (a int, b varchar(20), c int, clustering key (b(3)));
insert into t1 values (1,"100000",100);
insert into t1 values (2,"200000",200);
insert into t1 values (3,"300000",300);
insert into t1 values (4,"400000",400);
insert into t1 values (5,"500000",500);
select b from t1 where b > "10";
b
100000
200000
300000
400000
500000
alter table t1 drop key b;
alter table t1 add clustering key b(b(2));
select b from t1 where b > "10";
b
100000
200000
300000
400000
500000
DROP TABLE t1;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment