Commit 8ea4ac60 authored by Zardosht Kasheff's avatar Zardosht Kasheff

[t:2922] move mvcc tests

git-svn-id: file:///svn/mysql/tests/mysql-test@23629 c7de825b-a66e-492c-adef-691d508d4ae1
parent 570ad08f
# Establish connection conn1 (user = root)
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo,foo_isam;
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
insert into foo values (5,5);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
select * from foo;
a b
1 1
2 2
3 1
4 3
begin;
delete from foo where b=2;
select * from foo;
a b
1 1
3 1
4 3
insert into foo values (5,5);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
select * from foo;
a b
1 1
2 2
3 1
4 3
create table foo_isam (a int, b int)engine=MyISAM;
begin;
insert into foo_isam select * from foo;
insert into foo values (5,5);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from foo;
a b
1 1
2 2
3 1
4 3
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
# Establish connection conn1 (user = root)
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo,foo_isam;
set session transaction isolation level read uncommitted;
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
insert into foo values (5,5);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
select * from foo;
a b
1 1
2 2
3 1
4 3
begin;
delete from foo where b=2;
select * from foo;
a b
1 1
3 1
4 3
insert into foo values (5,5);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
select * from foo;
a b
1 1
2 2
3 1
4 3
create table foo_isam (a int, b int)engine=MyISAM;
begin;
insert into foo_isam select * from foo;
insert into foo values (5,5);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from foo;
a b
1 1
2 2
3 1
4 3
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int);
select * from foo;
a
begin;
insert into foo values (1);
select * from foo;
a
1
rollback;
select * from foo;
a
set session transaction isolation level read committed;
begin;
insert into foo values (1);
select * from foo;
a
1
rollback;
select * from foo;
a
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(100) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
replace into foo values (1, "a");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 a
delete from foo;
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
replace into foo values (1,"abc");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abc
delete from foo;
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
select * from foo;
a b
select * from foo;
a b
1 a
select * from foo;
a b
select * from foo;
a b
1 abc
select * from foo;
a b
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1);
begin;
insert into foo values (2);
set session transaction isolation level serializable;
select * from foo;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
set session transaction isolation level read uncommitted;
select * from foo;
a
1
2
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level serializable;
create table foo (a int) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1);
begin;
select * from foo;
a
1
set session transaction isolation level serializable;
insert into foo values (3);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
set session transaction isolation level repeatable read;
insert into foo values (3);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
set session transaction isolation level read committed;
insert into foo values (3);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
set session transaction isolation level read uncommitted;
insert into foo values (3);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo,foo1;
set session transaction isolation level repeatable read;
create table foo (a int) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
begin;
select * from foo;
a
set session transaction isolation level repeatable read;
create table foo1(a int) engine=TokuDB;
insert into foo1 values(1);
select * from foo1;
ERROR HY000: Table definition has changed, please retry transaction
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo,foo1;
set session transaction isolation level read uncommitted;
create table foo (a int) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
begin;
select * from foo;
a
set session transaction isolation level repeatable read;
create table foo1(a int) engine=TokuDB;
insert into foo1 values(1);
select * from foo1;
a
1
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo,foo1;
set session transaction isolation level serializable;
create table foo (a int) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
begin;
select * from foo;
a
set session transaction isolation level repeatable read;
create table foo1(a int) engine=TokuDB;
insert into foo1 values(1);
select * from foo1;
a
1
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo,foo1;
set session transaction isolation level repeatable read;
create table foo (a int) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
begin;
select * from foo;
a
set session transaction isolation level repeatable read;
create table foo1(a int, b int, c int, primary key (a)) engine=TokuDB;
insert into foo1 values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500);
select a from foo1;
ERROR HY000: Table definition has changed, please retry transaction
select a from foo1 order by a desc;
ERROR HY000: Table definition has changed, please retry transaction
select * from foo1 where a=3;
ERROR HY000: Table definition has changed, please retry transaction
select * from foo1 where a>3;
ERROR HY000: Table definition has changed, please retry transaction
select * from foo1 where a>3 order by a desc;
ERROR HY000: Table definition has changed, please retry transaction
select * from foo1;
ERROR HY000: Table definition has changed, please retry transaction
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session tokudb_load_save_space=0;
set session transaction isolation level repeatable read;
create table foo (a int)engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session tokudb_load_save_space=0;
set session transaction isolation level repeatable read;
begin;
select * from foo;
a
begin;
insert into foo values (1),(2),(3);
# should return 1,2,3
select * from foo;
a
1
2
3
# should be empty
select * from foo;
a
# verify that a bulk load was done, by trying to insert and fail due to ER_LOCK_WAIT_TIMEOUT
insert into foo values (10000);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
commit;
# should see 1,2,3
select * from foo;
a
1
2
3
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session tokudb_load_save_space=1;
set session transaction isolation level repeatable read;
create table foo (a int)engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) DEFAULT NULL
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session tokudb_load_save_space=1;
set session transaction isolation level repeatable read;
begin;
select * from foo;
a
begin;
insert into foo values (1),(2),(3);
# should return 1,2,3
select * from foo;
a
1
2
3
# should be empty
select * from foo;
a
# verify that a bulk load was done, by trying to insert and fail due to ER_LOCK_WAIT_TIMEOUT
insert into foo values (10000);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
commit;
# should see 1,2,3
select * from foo;
a
1
2
3
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a))engine=TokuDB;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400);
begin;
# should read all four values
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
set session transaction isolation level repeatable read;
set session tokudb_load_save_space=0;
alter table foo add index (b);
# should read all four values
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
# should fail
select sum(b) from foo;
ERROR HY000: Table definition has changed, please retry transaction
commit;
# should return 100
select sum(b) from foo;
sum(b)
100
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
set session transaction isolation level repeatable read;
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int) engine=TokuDB;
insert into foo values (1);
begin;
select * from foo;
a
1
insert into foo values (1000000);
select * From foo;
a
1
select * from foo;
a
1
1000000
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a))engine=TokuDB;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400);
begin;
# should read all four values
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
set session transaction isolation level repeatable read;
set session tokudb_load_save_space=1;
alter table foo add index (b);
# should read all four values
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
# should fail
select sum(b) from foo;
ERROR HY000: Table definition has changed, please retry transaction
commit;
# should return 100
select sum(b) from foo;
sum(b)
100
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(100) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
replace into foo values (1, "a");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 a
replace into foo values (1,"abGARBAGE"), (2, "abGARBAGE");
replace into foo values (1,"ab"), (2, "ab");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 ab
2 ab
replace into foo values (1,"abcGARBAGE"),(2,"abcGARBAGE"),(3, "abcGARBAGE");
replace into foo values (1,"abc"),(2,"abc"),(3, "abc");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abc
2 abc
3 abc
replace into foo values (1,"abcdGARBAGE"),(2,"abcdGARBAGE"),(3, "abcdGARBAGE"),(4, "abcdGARBAGE");
replace into foo values (1,"abcd"),(2,"abcd"),(3, "abcd"),(4, "abcd");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abcd
2 abcd
3 abcd
4 abcd
select * from foo;
a b
commit;
select * from foo;
a b
1 a
commit;
select * from foo;
a b
1 ab
2 ab
commit;
select * from foo;
a b
1 abc
2 abc
3 abc
commit;
select * from foo;
a b
1 abcd
2 abcd
3 abcd
4 abcd
commit;
select * from foo;
a b
1 abcd
2 abcd
3 abcd
4 abcd
replace into foo values (1,"1"),(2,"2"),(3,"3"),(4,"4");
select * from foo;
a b
1 1
2 2
3 3
4 4
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(100) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
replace into foo values (1,"aGARBAGE");
replace into foo values (1, "a");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 a
replace into foo values (1,"abGARBAGE");
replace into foo values (1,"ab");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 ab
replace into foo values (1,"abcGARBAGE");
replace into foo values (1,"abc");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abc
replace into foo values (1,"abcdGARBAGE");
replace into foo values (1,"abcd");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abcd
select * from foo;
a b
commit;
select * from foo;
a b
1 a
commit;
select * from foo;
a b
1 ab
commit;
select * from foo;
a b
1 abc
commit;
select * from foo;
a b
1 abcd
commit;
select * from foo;
a b
1 abcd
replace into foo values (1,"1");
select * from foo;
a b
1 1
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(100) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
replace into foo values (1, "aGARBAGE");
replace into foo values (1, "a");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 a
replace into foo values (1, "delete1Garbage");
delete from foo;
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
replace into foo values (1,"abcGARBAGE");
replace into foo values (1,"abc");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abc
delete from foo;
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
select * from foo;
a b
commit;
select * from foo;
a b
1 a
commit;
select * from foo;
a b
commit;
select * from foo;
a b
1 abc
commit;
select * from foo;
a b
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b varchar (100), primary key (a))engine=TokuDB;
set session transaction isolation level repeatable read;
begin;
# should return nothing
select * from foo;
a b
insert into foo values (1, "G");
replace into foo values (1, "Ga");
replace into foo values (1, "Gar");
replace into foo values (1, "Garb");
replace into foo values (1, "Garba");
replace into foo values (1, "a");
begin;
# Should read (1, "a")
select * from foo;
a b
1 a
# Should be empty
select * from foo;
a b
commit;
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo,bar;
set session transaction isolation level repeatable read;
create table foo (a int, b varchar (100), primary key (a))engine=TokuDB;
create table bar like foo;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(100) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
show create table bar;
Table Create Table
bar CREATE TABLE `bar` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(100) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session transaction isolation level repeatable read;
begin;
# should be empty
select * from foo;
a b
begin;
# should be empty
select * from bar;
a b
begin;
# should be empty
select * from foo;
a b
insert into foo values (1,"g");
commit;
replace into foo values (1,"ga");
replace into foo values (1,"gar");
replace into foo values (1,"garb");
replace into foo values (1,"aaaa");
# should have one value
select * from foo;
a b
1 aaaa
commit;
# should be empty
select * from foo;
a b
commit;
# should be empty
select * from foo;
a b
commit;
set session transaction isolation level serializable;
DROP TABLE foo,bar;
SET STORAGE_ENGINE = 'tokudb';
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int);
select * from foo;
a
begin;
insert into foo values (1),(2),(3);
select * from foo;
a
1
2
3
rollback;
select * from foo;
a
optimize table foo;
Table Op Msg_type Msg_text
test.foo optimize status OK
select * from foo;
a
insert into foo values (1),(2),(3);
select * from foo;
a
1
2
3
optimize table foo;
Table Op Msg_type Msg_text
test.foo optimize status OK
select * from foo;
a
1
2
3
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int, b varchar(100), primary key (a))engine=TokudB;
# should return nothing
select * from foo;
a b
begin;
set session transaction isolation level repeatable read;
select * from foo;
a b
replace into foo values (1,"G");
replace into foo values (1,"GA");
replace into foo values (1,"GAR");
replace into foo values (1,"GARB");
replace into foo values (1,"GARBA");
replace into foo values (1,"GARBAG");
replace into foo values (1,"GARBAGE");
replace into foo values (1,"a");
# should return one element,
select * from foo;
a b
1 a
optimize table foo;
Table Op Msg_type Msg_text
test.foo optimize status OK
# should return nothing
select * from foo;
a b
commit;
# should return one element,
select * from foo;
a b
1 a
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level serializable;
create table foo (a int, b varchar(10), primary key (a))engine=TokuDB;
insert into foo values (1,"a");
set session transaction isolation level repeatable read;
begin;
# should read ONLY (1,"a")
select * from foo;
a b
1 a
delete from foo where a=1;
insert into foo values (2,"bb");
# should read ONLY (2,"bb")
begin;
select * from foo;
a b
2 bb
# should read ONLY (1,"a")
select * From foo;
a b
1 a
commit;
insert into foo values ("101000","asdf");
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokUDB;
insert into foo values (1,1),(2,2),(3,3),(4,4),(5,5),(10,10),(20,20),(30,30),(40,40),(50,50);
begin;
select * from foo;
a b
1 1
2 2
3 3
4 4
5 5
10 10
20 20
30 30
40 40
50 50
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
delete from foo where a > 5;
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
# should have just 4 values
select * from foo where a > 1;
a b
2 2
3 3
4 4
5 5
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
# 9 values
select * From foo where a > 1;
a b
2 2
3 3
4 4
5 5
10 10
20 20
30 30
40 40
50 50
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
set session transaction isolation level repeatable read;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,1);
begin;
select * from foo;
a b
1 1
begin;
select * from foo;
a b
1 1
replace into foo values (1,100), (2,200);
#transaction that did the insert about to read
select * from foo;
a b
1 100
2 200
#this should read just (1,1)
select * from foo;
a b
1 1
commit;
# this should read 2 values, (1,100) and (2,200)
select * from foo;
a b
1 100
2 200
#this should read just (1,1)
select * from foo;
a b
1 1
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokUDB;
insert into foo values (1,1),(2,2),(3,3),(4,4),(5,5),(10,10),(20,20),(30,30),(40,40),(50,50);
begin;
select * from foo;
a b
1 1
2 2
3 3
4 4
5 5
10 10
20 20
30 30
40 40
50 50
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
delete from foo where a < 10;
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
# should have just 4 values
select * from foo where a < 50;
a b
10 10
20 20
30 30
40 40
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
# 9 values
select * From foo where a < 50;
a b
1 1
2 2
3 3
4 4
5 5
10 10
20 20
30 30
40 40
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokUDB;
insert into foo values (1,1),(2,2),(3,3),(4,4),(5,5),(10,10),(20,20),(30,30),(40,40),(50,50);
begin;
select * from foo;
a b
1 1
2 2
3 3
4 4
5 5
10 10
20 20
30 30
40 40
50 50
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50;
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
# should have just 4 values
select * from foo where a > 1 and a < 50;
a b
3 3
5 5
20 20
40 40
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
# 8 values
select * from foo where a > 1 and a < 50;
a b
2 2
3 3
4 4
5 5
10 10
20 20
30 30
40 40
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, primary key (a))engine=TokuDB;
insert into foo values (1,10),(2,20),(3,30),(4,40),(5,50),(6,60),(7,70),(8,80),(9,90);
insert into foo values (10,100),(20,200),(30,300),(40,400),(50,500),(60,600),(70,700),(80,800),(90,900);
# row estimate should be 6
explain select count(*) from foo where a > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
select count(*) from foo where a > 30;
count(*)
6
delete from foo where a > 50;
# row estimate should be 2
explain select count(*) from foo where a > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
select count(*) from foo where a > 30;
count(*)
2
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
7 70 700
8 80 800
9 90 900
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
set session transaction isolation level repeatable read;
replace into foo values (5,50,555);
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 555
6 60 600
7 70 700
8 80 800
9 90 900
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
replace into foo values (5,50,111111111);
# should get (5,50,111111111)
select * from foo where b=50;
a b c
5 50 111111111
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
7 70 700
8 80 800
9 90 900
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
replace into foo values (5,50,1515);
set session transaction isolation level repeatable read;
begin;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level read committed;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
7 70 700
8 80 800
9 90 900
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
replace into foo values (5,50,1515);
set session transaction isolation level read committed;
begin;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level serializable;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
7 70 700
8 80 800
9 90 900
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
replace into foo values (5,50,1515);
set session transaction isolation level serializable;
begin;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# timeout
select * from foo where b=50;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level read uncommitted;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
7 70 700
8 80 800
9 90 900
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,500)
select * from foo where b=50;
a b c
5 50 500
replace into foo values (5,50,1515);
set session transaction isolation level read uncommitted;
begin;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
commit;
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should get (5,50,1515)
select * from foo where b=50;
a b c
5 50 1515
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo, foo_isam;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokUDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
create table foo_isam (a int, b int, c int) engine=MyISAM;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
a b c
1 10 100
2 20 200
3 30 300
4 40 400
5 50 500
6 60 600
7 70 700
8 80 800
9 90 900
# should use key b
explain select * from foo where b=50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
# should grab a read lock on the main table on (5,50,500)
insert into foo_isam select * from foo where b=50;
# should get (5,50,500)
select * From foo_isam;
a b c
5 50 500
set session transaction isolation level repeatable read;
# should fail with lock timeout because of read lock grabbed earlier
replace into foo values (5, 1,1);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
SET STORAGE_ENGINE = 'tokudb';
set session transaction isolation level repeatable read;
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokuDB;
insert into foo values (1,1);
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
#should read (1,1)
select * from foo;
a b
1 1
begin;
replace into foo values (1,100), (2,200);
commit;
#should read (1,100),(2,200)
select * from foo;
a b
1 100
2 200
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
set session transaction isolation level repeatable read;
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int, b int, primary key (a))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,1);
set session transaction isolation level repeatable read;
begin;
# Should read just (1,1)
select * from foo;
a b
1 1
set session transaction isolation level read committed;
begin;
# Should read just (1,1)
select * from foo;
a b
1 1
replace into foo values (1,10),(2,20);
# Should read just (1,1)
select * from foo;
a b
1 1
# Should read just (1,10), (2,20)
select * from foo;
a b
1 10
2 20
replace into foo values (1,100),(2,200),(3,300);
# Should read just (1,1)
select * from foo;
a b
1 1
commit;
# Should read just (1,100), (2,200),(3,300)
select * from foo;
a b
1 100
2 200
3 300
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a), key (b))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (100,100);
begin;
insert into foo values (1,100);
set session transaction isolation level repeatable read;
begin;
# should NOT see (1,100)
select * from foo;
a b
100 100
# should be empty
select * from foo where a=1;
a b
# should fail with a lock wait timeout
insert into foo values (1,1000);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
# should return two values
select * from foo;
a b
1 100
100 100
# should be empty
select * from foo where a=1;
a b
# should fail with a dup entry
insert into foo values (1,1000);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
commit;
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,100);
select * from foo;
a b
1 100
begin;
insert into foo values (100,100);
# should see (1,100)
select * from foo;
a b
1 100
100 100
set session transaction isolation level repeatable read;
# should NOT see (1,100)
select * from foo;
a b
1 100
# should see (1,100)
select * from foo;
a b
1 100
100 100
rollback;
# should NOT see (1,100)
select * from foo;
a b
1 100
set session transaction isolation level serializable;
DROP TABLE foo;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo, foo_isam;
set session transaction isolation level repeatable read;
create table foo ( a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500);
create table foo_isam (a int, b int, c int);
# should use key b
explain select * from foo where b=30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo ref b b 5 const 1 Using where
begin;
insert into foo_isam select * from foo where b=30;
set session transaction isolation level repeatable read;
# should get a lock error
replace into foo values (3,3,3);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
SET STORAGE_ENGINE = 'tokudb';
# Establish connection conn1 (user = root)
DROP TABLE IF EXISTS foo;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
Table Create Table
foo CREATE TABLE `foo` (
`a` int(11) NOT NULL DEFAULT '0',
`b` varchar(100) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=TOKUDB DEFAULT CHARSET=latin1
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
replace into foo values (1, "a");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 a
replace into foo values (1,"ab"), (2, "ab");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 ab
2 ab
replace into foo values (1,"abc"),(2,"abc"),(3, "abc");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abc
2 abc
3 abc
replace into foo values (1,"abcd"),(2,"abcd"),(3, "abcd"),(4, "abcd");
set session transaction isolation level repeatable read;
begin;
select * from foo;
a b
1 abcd
2 abcd
3 abcd
4 abcd
select * from foo;
a b
select * from foo;
a b
1 a
select * from foo;
a b
1 ab
2 ab
select * from foo;
a b
1 abc
2 abc
3 abc
select * from foo;
a b
1 abcd
2 abcd
3 abcd
4 abcd
set session transaction isolation level serializable;
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,foo_isam;
--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;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,5);
connection conn1;
rollback;
select * from foo;
begin;
delete from foo where b=2;
select * from foo;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,5);
connection conn1;
rollback;
select * from foo;
create table foo_isam (a int, b int)engine=MyISAM;
begin;
insert into foo_isam select * from foo;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,5);
select * from foo;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
\ No newline at end of file
# 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,foo_isam;
--enable_warnings
connection conn1;
set session transaction isolation level read uncommitted;
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;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,5);
connection conn1;
rollback;
select * from foo;
begin;
delete from foo where b=2;
select * from foo;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,5);
connection conn1;
rollback;
select * from foo;
create table foo_isam (a int, b int)engine=MyISAM;
begin;
insert into foo_isam select * from foo;
connection default;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (5,5);
select * from foo;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
set session transaction isolation level repeatable read;
create table foo (a int);
select * from foo;
begin;
insert into foo values (1);
select * from foo;
rollback;
select * from foo;
set session transaction isolation level read committed;
begin;
insert into foo values (1);
select * from foo;
rollback;
select * from foo;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
connect (conn3,localhost,root,,);
connect (conn4,localhost,root,,);
connect (conn5,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
connection conn1;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1, "a");
connection conn2;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
delete from foo;
connection conn3;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abc");
connection conn4;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
delete from foo;
connection conn5;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection conn1;
select * from foo;
connection conn2;
select * from foo;
connection conn3;
select * from foo;
connection conn4;
select * from foo;
connection conn5;
select * from foo;
connection default;
disconnect conn1;
disconnect conn2;
disconnect conn3;
disconnect conn4;
disconnect conn5;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
create table foo (a int) engine=TokuDB;
show create table foo;
insert into foo values (1);
begin;
insert into foo values (2);
connection conn1;
set session transaction isolation level serializable;
--error ER_LOCK_WAIT_TIMEOUT
select * from foo;
set session transaction isolation level read uncommitted;
select * from foo;
connection default;
commit;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# simple serializable test
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level serializable;
create table foo (a int) engine=TokuDB;
show create table foo;
insert into foo values (1);
begin;
select * from foo;
connection conn1;
set session transaction isolation level serializable;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (3);
set session transaction isolation level repeatable read;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (3);
set session transaction isolation level read committed;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (3);
set session transaction isolation level read uncommitted;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (3);
connection default;
commit;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo,foo1;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int) engine=TokuDB;
show create table foo;
begin;
select * from foo;
connection conn1;
set session transaction isolation level repeatable read;
create table foo1(a int) engine=TokuDB;
insert into foo1 values(1);
connection default;
--error ER_TABLE_DEF_CHANGED
select * from foo1;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
\ 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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo,foo1;
--enable_warnings
connection default;
set session transaction isolation level read uncommitted;
create table foo (a int) engine=TokuDB;
show create table foo;
begin;
select * from foo;
connection conn1;
set session transaction isolation level repeatable read;
create table foo1(a int) engine=TokuDB;
insert into foo1 values(1);
connection default;
select * from foo1;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
\ 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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo,foo1;
--enable_warnings
connection default;
set session transaction isolation level serializable;
create table foo (a int) engine=TokuDB;
show create table foo;
begin;
select * from foo;
connection conn1;
set session transaction isolation level repeatable read;
create table foo1(a int) engine=TokuDB;
insert into foo1 values(1);
connection default;
select * from foo1;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
\ 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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo,foo1;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int) engine=TokuDB;
show create table foo;
begin;
select * from foo;
connection conn1;
set session transaction isolation level repeatable read;
create table foo1(a int, b int, c int, primary key (a)) engine=TokuDB;
insert into foo1 values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500);
connection default;
--error ER_TABLE_DEF_CHANGED
select a from foo1;
--error ER_TABLE_DEF_CHANGED
select a from foo1 order by a desc;
--error ER_TABLE_DEF_CHANGED
select * from foo1 where a=3;
--error ER_TABLE_DEF_CHANGED
select * from foo1 where a>3;
--error ER_TABLE_DEF_CHANGED
select * from foo1 where a>3 order by a desc;
--error ER_TABLE_DEF_CHANGED
select * from foo1;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo,foo1;
\ 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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session tokudb_load_save_space=0;
set session transaction isolation level repeatable read;
create table foo (a int)engine=TokuDB;
show create table foo;
connection conn1;
set session tokudb_load_save_space=0;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
begin;
insert into foo values (1),(2),(3);
--echo # should return 1,2,3
select * from foo;
connection conn1;
--echo # should be empty
select * from foo;
--echo # verify that a bulk load was done, by trying to insert and fail due to ER_LOCK_WAIT_TIMEOUT
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (10000);
commit;
connection default;
commit;
connection conn1;
--echo # should see 1,2,3
select * from foo;
connection default;
commit;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session tokudb_load_save_space=1;
set session transaction isolation level repeatable read;
create table foo (a int)engine=TokuDB;
show create table foo;
connection conn1;
set session tokudb_load_save_space=1;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
begin;
insert into foo values (1),(2),(3);
--echo # should return 1,2,3
select * from foo;
connection conn1;
--echo # should be empty
select * from foo;
--echo # verify that a bulk load was done, by trying to insert and fail due to ER_LOCK_WAIT_TIMEOUT
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (10000);
commit;
connection default;
commit;
connection conn1;
--echo # should see 1,2,3
select * from foo;
connection default;
commit;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a))engine=TokuDB;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400);
begin;
--echo # should read all four values
select * from foo;
connection conn1;
set session transaction isolation level repeatable read;
set session tokudb_load_save_space=0;
alter table foo add index (b);
connection default;
--echo # should read all four values
select * from foo;
--echo # should fail
--error ER_TABLE_DEF_CHANGED
select sum(b) from foo;
commit;
--echo # should return 100
select sum(b) from foo;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# test simple MVCC, that a transaction does not read something committed after it
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
set session transaction isolation level repeatable read;
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level repeatable read;
create table foo (a int) engine=TokuDB;
insert into foo values (1);
begin;
select * from foo;
connection default;
insert into foo values (1000000);
connection conn1;
select * From foo;
connection default;
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
# ticket 895 is a query optimization problem with the primary key
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a))engine=TokuDB;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400);
begin;
--echo # should read all four values
select * from foo;
connection conn1;
set session transaction isolation level repeatable read;
set session tokudb_load_save_space=1;
alter table foo add index (b);
connection default;
--echo # should read all four values
select * from foo;
--echo # should fail
--error ER_TABLE_DEF_CHANGED
select sum(b) from foo;
commit;
--echo # should return 100
select sum(b) from foo;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
connect (conn3,localhost,root,,);
connect (conn4,localhost,root,,);
connect (conn5,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
connection conn1;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1, "a");
connection conn2;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abGARBAGE"), (2, "abGARBAGE");
replace into foo values (1,"ab"), (2, "ab");
connection conn3;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abcGARBAGE"),(2,"abcGARBAGE"),(3, "abcGARBAGE");
replace into foo values (1,"abc"),(2,"abc"),(3, "abc");
connection conn4;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abcdGARBAGE"),(2,"abcdGARBAGE"),(3, "abcdGARBAGE"),(4, "abcdGARBAGE");
replace into foo values (1,"abcd"),(2,"abcd"),(3, "abcd"),(4, "abcd");
connection conn5;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection conn1;
select * from foo;
commit;
connection conn2;
select * from foo;
commit;
connection conn3;
select * from foo;
commit;
connection conn4;
select * from foo;
commit;
connection conn5;
select * from foo;
commit;
connection default;
select * from foo;
replace into foo values (1,"1"),(2,"2"),(3,"3"),(4,"4");
select * from foo;
disconnect conn1;
disconnect conn2;
disconnect conn3;
disconnect conn4;
disconnect conn5;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
connect (conn3,localhost,root,,);
connect (conn4,localhost,root,,);
connect (conn5,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
connection conn1;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"aGARBAGE");
replace into foo values (1, "a");
connection conn2;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abGARBAGE");
replace into foo values (1,"ab");
connection conn3;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abcGARBAGE");
replace into foo values (1,"abc");
connection conn4;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abcdGARBAGE");
replace into foo values (1,"abcd");
connection conn5;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection conn1;
select * from foo;
commit;
connection conn2;
select * from foo;
commit;
connection conn3;
select * from foo;
commit;
connection conn4;
select * from foo;
commit;
connection conn5;
select * from foo;
commit;
connection default;
select * from foo;
replace into foo values (1,"1");
select * from foo;
disconnect conn1;
disconnect conn2;
disconnect conn3;
disconnect conn4;
disconnect conn5;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
connect (conn3,localhost,root,,);
connect (conn4,localhost,root,,);
connect (conn5,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
connection conn1;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1, "aGARBAGE");
replace into foo values (1, "a");
connection conn2;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1, "delete1Garbage");
delete from foo;
connection conn3;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abcGARBAGE");
replace into foo values (1,"abc");
connection conn4;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
delete from foo;
connection conn5;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection conn1;
select * from foo;
commit;
connection conn2;
select * from foo;
commit;
connection conn3;
select * from foo;
commit;
connection conn4;
select * from foo;
commit;
connection conn5;
select * from foo;
commit;
connection default;
disconnect conn1;
disconnect conn2;
disconnect conn3;
disconnect conn4;
disconnect conn5;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b varchar (100), primary key (a))engine=TokuDB;
connection conn1;
set session transaction isolation level repeatable read;
begin;
--echo # should return nothing
select * from foo;
connection default;
insert into foo values (1, "G");
replace into foo values (1, "Ga");
replace into foo values (1, "Gar");
replace into foo values (1, "Garb");
replace into foo values (1, "Garba");
replace into foo values (1, "a");
connection conn2;
begin;
--echo # Should read (1, "a")
select * from foo;
connection conn1;
--echo # Should be empty
select * from foo;
connection conn2;
commit;
connection conn1;
commit;
connection default;
disconnect conn1;
disconnect conn2;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
connect (conn3,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo,bar;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b varchar (100), primary key (a))engine=TokuDB;
create table bar like foo;
show create table foo;
show create table bar;
connection conn1;
set session transaction isolation level repeatable read;
begin;
--echo # should be empty
select * from foo;
connection default;
begin;
--echo # should be empty
select * from bar;
connection conn2;
begin;
--echo # should be empty
select * from foo;
connection default;
insert into foo values (1,"g");
commit;
replace into foo values (1,"ga");
replace into foo values (1,"gar");
replace into foo values (1,"garb");
replace into foo values (1,"aaaa");
connection conn3;
--echo # should have one value
select * from foo;
commit;
connection conn2;
--echo # should be empty
select * from foo;
commit;
connection conn1;
--echo # should be empty
select * from foo;
commit;
connection default;
disconnect conn1;
disconnect conn2;
disconnect conn3;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo,bar;
\ No newline at end of file
# ticket 895 is a query optimization problem with the primary key
SET STORAGE_ENGINE = 'tokudb';
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
set session transaction isolation level repeatable read;
create table foo (a int);
select * from foo;
begin;
insert into foo values (1),(2),(3);
select * from foo;
rollback;
select * from foo;
optimize table foo;
select * from foo;
insert into foo values (1),(2),(3);
select * from foo;
optimize table foo;
select * from foo;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
create table foo (a int, b varchar(100), primary key (a))engine=TokudB;
--echo # should return nothing
select * from foo;
connection conn1;
begin;
set session transaction isolation level repeatable read;
select * from foo;
connection default;
replace into foo values (1,"G");
replace into foo values (1,"GA");
replace into foo values (1,"GAR");
replace into foo values (1,"GARB");
replace into foo values (1,"GARBA");
replace into foo values (1,"GARBAG");
replace into foo values (1,"GARBAGE");
replace into foo values (1,"a");
--echo # should return one element,
select * from foo;
optimize table foo;
connection conn1;
--echo # should return nothing
select * from foo;
commit;
connection default;
--echo # should return one element,
select * from foo;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# verify that serializable properly reads provisional delete and actual value
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level serializable;
create table foo (a int, b varchar(10), primary key (a))engine=TokuDB;
insert into foo values (1,"a");
connection conn1;
set session transaction isolation level repeatable read;
begin;
--echo # should read ONLY (1,"a")
select * from foo;
connection default;
delete from foo where a=1;
insert into foo values (2,"bb");
--echo # should read ONLY (2,"bb")
begin;
select * from foo;
connection conn1;
--echo # should read ONLY (1,"a")
select * From foo;
commit;
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values ("101000","asdf");
connection default;
commit;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# simple keyrange64 test, ensure that it reads number of leafentries in the system
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level repeatable read;
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokUDB;
insert into foo values (1,1),(2,2),(3,3),(4,4),(5,5),(10,10),(20,20),(30,30),(40,40),(50,50);
connection conn1;
begin;
select * from foo;
--echo # number of rows should be 9
explain select * from foo where a > 1;
connection default;
delete from foo where a > 5;
--echo # number of rows should be 9
explain select * from foo where a > 1;
--echo # should have just 4 values
select * from foo where a > 1;
connection conn1;
--echo # number of rows should be 9
explain select * from foo where a > 1;
--echo # 9 values
select * From foo where a > 1;
commit;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# test simple mvcc, that a transaction does not read a transaction's element that was live when it began
set session transaction isolation level repeatable read;
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokuDB;
show create table foo;
insert into foo values (1,1);
begin;
select * from foo;
connection default;
begin;
select * from foo;
connection conn1;
replace into foo values (1,100), (2,200);
--echo #transaction that did the insert about to read
select * from foo;
connection default;
--echo #this should read just (1,1)
select * from foo;
connection conn1;
commit;
--echo # this should read 2 values, (1,100) and (2,200)
select * from foo;
connection default;
--echo #this should read just (1,1)
select * from foo;
commit;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# simple keyrange64 test, ensure that it reads number of leafentries in the system
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level repeatable read;
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokUDB;
insert into foo values (1,1),(2,2),(3,3),(4,4),(5,5),(10,10),(20,20),(30,30),(40,40),(50,50);
connection conn1;
begin;
select * from foo;
--echo # number of rows should be 9
explain select * from foo where a < 50;
connection default;
delete from foo where a < 10;
--echo # number of rows should be 9
explain select * from foo where a < 50;
--echo # should have just 4 values
select * from foo where a < 50;
connection conn1;
--echo # number of rows should be 9
explain select * from foo where a < 50;
--echo # 9 values
select * From foo where a < 50;
commit;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# simple keyrange64 test, ensure that it reads number of leafentries in the system
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level repeatable read;
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokUDB;
insert into foo values (1,1),(2,2),(3,3),(4,4),(5,5),(10,10),(20,20),(30,30),(40,40),(50,50);
connection conn1;
begin;
select * from foo;
--echo # number of rows should be 8
explain select * from foo where a > 1 and a < 50;
connection default;
delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50;
--echo # number of rows should be 8
explain select * from foo where a > 1 and a < 50;
--echo # should have just 4 values
select * from foo where a > 1 and a < 50;
connection conn1;
--echo # number of rows should be 8
explain select * from foo where a > 1 and a < 50;
--echo # 8 values
select * from foo where a > 1 and a < 50;
commit;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# tests that deletes are cleaned by verifying that row estimate goes down
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,20),(3,30),(4,40),(5,50),(6,60),(7,70),(8,80),(9,90);
insert into foo values (10,100),(20,200),(30,300),(40,400),(50,500),(60,600),(70,700),(80,800),(90,900);
--echo # row estimate should be 6
explain select count(*) from foo where a > 30;
select count(*) from foo where a > 30;
delete from foo where a > 50;
--echo # row estimate should be 2
explain select count(*) from foo where a > 30;
select count(*) from foo where a > 30;
DROP TABLE foo;
\ No newline at end of file
# verify a db_get sees data that transaction inserted, and that it does not read data that is too new
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
connection conn1;
set session transaction isolation level repeatable read;
replace into foo values (5,50,555);
select * from foo;
connection default;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
replace into foo values (5,50,111111111);
--echo # should get (5,50,111111111)
select * from foo where b=50;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# verify a db_get does not read a transaction's data because it is in live list
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
replace into foo values (5,50,1515);
connection conn1;
set session transaction isolation level repeatable read;
begin;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
connection default;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection conn1;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# verify a db_get does not read a read committed transaction's data because it is in live list
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level read committed;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
replace into foo values (5,50,1515);
connection conn1;
set session transaction isolation level read committed;
begin;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
connection default;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection conn1;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# verify a db_get does not read a read committed transaction's data because it is in live list
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level serializable;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
replace into foo values (5,50,1515);
connection conn1;
set session transaction isolation level serializable;
begin;
--echo # should use key b
explain select * from foo where b=50;
--echo # timeout
--error ER_LOCK_WAIT_TIMEOUT
select * from foo where b=50;
connection default;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection conn1;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# verify a db_get does not read a read committed transaction's data because it is in live list
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level read uncommitted;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,500)
select * from foo where b=50;
replace into foo values (5,50,1515);
connection conn1;
set session transaction isolation level read uncommitted;
begin;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection default;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection conn1;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
commit;
--echo # should use key b
explain select * from foo where b=50;
--echo # should get (5,50,1515)
select * from foo where b=50;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo, foo_isam;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, c int, primary key (a), key (b))engine=TokUDB;
show create table foo;
create table foo_isam (a int, b int, c int) engine=MyISAM;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500),(6,60,600),(7,70,700),(8,80,800),(9,90,900);
begin;
select * from foo;
--echo # should use key b
explain select * from foo where b=50;
--echo # should grab a read lock on the main table on (5,50,500)
insert into foo_isam select * from foo where b=50;
--echo # should get (5,50,500)
select * From foo_isam;
connection conn1;
set session transaction isolation level repeatable read;
--echo # should fail with lock timeout because of read lock grabbed earlier
--error ER_LOCK_WAIT_TIMEOUT
replace into foo values (5, 1,1);
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
\ No newline at end of file
# test that we read data that was committed before we began
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
set session transaction isolation level repeatable read;
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection conn1;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokuDB;
insert into foo values (1,1);
show create table foo;
--echo #should read (1,1)
select * from foo;
begin;
replace into foo values (1,100), (2,200);
commit;
connection default;
--echo #should read (1,100),(2,200)
select * from foo;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# verify that repeatable read uses one snapshot, whereas read committed keeps taking new ones
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
set session transaction isolation level repeatable read;
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
create table foo (a int, b int, primary key (a))engine=TokuDB;
show create table foo;
insert into foo values (1,1);
connection conn1;
set session transaction isolation level repeatable read;
begin;
--echo # Should read just (1,1)
select * from foo;
connection conn2;
set session transaction isolation level read committed;
begin;
--echo # Should read just (1,1)
select * from foo;
connection default;
replace into foo values (1,10),(2,20);
connection conn1;
--echo # Should read just (1,1)
select * from foo;
connection conn2;
--echo # Should read just (1,10), (2,20)
select * from foo;
connection default;
replace into foo values (1,100),(2,200),(3,300);
connection conn1;
--echo # Should read just (1,1)
select * from foo;
commit;
connection conn2;
--echo # Should read just (1,100), (2,200),(3,300)
select * from foo;
commit;
connection default;
disconnect conn1;
disconnect conn2;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# make sure reads done during writes take read locks
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a), key (b))engine=TokuDB;
show create table foo;
insert into foo values (100,100);
begin;
insert into foo values (1,100);
connection conn1;
set session transaction isolation level repeatable read;
begin;
--echo # should NOT see (1,100)
select * from foo;
--echo # should be empty
select * from foo where a=1;
--echo # should fail with a lock wait timeout
--error ER_LOCK_WAIT_TIMEOUT
insert into foo values (1,1000);
connection default;
commit;
--echo # should return two values
select * from foo;
connection conn1;
--echo # should be empty
select * from foo where a=1;
--echo # should fail with a dup entry
--error ER_DUP_ENTRY
insert into foo values (1,1000);
commit;
connection default;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# make sure reads done during writes take read locks
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo (a int, b int, primary key (a))engine=TokuDB;
show create table foo;
insert into foo values (1,100);
select * from foo;
begin;
insert into foo values (100,100);
--echo # should see (1,100)
select * from foo;
connection conn1;
set session transaction isolation level repeatable read;
--echo # should NOT see (1,100)
select * from foo;
connection default;
--echo # should see (1,100)
select * from foo;
rollback;
--echo # should NOT see (1,100)
select * from foo;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
# verify that serializable get of a repeatable read transaction grabs read lock
#--source include/have_tokudb.inc
SET STORAGE_ENGINE = 'tokudb';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo, foo_isam;
--enable_warnings
connection default;
set session transaction isolation level repeatable read;
create table foo ( a int, b int, c int, primary key (a), key (b))engine=TokuDB;
show create table foo;
insert into foo values (1,10,100),(2,20,200),(3,30,300),(4,40,400),(5,50,500);
create table foo_isam (a int, b int, c int);
--echo # should use key b
explain select * from foo where b=30;
begin;
insert into foo_isam select * from foo where b=30;
connection conn1;
set session transaction isolation level repeatable read;
--echo # should get a lock error
--error ER_LOCK_WAIT_TIMEOUT
replace into foo values (3,3,3);
connection default;
commit;
disconnect conn1;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo, foo_isam;
\ 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';
--echo # Establish connection conn1 (user = root)
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);
connect (conn3,localhost,root,,);
connect (conn4,localhost,root,,);
connect (conn5,localhost,root,,);
--disable_warnings
DROP TABLE IF EXISTS foo;
--enable_warnings
connection default;
create table foo (a int, b varchar (100), primary key (a)) engine=TokuDB;
show create table foo;
connection conn1;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1, "a");
connection conn2;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"ab"), (2, "ab");
connection conn3;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abc"),(2,"abc"),(3, "abc");
connection conn4;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection default;
replace into foo values (1,"abcd"),(2,"abcd"),(3, "abcd"),(4, "abcd");
connection conn5;
set session transaction isolation level repeatable read;
begin;
select * from foo;
connection conn1;
select * from foo;
connection conn2;
select * from foo;
connection conn3;
select * from foo;
connection conn4;
select * from foo;
connection conn5;
select * from foo;
connection default;
disconnect conn1;
disconnect conn2;
disconnect conn3;
disconnect conn4;
disconnect conn5;
connection default;
# Final cleanup.
set session transaction isolation level serializable;
DROP TABLE foo;
\ No newline at end of file
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