~drizzle-trunk/drizzle/development

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