~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
# This test doesn't work with the embedded version as this code
2
# assumes that one query is running while we are doing queries on
3
# a second connection.
4
# This would work if mysqltest run would be threaded and handle each
5
# connection in a separate thread.
6
#
7
-- source include/not_embedded.inc
8
9
# Disable concurrent inserts to avoid test failures when reading the
10
# connection id which was inserted into a table by another thread.
11
set @old_concurrent_insert= @@global.concurrent_insert;
12
set @@global.concurrent_insert= 0;
13
14
connect (con1, localhost, root,,);
15
connect (con2, localhost, root,,);
16
17
#remember id of con1
18
connection con1;
19
--disable_warnings
20
drop table if exists t1, t2, t3;
21
--enable_warnings
22
23
--disable_reconnect
24
create table t1 (kill_id int);
25
insert into t1 values(connection_id());
26
27
#kill con1
28
connection con2;
29
select ((@id := kill_id) - kill_id) from t1; 
30
kill @id;
31
32
connection con1;
33
--sleep 2
34
35
--disable_query_log
36
--disable_result_log
37
# One of the following statements should fail
38
--error 0,2006,2013
39
select 1;
40
--error 0,2006,2013
41
select 1;
42
--enable_query_log
43
--enable_result_log
44
45
--enable_reconnect
46
# this should work, and we should have a new connection_id()
47
select ((@id := kill_id) - kill_id) from t1;
48
select @id != connection_id();
49
50
#make sure the server is still alive
51
connection con2;
52
select 4;
53
drop table t1;
54
connection default;
55
56
--error ER_NOT_SUPPORTED_YET
57
kill (select count(*) from mysql.user);
58
59
#
60
# BUG#14851: killing long running subquery processed via a temporary table.
61
#
62
create table t1 (id int primary key);
63
create table t2 (id int unsigned not null);
64
65
connect (conn1, localhost, root,,);
66
connection conn1;
67
68
-- disable_result_log
69
-- disable_query_log
70
let $1 = 4096;
71
while ($1)
72
{
73
  eval insert into t1 values ($1);
74
  dec $1;
75
}
76
-- enable_query_log
77
-- enable_result_log
78
79
insert into t2 select id from t1;
80
81
create table t3 (kill_id int);
82
insert into t3 values(connection_id());
83
connect (conn2, localhost, root,,);
84
connection conn2;
85
86
connection conn1;
87
-- disable_result_log
88
# This is a very long running query. If this test start failing, it may
89
# be necessary to change to an even longer query.
90
send select id from t1 where id in (select distinct a.id from t2 a, t2 b, t2 c, t2 d group by a.id, b.id, c.id, d.id having a.id between 10 and 20);
91
-- enable_result_log
92
93
connection conn2;
94
select ((@id := kill_id) - kill_id) from t3;
95
-- sleep 1
96
kill @id;
97
98
connection conn1;
99
-- error 1053,2013
100
reap;
101
102
connection default;
103
104
drop table t1, t2, t3;
105
106
# End of 4.1 tests
107
108
#
109
# test of blocking of sending ERROR after OK or EOF
110
#
111
connection con1;
112
select get_lock("a", 10);
113
connection con2;
114
let $ID= `select connection_id()`;
115
send select get_lock("a", 10);
116
real_sleep 2;
117
connection con1;
118
disable_query_log;
119
eval kill query $ID;
120
enable_query_log;
121
connection con2;
122
reap;
123
select 1;
124
connection con1;
125
select RELEASE_LOCK("a");
126
127
create table t1(f1 int);
128
129
130
# Test UPDATE
131
insert into t1 values(0);
132
connection con2;
133
send update t1 set f1= bug27563();
134
real_sleep 2;
135
connection con1;
136
disable_query_log;
137
eval kill query $ID;
138
enable_query_log;
139
connection con2;
140
--error 1317
141
reap;
142
select @a;
143
connection con1;
144
select * from t1;
145
146
# Test DELETE
147
insert into t1 values(1);
148
connection con2;
149
send delete from t1 where bug27563() is null;
150
real_sleep 2;
151
connection con1;
152
disable_query_log;
153
eval kill query $ID;
154
enable_query_log;
155
connection con2;
156
--error 1317
157
reap;
158
select @a;
159
connection con1;
160
select * from t1;
161
162
# Test SELECT
163
connection con2;
164
send select * from t1 where f1= bug27563();
165
real_sleep 2;
166
connection con1;
167
disable_query_log;
168
eval kill query $ID;
169
enable_query_log;
170
connection con2;
171
--error 1317
172
reap;
173
select @a;
174
175
176
###########################################################################
177
178
--echo #
179
--echo # Bug#19723: kill of active connection yields different error code
180
--echo # depending on platform.
181
--echo #
182
183
--echo
184
--echo # Connection: con2.
185
--connection con2
186
187
KILL CONNECTION_ID();
188
189
--echo # CR_SERVER_LOST, CR_SERVER_GONE_ERROR, depending on the timing 
190
--echo # of close of the connection socket
191
--error 2013, 2006 
192
SELECT 1;
193
--connection default
194
195
###########################################################################
196
197
# Restore global concurrent_insert value. Keep in the end of the test file.
198
set @@global.concurrent_insert= @old_concurrent_insert;