~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/connect.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This test is to check various cases of connections
 
2
# with right and wrong password, with and without database
 
3
# Unfortunately the check is incomplete as we can't connect without database
 
4
 
 
5
# This test makes no sense with the embedded server
 
6
--source include/not_embedded.inc
 
7
 
 
8
# check that CSV engine was compiled in, as the test relies on the presence
 
9
# of the log tables (which are CSV-based). By connect mysql; show tables;
 
10
--source include/have_csv.inc
 
11
 
 
12
# Save the initial number of concurrent sessions
 
13
--source include/count_sessions.inc
 
14
 
 
15
 
 
16
--disable_warnings
 
17
drop table if exists t1,t2;
 
18
--enable_warnings
 
19
 
 
20
#connect (con1,localhost,root,,"");
 
21
#show tables;
 
22
connect (con1,localhost,root,,mysql);
 
23
show tables;
 
24
connect (con2,localhost,root,,test);
 
25
show tables;
 
26
 
 
27
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
28
--error ER_ACCESS_DENIED_ERROR
 
29
connect (fail_con,localhost,root,z,test2);
 
30
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
31
--error ER_ACCESS_DENIED_ERROR
 
32
connect (fail_con,localhost,root,z,);
 
33
 
 
34
connection default;
 
35
disconnect con1;
 
36
disconnect con2;
 
37
 
 
38
grant ALL on *.* to test@localhost identified by "gambling";
 
39
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
 
40
 
 
41
# Now check this user with different databases
 
42
#connect (con1,localhost,test,gambling,"");
 
43
#show tables;
 
44
connect (con3,localhost,test,gambling,mysql);
 
45
show tables;
 
46
connect (con4,localhost,test,gambling,test);
 
47
show tables;
 
48
 
 
49
connection default;
 
50
disconnect con3;
 
51
disconnect con4;
 
52
 
 
53
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
54
--error ER_ACCESS_DENIED_ERROR
 
55
connect (fail_con,localhost,test,,test2);
 
56
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
57
--error ER_ACCESS_DENIED_ERROR
 
58
# Need to protect "" within '' so it's interpreted literally
 
59
connect (fail_con,localhost,test,,'""');
 
60
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
61
--error ER_ACCESS_DENIED_ERROR
 
62
connect (fail_con,localhost,test,zorro,test2);
 
63
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
64
--error ER_ACCESS_DENIED_ERROR
 
65
connect (fail_con,localhost,test,zorro,);
 
66
 
 
67
# check if old password version also works
 
68
update mysql.user set password=old_password("gambling2") where user=_binary"test";
 
69
flush privileges;
 
70
 
 
71
connect (con10,localhost,test,gambling2,);
 
72
connect (con5,localhost,test,gambling2,mysql);
 
73
connection con5;
 
74
set password="";
 
75
--error ER_PASSWD_LENGTH
 
76
set password='gambling3';
 
77
set password=old_password('gambling3');
 
78
show tables;
 
79
connect (con6,localhost,test,gambling3,test);
 
80
show tables;
 
81
 
 
82
connection default;
 
83
disconnect con10;
 
84
disconnect con5;
 
85
disconnect con6;
 
86
 
 
87
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
88
--error ER_ACCESS_DENIED_ERROR
 
89
connect (fail_con,localhost,test,,test2);
 
90
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
91
--error ER_ACCESS_DENIED_ERROR
 
92
connect (fail_con,localhost,test,,);
 
93
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
94
--error ER_ACCESS_DENIED_ERROR
 
95
connect (fail_con,localhost,test,zorro,test2);
 
96
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
97
--error ER_ACCESS_DENIED_ERROR
 
98
connect (fail_con,localhost,test,zorro,);
 
99
 
 
100
 
 
101
# remove user 'test' so that other tests which may use 'test'
 
102
# do not depend on this test.
 
103
delete from mysql.user where user=_binary"test";
 
104
flush privileges;
 
105
 
 
106
#
 
107
# Bug#12517 Clear user variables and replication events before
 
108
#           closing temp tables in thread cleanup.
 
109
connect (con7,localhost,root,,test);
 
110
connection con7;
 
111
let $connection_id= `select connection_id()`;
 
112
create table t1 (id integer not null auto_increment primary key);
 
113
create temporary table t2(id integer not null auto_increment primary key);
 
114
set @id := 1;
 
115
delete from t1 where id like @id;
 
116
connection default;
 
117
disconnect con7;
 
118
# Wait till the session con7 is disconnected
 
119
let $wait_condition =
 
120
  SELECT COUNT(*) = 0
 
121
  FROM information_schema.processlist
 
122
  WHERE  id = '$connection_id';
 
123
--source include/wait_condition.inc
 
124
drop table t1;
 
125
 
 
126
--echo # ------------------------------------------------------------------
 
127
--echo # -- End of 4.1 tests
 
128
--echo # ------------------------------------------------------------------
 
129
 
 
130
###########################################################################
 
131
 
 
132
--echo
 
133
--echo # -- Bug#33507: Event scheduler creates more threads than max_connections
 
134
--echo # -- which results in user lockout.
 
135
 
 
136
--echo
 
137
GRANT USAGE ON *.* TO mysqltest_u1@localhost;
 
138
 
 
139
# NOTE: if the test case fails sporadically due to spurious connections,
 
140
# consider disabling all users.
 
141
 
 
142
--echo
 
143
let $saved_max_connections = `SELECT @@global.max_connections`;
 
144
SET GLOBAL max_connections = 3;
 
145
SET GLOBAL event_scheduler = ON;
 
146
 
 
147
--echo
 
148
--echo # -- Waiting for Event Scheduler to start...
 
