~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
connect (con1,localhost,root,,);
2
connect (con2,localhost,root,,);
3
connection con1;
4
5
--disable_warnings
6
drop table if exists t1,t2;
7
drop database if exists mysqltest;
8
--enable_warnings
9
10
create temporary table t1(n int not null primary key);
11
create table t2(n int);
12
insert into t2 values(3);
13
let $1=100;
14
disable_query_log;
15
while ($1)
16
{
17
 connection con1;
18
 send replace into t1 select n from t2;
19
 connection con2;
20
 send flush tables;
21
 connection con1;
22
 reap;
23
 connection con2;
24
 reap;
25
 dec $1;
26
}
27
enable_query_log;
28
connection con1;
29
select * from t1;
30
connection con2;
31
flush tables with read lock;
32
--error 1223
33
drop table t2;
34
connection con1;
35
send drop table t2;
36
connection con2;
37
unlock tables;
38
connection con1;
39
reap;
40
41
#test if drop database will wait until we release the global read lock
42
connection con1;
43
create database mysqltest;
44
create table mysqltest.t1(n int);
45
insert into mysqltest.t1 values (23);
46
flush tables with read lock;
47
connection con2;
48
send drop database mysqltest;
49
connection con1;
50
select * from mysqltest.t1;
51
unlock tables;
52
connection con2;
53
reap;
54
718 by Brian Aker
Fix for FLUSH TABLE WITH READ LOCK
55
## test if dirty close releases global read lock
56
#connection con1;
57
#create table t1 (n int);
58
#flush tables with read lock;
59
#dirty_close con1;
60
#connection con2;
61
#insert into t1 values (345);
62
#select * from t1;
63
#drop table t1;
1 by brian
clean slate
64
65
#
66
# Bug#9459 - deadlock with flush with lock, and lock table write
67
#
68
create table t1 (c1 int);
69
lock table t1 write;
70
# Cannot get the global read lock with write locked tables.
71
--error 1192
72
flush tables with read lock;
73
lock table t1 read;
74
# Can get the global read lock with read locked tables.
75
flush tables with read lock;
76
--error 1223
77
lock table t1 write;
78
lock table t1 read;
79
--error 1223
80
lock table t1 write;
81
# Release all table locks and the global read lock.
82
unlock tables;
83
create table t2 (c1 int);
84
create table t3 (c1 int);
85
lock table t1 read, t2 read, t3 write;
86
# Cannot get the global read lock with write locked tables.
87
--error 1192
88
flush tables with read lock;
89
lock table t1 read, t2 read, t3 read;
90
# Can get the global read lock with read locked tables.
91
flush tables with read lock;
92
# Release all table locks and the global read lock.
93
unlock tables;
94
drop table t1, t2, t3;
95
96
# End of 4.1 tests
97
98
#
99
# Test of deadlock problem when doing FLUSH TABLE with read lock
100
# (Bug was in NTPL threads in Linux when using different mutex while
101
#  waiting for a condtion variable)
102
103
create table t1 (c1 int);
104
create table t2 (c1 int);
105
106
connect (con3,localhost,root,,);
107
108
connection con1;
109
lock table t1 write;
110
111
connection con2;
112
send flush tables with read lock;
113
--sleep 1
114
115
connection con3;
116
send insert into t2 values(1);
117
--sleep 1
118
119
connection con1;
120
unlock tables;
121
disconnect con1;
122
123
connection con2;
124
reap;
125
disconnect con2;
126
127
connection con3;
128
# It hangs here (insert into t2 does not end).
129
reap;
130
disconnect con3;
131
132
connection default;
133
drop table t1, t2;
134
135
#
136
# Bug #33334 mysqltest_embedded crashes when disconnecting before reap
137
#
138
139
connect (con1,localhost,root,,);
140
send select benchmark(200, (select sin(1))) > 1000;
141
disconnect con1;
142
connection default;
143
144
--echo End of 5.0 tests
145