Skip to content

Commit aaa9ed3

Browse files
author
mleich@three.local.lan
committed
This changeset belongs to
WL#3397 Refactoring storage engine test cases (for falcon) It contains also fixes according to code review. Contents: Testcases which were in history dedicated to InnoDB or MyISAM only. Modifications: 1. Shift the main testing code into include/<testing field>.inc Introduce $variables which can be used to omit tests for features which are not supported by certain storage engines. 2. The storage engine to be tested is assigned within the toplevel script (t/<whatever>_<engine>.test) via variable $engine_type and the the main testing code is sourced from include/<testing field>.inc 3. Some toplevel testscripts have to be renamed to - avoid immediate or future namespace clashes - show via filename which storage engine is tested 4. Minor code cleanup like remove trailing spaces, some additional comments ....
1 parent a60a43c commit aaa9ed3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+8747
-2319
lines changed

mysql-test/t/innodb_concurrent.test renamed to mysql-test/include/concurrent.inc

+23-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
1+
# include/concurrent.inc
12
#
2-
# Concurrent InnoDB tests, mainly in UPDATE's
3+
# Concurrent tests for transactional storage engines, mainly in UPDATE's
34
# Bug#3300
45
# Designed and tested by Sinisa Milivojevic, sinisa@mysql.com
56
#
67
# two non-interfering UPDATE's not changing result set
78
#
8-
9-
# test takes circa 5 minutes to run, so it's big
10-
-- source include/big_test.inc
9+
# The variable
10+
# $engine_type -- storage engine to be tested
11+
# has to be set before sourcing this script.
12+
#
13+
# Last update:
14+
# 2006-08-02 ML test refactored
15+
# old name was t/innodb_concurrent.test
16+
# main code went into include/concurrent.inc
17+
#
1118

1219
connection default;
20+
eval SET SESSION STORAGE_ENGINE = $engine_type;
21+
--disable_warnings
1322
drop table if exists t1;
14-
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
23+
--enable_warnings
24+
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
1525
connect (thread1, localhost, mysqltest,,);
1626
connection thread1;
27+
eval SET SESSION STORAGE_ENGINE = $engine_type;
1728
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
1829
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
1930
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -57,7 +68,7 @@ drop table t1;
5768
#
5869
#connect (thread1, localhost, mysqltest,,);
5970
connection thread1;
60-
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
71+
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
6172
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
6273
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
6374
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -103,7 +114,7 @@ drop table t1;
103114

104115
#connect (thread1, localhost, mysqltest,,);
105116
connection thread1;
106-
create table t1 (a int not null, b int not null) engine=innodb;
117+
create table t1 (a int not null, b int not null);
107118
insert into t1 values (1,1),(2,1),(3,1),(4,1);
108119
select get_lock("hello2",1000);
109120
#connect (thread2, localhost, mysqltest,,);
@@ -132,7 +143,7 @@ drop table t1;
132143
#
133144
#connect (thread1, localhost, mysqltest,,);
134145
connection thread1;
135-
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
146+
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
136147
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
137148
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
138149
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -175,7 +186,7 @@ drop table t1;
175186
#
176187
#connect (thread1, localhost, mysqltest,,);
177188
connection thread1;
178-
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
189+
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
179190
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
180191
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
181192
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -218,7 +229,7 @@ drop table t1;
218229
#
219230
#connect (thread1, localhost, mysqltest,,);
220231
connection thread1;
221-
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
232+
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
222233
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
223234
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
224235
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -261,7 +272,7 @@ drop table t1;
261272
#
262273
#connect (thread1, localhost, mysqltest,,);
263274
connection thread1;
264-
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
275+
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
265276
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
266277
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
267278
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
@@ -305,7 +316,7 @@ drop table t1;
305316
#
306317
#connect (thread1, localhost, mysqltest,,);
307318
connection thread1;
308-
create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
319+
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
309320
insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
310321
insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
311322
insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");