149
let $wait_condition =
 
150
  SELECT COUNT(*) = 1
 
151
  FROM information_schema.processlist
 
152
  WHERE user = 'event_scheduler';
 
153
--source include/wait_condition.inc
 
154
 
 
155
--echo
 
156
--echo # -- Disconnecting default connection...
 
157
--disconnect default
 
158
 
 
159
--echo
 
160
--echo # -- Check that we allow exactly three user connections, no matter how
 
161
--echo # -- many threads are running.
 
162
 
 
163
--echo
 
164
--echo # -- Connecting (1)...
 
165
let $con_name = con_1;
 
166
let $con_user_name = mysqltest_u1;
 
167
--source include/connect2.inc
 
168
 
 
169
--echo
 
170
--echo # -- Connecting (2)...
 
171
let $con_name = con_2;
 
172
let $con_user_name = mysqltest_u1;
 
173
--source include/connect2.inc
 
174
 
 
175
--echo
 
176
--echo # -- Connecting (3)...
 
177
let $con_name = con_3;
 
178
let $con_user_name = mysqltest_u1;
 
179
--source include/connect2.inc
 
180
 
 
181
--echo
 
182
--echo # -- Connecting (4) [should fail]...
 
183
let $con_name = con_4;
 
184
let $con_user_name = mysqltest_u1;
 
185
let $wait_timeout = 5;
 
186
--source include/connect2.inc
 
187
 
 
188
--echo
 
189
--echo # -- Check that we allow one extra SUPER-user connection.
 
190
 
 
191
--echo
 
192
--echo # -- Connecting super (1)...
 
193
let $con_name = con_super_1;
 
194
let $con_user_name = root;
 
195
--source include/connect2.inc
 
196
 
 
197
--echo
 
198
--echo # -- Connecting super (2) [should fail]...
 
199
let $con_name = con_super_2;
 
200
let $con_user_name = root;
 
201
let $wait_timeout = 5;
 
202
--source include/connect2.inc
 
203
 
 
204
--echo
 
205
--echo # -- Ensure that we have Event Scheduler thread, 3 ordinary user
 
206
--echo # -- connections and one extra super-user connection.
 
207
SELECT user FROM information_schema.processlist ORDER BY id;
 
208
 
 
209
--echo
 
210
--echo # -- Resetting variables...
 
211
--eval SET GLOBAL max_connections = $saved_max_connections
 
212
 
 
213
--echo
 
214
--echo # -- Stopping Event Scheduler...
 
215
SET GLOBAL event_scheduler = OFF;
 
216
 
 
217
--echo
 
218
--echo # -- Waiting for Event Scheduler to stop...
 
219
let $wait_condition =
 
220
  SELECT COUNT(*) = 0
 
221
  FROM information_schema.processlist
 
222
  WHERE user = 'event_scheduler';
 
223
--source include/wait_condition.inc
 
224
 
 
225
--echo
 
226
--echo # -- That's it. Closing connections...
 
227
--disconnect con_1
 
228
--disconnect con_2
 
229
--disconnect con_3
 
230
--disconnect con_super_1
 
231
 
 
232
--echo
 
233
--echo # -- Restoring default connection...
 
234
--connect (default,localhost,root,,test)
 
235
 
 
236
--echo
 
237
--echo # -- Waiting for connections to close...
 
238
let $wait_condition =
 
239
  SELECT COUNT(*) = 1
 
240
  FROM information_schema.processlist
 
241
  WHERE db = 'test';
 
242
--source include/wait_condition.inc
 
243
 
 
244
--echo
 
245
DROP USER mysqltest_u1@localhost;
 
246
 
 
247
--echo
 
248
--echo # -- End of Bug#33507.
 
249
--echo
 
250
 
 
251
###########################################################################
 
252
 
 
253
--echo # -- Bug#35074: max_used_connections is not correct.
 
254
--echo
 
255
 
 
256
FLUSH STATUS;
 
257
 
 
258
--echo
 
259
SHOW STATUS LIKE 'max_used_connections';
 
260
 
 
261
--echo
 
262
--echo # -- Starting Event Scheduler...
 
263
SET GLOBAL event_scheduler = ON;
 
264
 
 
265
--echo # -- Waiting for Event Scheduler to start...
 
266
--source include/running_event_scheduler.inc
 
267
 
 
268
# NOTE: We should use a new connection here instead of reconnect in order to
 
269
# avoid races (we can not for sure when the connection being disconnected is
 
270
# actually disconnected on the server).
 
271
 
 
272
--echo
 
273
--echo # -- Opening a new connection to check max_used_connections...
 
274
--connect (con_1,localhost,root)
 
275
 
 
276
--echo
 
277
--echo # -- Check that max_used_connections hasn't changed.
 
278
SHOW STATUS LIKE 'max_used_connections';
 
279
 
 
280
--echo
 
281
--echo # -- Closing new connection...
 
282
--disconnect con_1
 
283
--connection default
 
284
 
 
285
--echo
 
286
--echo # -- Stopping Event Scheduler...
 
287
SET GLOBAL event_scheduler = OFF;
 
288
 
 
289
--echo # -- Waiting for Event Scheduler to stop...
 
290
--source include/no_running_events.inc
 
291
 
 
292
--echo
 
293
--echo # -- End of Bug#35074.
 
294
--echo
 
295
 
 
296
--echo # ------------------------------------------------------------------
 
297
--echo # -- End of 5.1 tests
 
298
--echo # ------------------------------------------------------------------
 
299
 
 
300
# Wait till all disconnects are completed
 
301
--source include/wait_until_count_sessions.inc
 
302