~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/include/read_many_rows.inc

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# include/read_many_rows.inc
 
2
#
 
3
# Test how filesort and buffered-record-reads works
 
4
# This test needs a lot of time.
 
5
#
 
6
# The variables
 
7
#     $engine_type       -- storage engine to be tested
 
8
#     $other_engine_type -- storage engine <> $engine_type, if possible
 
9
#                           1. $other_engine_type must allow to store many rows
 
10
#                              without using non standard server options
 
11
#                              (does not need a t/read_many_rows_*-master.opt file)
 
12
#                           2. $other_engine_type must point to an all time
 
13
#                              available storage engine
 
14
#                              2006-08 MySQL 5.1 MyISAM and MEMORY only
 
15
# have to be set before sourcing this script.
 
16
#
 
17
# Last update:
 
18
# 2006-08-03 ML test refactored (MySQL 5.1)
 
19
#               main code t/innodb-big.test --> include/read_many_rows.inc
 
20
#
 
21
 
 
22
eval SET SESSION STORAGE_ENGINE = $engine_type;
 
23
 
 
24
--disable_warnings
 
25
DROP TABLE IF EXISTS t1, t2, t3, t4;
 
26
--enable_warnings
 
27
 
 
28
eval CREATE TABLE t1 (id INTEGER) ENGINE=$other_engine_type;
 
29
CREATE TABLE t2 (id INTEGER PRIMARY KEY);
 
30
CREATE TABLE t3 (a CHAR(32) PRIMARY KEY,id INTEGER);
 
31
eval CREATE TABLE t4 (a CHAR(32) PRIMARY KEY,id INTEGER) ENGINE=$other_engine_type;
 
32
 
 
33
INSERT INTO t1 (id) VALUES (1);
 
34
INSERT INTO t1 SELECT id+1 FROM t1;
 
35
INSERT INTO t1 SELECT id+2 FROM t1;
 
36
INSERT INTO t1 SELECT id+4 FROM t1;
 
37
INSERT INTO t1 SELECT id+8 FROM t1;
 
38
INSERT INTO t1 SELECT id+16 FROM t1;
 
39
INSERT INTO t1 SELECT id+32 FROM t1;
 
40
INSERT INTO t1 SELECT id+64 FROM t1;
 
41
INSERT INTO t1 SELECT id+128 FROM t1;
 
42
INSERT INTO t1 SELECT id+256 FROM t1;
 
43
INSERT INTO t1 SELECT id+512 FROM t1;
 
44
INSERT INTO t1 SELECT id+1024 FROM t1;
 
45
INSERT INTO t1 SELECT id+2048 FROM t1;
 
46
INSERT INTO t1 SELECT id+4096 FROM t1;
 
47
INSERT INTO t1 SELECT id+8192 FROM t1;
 
48
INSERT INTO t1 SELECT id+16384 FROM t1;
 
49
INSERT INTO t1 SELECT id+32768 FROM t1;
 
50
INSERT INTO t1 SELECT id+65536 FROM t1;
 
51
INSERT INTO t1 SELECT id+131072 FROM t1;
 
52
INSERT INTO t1 SELECT id+262144 FROM t1;
 
53
INSERT INTO t1 SELECT id+524288 FROM t1;
 
54
INSERT INTO t1 SELECT id+1048576 FROM t1;
 
55
 
 
56
INSERT INTO t2 SELECT * FROM t1;
 
57
INSERT INTO t3 SELECT CONCAT(id),id FROM t2 ORDER BY -id;
 
58
INSERT INTO t4 SELECT * FROM t3 ORDER BY CONCAT(a);
 
59
SELECT SUM(id) FROM t3;
 
60
 
 
61
DROP TABLE t1,t2,t3,t4;
 
62
 
 
63
#
 
64
# Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
 
65
#
 
66
CREATE TABLE t1 (f1 int NOT NULL) ENGINE=InnoDB;
 
67
CREATE TABLE t2 (f2 int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
 
68
DELIMITER |;
 
69
CREATE TRIGGER t1_bi before INSERT
 
70
    ON t1 FOR EACH ROW
 
71
BEGIN
 
72
  DECLARE CONTINUE HANDLER FOR SQLSTATE '40001' SET @a:= 'deadlock';
 
73
  DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception';
 
74
  INSERT INTO t2 (f2) VALUES (1);
 
75
  DELETE FROM t2 WHERE f2 = 1;
 
76
END;|
 
77
 
 
78
CREATE PROCEDURE proc24989()
 
79
BEGIN
 
80
  DECLARE CONTINUE HANDLER FOR SQLSTATE '40001' SET @b:= 'deadlock';
 
81
  DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception';
 
82
  INSERT INTO t2 (f2) VALUES (1);
 
83
  DELETE FROM t2 WHERE f2 = 1;
 
84
END;|
 
85
 
 
86
create procedure proc24989_2()
 
87
    deterministic
 
88
begin
 
89
  declare continue handler for sqlexception
 
90
    select 'Outer handler' as 'exception';
 
91
 
 
92
  insert into t1 values(1);
 
93
  select "continued";
 
94
end|
 
95
 
 
96
DELIMITER ;|
 
97
 
 
98
connect (con1,localhost,root,,);
 
99
connect (con2,localhost,root,,);
 
100
 
 
101
connection con1;
 
102
start transaction;
 
103
insert into t1 values(1);
 
104
 
 
105
connection con2;
 
106
start transaction;
 
107
insert into t2 values(123);
 
108
send insert into t1 values(1);
 
109
 
 
110
connection con1;
 
111
--sleep 1
 
112
insert into t1 values(1);
 
113
 
 
114
connection con2;
 
115
--error 1213
 
116
reap;
 
117
select @a;
 
118
# check that the whole transaction was rolled back
 
119
select * from t2;
 
120
 
 
121
connection con1;
 
122
commit;
 
123
start transaction;
 
124
insert into t1 values(1);
 
125
 
 
126
connection con2;
 
127
start transaction;
 
128
insert into t2 values(123);
 
129
send call proc24989();
 
130
 
 
131
connection con1;
 
132
--sleep 1
 
133
insert into t1 values(1);
 
134
 
 
135
connection con2;
 
136
reap;
 
137
select @a,@b;
 
138
# check that the whole transaction was rolled back
 
139
select * from t2;
 
140
 
 
141
connection con1;
 
142
commit;
 
143
start transaction;
 
144
insert into t1 values(1);
 
145
 
 
146
connection con2;
 
147
start transaction;
 
148
insert into t2 values(123);
 
149
send call proc24989_2();
 
150
 
 
151
connection con1;
 
152
--sleep 1
 
153
insert into t1 values(1);
 
154
commit;
 
155
 
 
156
connection con2;
 
157
reap;
 
158
# check that the whole transaction was rolled back
 
159
select * from t2;
 
160
 
 
161
disconnect con1;
 
162
disconnect con2;
 
163
connection default;
 
164
drop procedure proc24989;
 
165
drop procedure proc24989_2;
 
166
drop table t1,t2;
 
167