mysql-test/include/deadlock.inc

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# include/deadlock.inc
2+
#
3+
# The variable
4+
# $engine_type -- storage engine to be tested
5+
# has to be set before sourcing this script.
6+
#
7+
# Last update:
8+
# 2006-07-26 ML refactoring + print when connection is switched
9+
# old name was t/innodb-deadlock.test
10+
# main code went into include/deadlock.inc
11+
#
12+
13+
--echo # Establish connection con1 (user=root)
14+
connect (con1,localhost,root,,);
15+
--echo # Establish connection con2 (user=root)
16+
connect (con2,localhost,root,,);
17+
18+
--disable_warnings
19+
drop table if exists t1,t2;
20+
--enable_warnings
21+
22+
#
23+
# Testing of FOR UPDATE
24+
#
25+
26+
--echo # Switch to connection con1
27+
connection con1;
28+
eval create table t1 (id integer, x integer) engine = $engine_type;
29+
insert into t1 values(0, 0);
30+
set autocommit=0;
31+
SELECT * from t1 where id = 0 FOR UPDATE;
32+
33+
--echo # Switch to connection con2
34+
connection con2;
35+
set autocommit=0;
36+
37+
# The following query should hang because con1 is locking the record
38+
--send
39+
update t1 set x=2 where id = 0;
40+
--sleep 2
41+
42+
--echo # Switch to connection con1
43+
connection con1;
44+
update t1 set x=1 where id = 0;
45+
select * from t1;
46+
commit;
47+
48+
--echo # Switch to connection con2
49+
connection con2;
50+
reap;
51+
commit;
52+
53+
--echo # Switch to connection con1
54+
connection con1;
55+
select * from t1;
56+
commit;
57+
58+
drop table t1;
59+
#
60+
# Testing of FOR UPDATE
61+
#
62+
63+
--echo # Switch to connection con1
64+
connection con1;
65+
eval create table t1 (id integer, x integer) engine = $engine_type;
66+
eval create table t2 (b integer, a integer) engine = $engine_type;
67+
insert into t1 values(0, 0), (300, 300);
68+
insert into t2 values(0, 10), (1, 20), (2, 30);
69+
commit;
70+
set autocommit=0;
71+
select * from t2;
72+
update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
73+
select * from t2;
74+
select * from t1;
75+
76+
--echo # Switch to connection con2
77+
connection con2;
78+
set autocommit=0;
79+
80+
# The following query should hang because con1 is locking the record
81+
--send
82+
update t1 set x=2 where id = 0;
83+
--sleep 2
84+
85+
--echo # Switch to connection con1
86+
connection con1;
87+
update t1 set x=1 where id = 0;
88+
select * from t1;
89+
commit;
90+
91+
--echo # Switch to connection con2
92+
connection con2;
93+
reap;
94+
commit;
95+
96+
--echo # Switch to connection con1
97+
connection con1;
98+
select * from t1;
99+
commit;
100+
101+
drop table t1, t2;
102+
eval create table t1 (id integer, x integer) engine = $engine_type;
103+
eval create table t2 (b integer, a integer) engine = $engine_type;
104+
insert into t1 values(0, 0), (300, 300);
105+
insert into t2 values(0, 0), (1, 20), (2, 30);
106+
commit;
107+
108+
--echo # Switch to connection con1
109+
connection con1;
110+
select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
111+
select * from t2;
112+
select * from t1;
113+
114+
--echo # Switch to connection con2
115+
connection con2;
116+
117+
# The following query should hang because con1 is locking the record
118+
update t2 set a=2 where b = 0;
119+
select * from t2;
120+
--send
121+
update t1 set x=2 where id = 0;
122+
--sleep 2
123+
124+
--echo # Switch to connection con1
125+
connection con1;
126+
update t1 set x=1 where id = 0;
127+
select * from t1;
128+
commit;
129+
130+
--echo # Switch to connection con2
131+
connection con2;
132+
reap;
133+
commit;
134+
135+
--echo # Switch to connection con1
136+
connection con1;
137+
select * from t1;
138+
commit;
139+
140+
# Cleanup
141+
--echo # Switch to connection default + disconnect con1 and con2
142+
connection default;
143+
disconnect con1;
144+
disconnect con2;
145+
drop table t1, t2;
146+
147+
# End of 4.1 tests

mysql-test/t/handler.test renamed to mysql-test/include/handler.inc

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
# include/handler.inc
2+
#
3+
# The variable
4+
# $engine_type -- storage engine to be tested
5+
# has to be set before sourcing this script.
16
#
27
# test of HANDLER ...
38
#
9+
# Last update:
10+
# 2006-07-31 ML test refactored (MySQL 5.1)
11+
# code of t/handler.test and t/innodb_handler.test united
12+
# main testing code put into include/handler.inc
13+
#
414

5-
# should work in embedded server after mysqltest is fixed
6-
-- source include/not_embedded.inc
15+
eval SET SESSION STORAGE_ENGINE = $engine_type;
716

817
--disable_warnings
918
drop table if exists t1,t3,t4,t5;
@@ -73,6 +82,22 @@ handler t2 read next;
7382
handler t2 read last;
7483
handler t2 close;
7584

85+
handler t1 open;
86+
handler t1 read a next; # this used to crash as a bug#5373
87+
handler t1 read a next;
88+
handler t1 close;
89+
90+
handler t1 open;
91+
handler t1 read a prev; # this used to crash as a bug#5373
92+
handler t1 read a prev;
93+
handler t1 close;
94+
95+
handler t1 open as t2;
96+
handler t2 read first;
97+
eval alter table t1 engine = $engine_type;
98+
--error 1109
99+
handler t2 read first;
100+
76101
#
77102
# DROP TABLE / ALTER TABLE
78103
#
@@ -378,6 +403,13 @@ reap;
378403
connection default;
379404
drop table t1;
380405

406+
CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2));
407+
INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
408+
HANDLER t1 OPEN;
409+
HANDLER t1 READ `primary` = (1, 1000);
410+
HANDLER t1 READ `primary` PREV;
411+
DROP TABLE t1;
412+
381413
# End of 4.1 tests
382414

383415
#

0 commit comments

Comments
 (0)