~ubuntu-branches/ubuntu/raring/mysql-5.5/raring-proposed

« back to all changes in this revision

Viewing changes to mysql-test/t/create-big.test

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#
8
8
# This test takes rather long time so let us run it only in --big-test mode
9
9
--source include/big_test.inc
10
 
# We are using some debug-only features in this test
11
 
--source include/have_debug.inc
 
10
# We need the Debug Sync Facility.
 
11
--source include/have_debug_sync.inc
12
12
# Some of tests below also use binlog to check that statements are
13
13
# executed and logged in correct order
14
14
--source include/have_binlog_format_mixed_or_statement.inc
 
15
# Save the initial number of concurrent sessions.
 
16
--source include/count_sessions.inc
15
17
 
16
18
# Create auxilliary connections
17
19
connect (addconroot1, localhost, root,,);
22
24
--disable_warnings
23
25
drop table if exists t1,t2,t3,t4,t5;
24
26
--enable_warnings
25
 
 
 
27
set debug_sync='RESET';
26
28
 
27
29
#
28
30
# Tests for concurrency problems in CREATE TABLE ... SELECT
34
36
# What happens in situation when other statement messes with
35
37
# table to be created before it is created ?
36
38
# Concurrent CREATE TABLE
37
 
set session debug="+d,sleep_create_select_before_create";
 
39
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
38
40
--send create table t1 select 1 as i;
39
41
connection addconroot1;
40
 
--sleep 2
 
42
set debug_sync='now WAIT_FOR parked';
 
43
--send create table t1 (j char(5));
 
44
connection addconroot2;
 
45
let $wait_condition=
 
46
    select count(*) = 1 from information_schema.processlist
 
47
    where state = "Waiting for table metadata lock" and
 
48
          info = "create table t1 (j char(5))";
 
49
--source include/wait_condition.inc
 
50
set debug_sync='now SIGNAL go';
 
51
connection default;
 
52
--reap
 
53
connection addconroot1;
41
54
--error ER_TABLE_EXISTS_ERROR
42
 
create table t1 (j char(5));
 
55
--reap
43
56
connection default;
44
 
--reap
45
57
show create table t1;
46
58
drop table t1;
 
59
 
47
60
# Concurrent CREATE TABLE ... SELECT
 
61
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
48
62
--send create table t1 select 1 as i;
49
63
connection addconroot1;
50
 
--sleep 2
 
64
set debug_sync='now WAIT_FOR parked';
 
65
--send create table t1 select 'Test' as j;
 
66
connection addconroot2;
 
67
# Wait until the above CREATE TABLE t1 is blocked due to CREATE
 
68
let $wait_condition=
 
69
    select count(*) = 1 from information_schema.processlist
 
70
    where state = "Waiting for table metadata lock" and
 
71
          info = "create table t1 select 'Test' as j";
 
72
--source include/wait_condition.inc
 
73
set debug_sync='now SIGNAL go';
 
74
connection default;
 
75
--reap
 
76
connection addconroot1;
51
77
--error ER_TABLE_EXISTS_ERROR
52
 
create table t1 select "Test" as j;
 
78
--reap
53
79
connection default;
54
 
--reap
55
80
show create table t1;
56
81
drop table t1;
 
82
 
57
83
# Concurrent CREATE TABLE LIKE
58
84
create table t3 (j char(5));
 
85
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
59
86
--send create table t1 select 1 as i;
60
87
connection addconroot1;
61
 
--sleep 2
 
88
set debug_sync='now WAIT_FOR parked';
 
89
--send create table t1 like t3;
 
90
connection addconroot2;
 
91
# Wait until the above CREATE TABLE t1 is blocked due to CREATE
 
92
let $wait_condition=
 
93
    select count(*) = 1 from information_schema.processlist
 
94
    where state = "Waiting for table metadata lock" and
 
95
          info = "create table t1 like t3";
 
96
--source include/wait_condition.inc
 
97
set debug_sync='now SIGNAL go';
 
98
connection default;
 
99
--reap
 
100
connection addconroot1;
62
101
--error ER_TABLE_EXISTS_ERROR
63
 
create table t1 like t3;
 
102
--reap
64
103
connection default;
65
 
--reap
66
104
show create table t1;
67
105
drop table t1;
 
106
 
68
107
# Concurrent RENAME TABLE
 
108
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
69
109
--send create table t1 select 1 as i;
70
110
connection addconroot1;
71
 
--sleep 2
 
111
set debug_sync='now WAIT_FOR parked';
 
112
--send rename table t3 to t1;
 
113
connection addconroot2;
 
114
# Wait until the above RENAME TABLE is blocked due to CREATE
 
115
let $wait_condition=
 
116
    select count(*) = 1 from information_schema.processlist
 
117
    where state = "Waiting for table metadata lock" and
 
118
          info = "rename table t3 to t1";
 
119
--source include/wait_condition.inc
 
120
set debug_sync='now SIGNAL go';
 
121
connection default;
 
122
--reap
 
123
connection addconroot1;
72
124
--error ER_TABLE_EXISTS_ERROR
73
 
rename table t3 to t1;
 
125
--reap
74
126
connection default;
75
 
--reap
76
127
show create table t1;
77
128
drop table t1;
 
129
 
78
130
# Concurrent ALTER TABLE RENAME
 
131
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
79
132
--send create table t1 select 1 as i;
80
133
connection addconroot1;
81
 
--sleep 2
 
134
set debug_sync='now WAIT_FOR parked';
82
135
--error ER_TABLE_EXISTS_ERROR
83
136
alter table t3 rename to t1;
 
137
set debug_sync='now SIGNAL go';
84
138
connection default;
85
139
--reap
 
140
connection default;
86
141
show create table t1;
87
142
drop table t1;
 
143
 
88
144
# Concurrent ALTER TABLE RENAME which also adds column
 
145
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
89
146
--send create table t1 select 1 as i;
90
147
connection addconroot1;
91
 
--sleep 2
 
148
set debug_sync='now WAIT_FOR parked';
92
149
--error ER_TABLE_EXISTS_ERROR
93
150
alter table t3 rename to t1, add k int;
 
151
set debug_sync='now SIGNAL go';
94
152
connection default;
95
153
--reap
96
154
show create table t1;
97
 
drop table t1, t3;
 
155
drop table t1,t3;
 
156
 
98
157
# What happens if other statement sneaks in after the table
99
158
# creation but before its opening ?
100
 
set session debug="-d,sleep_create_select_before_create:+d,sleep_create_select_before_open";
 
159
set debug_sync='create_table_select_before_open SIGNAL parked WAIT_FOR go';
 
160
connection default;
 
161
 
101
162
# Concurrent DROP TABLE
 
163
set debug_sync='create_table_select_before_open SIGNAL parked WAIT_FOR go';
102
164
--send create table t1 select 1 as i;
103
165
connection addconroot1;
104
 
--sleep 2
105
 
drop table t1;
106
 
connection default;
107
 
--reap
 
166
set debug_sync='now WAIT_FOR parked';
 
167
--send drop table t1;
 
168
connection addconroot2;
 
169
# Wait until the above DROP TABLE is blocked due to CREATE
 
170
let $wait_condition=
 
171
    select count(*) = 1 from information_schema.processlist
 
172
    where state = "Waiting for table metadata lock" and
 
173
          info = "drop table t1";
 
174
--source include/wait_condition.inc
 
175
set debug_sync='now SIGNAL go';
 
176
connection default;
 
177
--reap
 
178
connection addconroot1;
 
179
--reap
 
180
connection default;
 
181
 
108
182
# Concurrent RENAME TABLE
 
183
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
109
184
--send create table t1 select 1 as i;
110
185
connection addconroot1;
111
 
--sleep 2
112
 
rename table t1 to t2;
113
 
connection default;
114
 
--reap
 
186
set debug_sync='now WAIT_FOR parked';
 
187
--send rename table t1 to t2;
 
188
connection addconroot2;
 
189
# Wait until the above RENAME TABLE is blocked due to CREATE
 
190
let $wait_condition=
 
191
    select count(*) = 1 from information_schema.processlist
 
192
    where state = "Waiting for table metadata lock" and
 
193
          info = "rename table t1 to t2";
 
194
--source include/wait_condition.inc
 
195
set debug_sync='now SIGNAL go';
 
196
connection default;
 
197
--reap
 
198
connection addconroot1;
 
199
--reap
 
200
connection default;
115
201
drop table t2;
 
202
 
116
203
# Concurrent SELECT
 
204
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
117
205
--send create table t1 select 1 as i;
118
206
connection addconroot1;
119
 
--sleep 2
120
 
select * from t1;
121
 
connection default;
122
 
--reap
 
207
set debug_sync='now WAIT_FOR parked';
 
208
--send select * from t1;
 
209
connection addconroot2;
 
210
# Wait until the above SELECT is blocked due to CREATE
 
211
let $wait_condition=
 
212
    select count(*) = 1 from information_schema.processlist
 
213
    where state = "Waiting for table metadata lock" and
 
214
          info = "select * from t1";
 
215
--source include/wait_condition.inc
 
216
set debug_sync='now SIGNAL go';
 
217
connection default;
 
218
--reap
 
219
connection addconroot1;
 
220
--reap
 
221
connection default;
123
222
drop table t1;
 
223
 
124
224
# Concurrent INSERT
 
225
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
125
226
--send create table t1 select 1 as i;
126
227
connection addconroot1;
127
 
--sleep 2
128
 
insert into t1 values (2);
129
 
connection default;
130
 
--reap
 
228
set debug_sync='now WAIT_FOR parked';
 
229
--send insert into t1 values (2);
 
230
connection addconroot2;
 
231
# Wait until the above INSERT is blocked due to CREATE
 
232
let $wait_condition=
 
233
    select count(*) = 1 from information_schema.processlist
 
234
    where state = "Waiting for table metadata lock" and
 
235
          info = "insert into t1 values (2)";
 
236
--source include/wait_condition.inc
 
237
set debug_sync='now SIGNAL go';
 
238
connection default;
 
239
--reap
 
240
connection addconroot1;
 
241
--reap
 
242
connection default;
131
243
select * from t1;
132
244
drop table t1;
 
245
 
133
246
# Concurrent CREATE TRIGGER 
134
247
set @a:=0;
 
248
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
135
249
--send create table t1 select 1 as i;
136
250
connection addconroot1;
137
 
--sleep 2
138
 
create trigger t1_bi before insert on t1 for each row set @a:=1;
139
 
connection default;
140
 
--reap
 
251
set debug_sync='now WAIT_FOR parked';
 
252
--send create trigger t1_bi before insert on t1 for each row set @a:=1;
 
253
connection addconroot2;
 
254
# Wait until the above CREATE TRIGGER is blocked due to CREATE TABLE
 
255
let $wait_condition=
 
256
    select count(*) = 1 from information_schema.processlist
 
257
    where state = "Waiting for table metadata lock" and
 
258
          info = "create trigger t1_bi before insert on t1 for each row set @a:=1";
 
259
--source include/wait_condition.inc
 
260
set debug_sync='now SIGNAL go';
 
261
connection default;
 
262
--reap
 
263
connection addconroot1;
 
264
--reap
 
265
connection default;
141
266
select @a;
142
267
drop table t1;
 
268
 
143
269
# Okay, now the same tests for the potential gap between open and lock
144
 
set session debug="-d,sleep_create_select_before_open:+d,sleep_create_select_before_lock";
 
270
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
 
271
 
145
272
# Concurrent DROP TABLE
146
273
--send create table t1 select 1 as i;
147
274
connection addconroot1;
148
 
--sleep 2
149
 
drop table t1;
150
 
connection default;
151
 
--reap
 
275
set debug_sync='now WAIT_FOR parked';
 
276
--send drop table t1;
 
277
connection addconroot2;
 
278
# Wait until the above DROP TABLE is blocked due to CREATE TABLE
 
279
let $wait_condition=
 
280
    select count(*) = 1 from information_schema.processlist
 
281
    where state = "Waiting for table metadata lock" and
 
282
          info = "drop table t1";
 
283
--source include/wait_condition.inc
 
284
set debug_sync='now SIGNAL go';
 
285
connection default;
 
286
--reap
 
287
connection addconroot1;
 
288
--reap
 
289
connection default;
 
290
 
152
291
# Concurrent RENAME TABLE
 
292
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
153
293
--send create table t1 select 1 as i;
154
294
connection addconroot1;
155
 
--sleep 2
156
 
rename table t1 to t2;
157
 
connection default;
158
 
--reap
 
295
set debug_sync='now WAIT_FOR parked';
 
296
--send rename table t1 to t2;
 
297
connection addconroot2;
 
298
# Wait until the above RENAME TABLE is blocked due to CREATE TABLE
 
299
let $wait_condition=
 
300
    select count(*) = 1 from information_schema.processlist
 
301
    where state = "Waiting for table metadata lock" and
 
302
          info = "rename table t1 to t2";
 
303
--source include/wait_condition.inc
 
304
set debug_sync='now SIGNAL go';
 
305
connection default;
 
306
--reap
 
307
connection addconroot1;
 
308
--reap
 
309
connection default;
159
310
drop table t2;
 
311
 
160
312
# Concurrent SELECT
 
313
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
161
314
--send create table t1 select 1 as i;
162
315
connection addconroot1;
163
 
--sleep 2
164
 
select * from t1;
165
 
connection default;
166
 
--reap
 
316
set debug_sync='now WAIT_FOR parked';
 
317
--send select * from t1;
 
318
connection addconroot2;
 
319
# Wait until the above SELECT is blocked due to CREATE TABLE
 
320
let $wait_condition=
 
321
    select count(*) = 1 from information_schema.processlist
 
322
    where state = "Waiting for table metadata lock" and
 
323
          info = "select * from t1";
 
324
--source include/wait_condition.inc
 
325
set debug_sync='now SIGNAL go';
 
326
connection default;
 
327
--reap
 
328
connection addconroot1;
 
329
--reap
 
330
connection default;
167
331
drop table t1;
 
332
 
168
333
# Concurrent INSERT
 
334
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
169
335
--send create table t1 select 1 as i;
170
336
connection addconroot1;
171
 
--sleep 2
172
 
insert into t1 values (2);
173
 
connection default;
174
 
--reap
 
337
set debug_sync='now WAIT_FOR parked';
 
338
--send insert into t1 values (2);
 
339
connection addconroot2;
 
340
# Wait until the above INSERT INTO t1 is blocked due to CREATE TABLE
 
341
let $wait_condition=
 
342
    select count(*) = 1 from information_schema.processlist
 
343
    where state = "Waiting for table metadata lock" and
 
344
          info = "insert into t1 values (2)";
 
345
--source include/wait_condition.inc
 
346
set debug_sync='now SIGNAL go';
 
347
connection default;
 
348
--reap
 
349
connection addconroot1;
 
350
--reap
 
351
connection default;
175
352
select * from t1;
176
353
drop table t1;
 
354
 
177
355
# Concurrent CREATE TRIGGER 
178
356
set @a:=0;
 
357
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
179
358
--send create table t1 select 1 as i;
180
359
connection addconroot1;
181
 
--sleep 2
182
 
create trigger t1_bi before insert on t1 for each row set @a:=1;
183
 
connection default;
184
 
--reap
 
360
set debug_sync='now WAIT_FOR parked';
 
361
--send create trigger t1_bi before insert on t1 for each row set @a:=1;
 
362
connection addconroot2;
 
363
# Wait until the above CREATE TRIGGER is blocked due to CREATE TABLE
 
364
let $wait_condition=
 
365
    select count(*) = 1 from information_schema.processlist
 
366
    where state = "Waiting for table metadata lock" and
 
367
          info = "create trigger t1_bi before insert on t1 for each row set @a:=1";
 
368
--source include/wait_condition.inc
 
369
set debug_sync='now SIGNAL go';
 
370
connection default;
 
371
--reap
 
372
connection addconroot1;
 
373
--reap
 
374
connection default;
185
375
select @a;
186
376
drop table t1;
187
 
# Some tests for case with existing table
188
 
set session debug="-d,sleep_create_select_before_lock:+d,sleep_create_select_before_check_if_exists";
189
 
create table t1 (i int);
 
377
 
190
378
# Concurrent DROP TABLE
 
379
set debug_sync='create_table_select_before_check_if_exists SIGNAL parked WAIT_FOR go';
191
380
--send create table if not exists t1 select 1 as i;
192
381
connection addconroot1;
193
 
--sleep 2
194
 
drop table t1;
195
 
connection default;
196
 
--reap
197
 
# Concurrent CREATE TRIGGER 
 
382
set debug_sync='now WAIT_FOR parked';
 
383
--send drop table t1;
 
384
connection addconroot2;
 
385
# Wait until the above DROP TABLE is blocked due to CREATE TABLE
 
386
let $wait_condition=
 
387
    select count(*) = 1 from information_schema.processlist
 
388
    where state = "Waiting for table metadata lock" and
 
389
          info = "drop table t1";
 
390
--source include/wait_condition.inc
 
391
set debug_sync='now SIGNAL go';
 
392
connection default;
 
393
--reap
 
394
connection addconroot1;
 
395
--reap
 
396
connection default;
 
397
 
 
398
# Concurrent CREATE TRIGGER
198
399
create table t1 (i int);
199
400
set @a:=0;
 
401
set debug_sync='create_table_select_before_check_if_exists SIGNAL parked WAIT_FOR go';
200
402
--send create table if not exists t1 select 1 as i;
201
403
connection addconroot1;
202
 
--sleep 2
203
404
create trigger t1_bi before insert on t1 for each row set @a:=1;
204
405
connection default;
205
406
--reap
 
407
connection default;
206
408
select @a;
207
409
select * from t1;
208
410
drop table t1;
209
 
set session debug="-d,sleep_create_select_before_check_if_exists";
210
 
 
211
 
 
212
 
# Test for some details of CREATE TABLE ... SELECT implementation.
213
 
#
214
 
# We check that create placeholder is handled properly if we have
215
 
# to reopen tables in open_tables().
216
 
# This test heavily relies on current implementation of name-locking/
217
 
# table cache so it may stop working if it changes. OTOH it such problem
218
 
# will serve as warning that such changes should not be done lightly.
219
 
create table t2 (a int);
220
 
create table t4 (b int);
221
 
connection addconroot2;
222
 
lock table t4 write;
223
 
select 1;
224
 
connection addconroot1;
225
 
# Create placeholder/name-lock for t3
226
 
--send create table t3 as select * from t4;
227
 
--sleep 2
228
 
connection default;
229
 
# This statement creates placeholder for t1, then opens t2,
230
 
# then meets name-lock for t3 and then reopens all tables
231
 
--send create table t1 select * from t2, t3;
232
 
--sleep 2
233
 
connection addconroot2;
234
 
unlock tables;
235
 
connection addconroot1;
236
 
--reap
237
 
connection default;
238
 
--reap
239
 
select * from t1;
240
 
show create table t1;
241
 
drop table t1, t3;
242
 
# Now similar test which proves that we really temporarily
243
 
# remove placeholder when we reopen tables.
244
 
connection addconroot2;
245
 
lock table t4 read;
246
 
select 1;
247
 
connection addconroot1;
248
 
# Create name-lock for t3 
249
 
--send rename table t4 to t3;
250
 
--sleep 2
251
 
connection default;
252
 
# This statement creates placeholder for t1, then opens t2,
253
 
# then meets name-lock for t3 and then reopens all tables
254
 
--send create table if not exists t1 select 1 as i from t2, t3;
255
 
--sleep 2
256
 
connection addconroot3;
257
 
# We should be able to take name-lock on table t1 as we should not have
258
 
# open placeholder for it at this point (otherwise it is possible to
259
 
# come-up with situation which will lead to deadlock, e.g. think of
260
 
# concurrent CREATE TABLE t1 SELECT * FROM t2 and RENAME TABLE t2 TO t1)
261
 
create table t5 (j int);
262
 
# This statement takes name-lock on t1 and therefore proves 
263
 
# that there is no active open placeholder for it.
264
 
rename table t5 to t1;
265
 
connection addconroot2;
266
 
unlock tables;
267
 
connection addconroot1;
268
 
--reap
269
 
connection default;
270
 
--reap
271
 
select * from t1;
272
 
show create table t1;
273
 
drop table t1, t2, t3;
274
 
 
275
411
 
276
412
# Tests for possible concurrency issues with CREATE TABLE ... LIKE
277
413
#
286
422
--disable_warnings
287
423
drop table if exists t1,t2;
288
424
--enable_warnings
 
425
set debug_sync='RESET';
289
426
 
290
427
# What happens if some statements sneak in right after we have
291
 
# opened source table ?
 
428
# acquired locks and opened source table ?
292
429
create table t1 (i int);
293
 
set session debug="+d,sleep_create_like_before_check_if_exists";
 
430
set debug_sync='create_table_like_after_open SIGNAL parked WAIT_FOR go';
294
431
# Reset binlog to have clear start
295
432
reset master;
296
433
--send create table t2 like t1;
297
434
connection addconroot1;
298
 
--sleep 2
 
435
set debug_sync='now WAIT_FOR parked';
299
436
# DML on source table should be allowed to run concurrently
300
437
insert into t1 values (1);
301
438
# And DDL should wait
302
 
drop table t1;
303
 
connection default;
304
 
--reap
 
439
--send drop table t1;
 
440
connection addconroot2;
 
441
let $wait_condition=
 
442
    select count(*) = 1 from information_schema.processlist
 
443
    where state = "Waiting for table metadata lock" and
 
444
          info = "drop table t1";
 
445
--source include/wait_condition.inc
 
446
set debug_sync='now SIGNAL go';
 
447
connection default;
 
448
--reap
 
449
connection addconroot1;
 
450
--reap
 
451
connection default;
305
452
show create table t2;
306
453
drop table t2;
307
454
# Let us check that statements were executed/binlogged in correct order
308
455
source include/show_binlog_events.inc;
309
456
 
310
 
# Now let us check the gap between check for target table
311
 
# existance and copying of .frm file. 
312
 
create table t1 (i int);
313
 
set session debug="-d,sleep_create_like_before_check_if_exists:+d,sleep_create_like_before_copy";
314
 
# It should be impossible to create target table concurrently
315
 
--send create table t2 like t1;
316
 
connection addconroot1;
317
 
--sleep 2
318
 
create table if not exists t2 (j int);
319
 
connection default;
320
 
--reap
321
 
show create table t2;
322
 
drop table t2;
323
 
# And concurrent DDL on the source table should be still disallowed 
324
 
reset master;
325
 
--send create table t2 like t1;
326
 
connection addconroot1;
327
 
--sleep 2
328
 
drop table t1;
329
 
connection default;
330
 
--reap
331
 
drop table t2;
332
 
source include/show_binlog_events.inc;
333
 
 
334
 
# And now he gap between copying of .frm file and ha_create_table() call. 
335
 
create table t1 (i int);
336
 
set session debug="-d,sleep_create_like_before_copy:+d,sleep_create_like_before_ha_create";
337
 
# Both DML and DDL on target table should wait till operation completes
338
 
reset master;
339
 
--send create table t2 like t1;
340
 
connection addconroot1;
341
 
--sleep 2
342
 
insert into t2 values (1);
343
 
connection default;
344
 
--reap
345
 
drop table t2;
346
 
--send create table t2 like t1;
347
 
connection addconroot1;
348
 
--sleep 2
349
 
drop table t2;
350
 
connection default;
351
 
--reap
352
 
# Concurrent DDL on the source table still waits 
353
 
--send create table t2 like t1;
354
 
connection addconroot1;
355
 
--sleep 2
356
 
drop table t1;
357
 
connection default;
358
 
--reap
359
 
drop table t2;
360
 
source include/show_binlog_events.inc;
361
 
 
362
 
# Finally we check the gap between ha_create_table() and binlogging
363
 
create table t1 (i int);
364
 
set session debug="-d,sleep_create_like_before_ha_create:+d,sleep_create_like_before_binlogging";
365
 
reset master;
366
 
--send create table t2 like t1;
367
 
connection addconroot1;
368
 
--sleep 2
369
 
insert into t2 values (1);
370
 
connection default;
371
 
--reap
372
 
drop table t2;
373
 
--send create table t2 like t1;
374
 
connection addconroot1;
375
 
--sleep 2
376
 
drop table t2;
377
 
connection default;
378
 
--reap
379
 
--send create table t2 like t1;
380
 
connection addconroot1;
381
 
--sleep 2
382
 
drop table t1;
383
 
connection default;
384
 
--reap
385
 
drop table t2;
386
 
source include/show_binlog_events.inc;
387
 
 
388
 
set session debug="-d,sleep_create_like_before_binlogging";
 
457
# Now check the gap between table creation and binlogging
 
458
create table t1 (i int);
 
459
set debug_sync='create_table_like_before_binlog SIGNAL parked WAIT_FOR go';
 
460
reset master;
 
461
--send create table t2 like t1;
 
462
connection addconroot1;
 
463
set debug_sync='now WAIT_FOR parked';
 
464
--send insert into t2 values (1);
 
465
connection addconroot2;
 
466
let $wait_condition=
 
467
    select count(*) = 1 from information_schema.processlist
 
468
    where state = "Waiting for table metadata lock" and
 
469
          info = "insert into t2 values (1)";
 
470
--source include/wait_condition.inc
 
471
set debug_sync='now SIGNAL go';
 
472
connection default;
 
473
--reap
 
474
 
 
475
connection addconroot1;
 
476
--reap
 
477
connection default;
 
478
drop table t2;
 
479
set debug_sync='create_table_like_before_binlog SIGNAL parked WAIT_FOR go';
 
480
--send create table t2 like t1;
 
481
connection addconroot1;
 
482
set debug_sync='now WAIT_FOR parked';
 
483
--send drop table t2;
 
484
connection addconroot2;
 
485
let $wait_condition=
 
486
    select count(*) = 1 from information_schema.processlist
 
487
    where state = "Waiting for table metadata lock" and
 
488
          info = "drop table t2";
 
489
--source include/wait_condition.inc
 
490
set debug_sync='now SIGNAL go';
 
491
connection default;
 
492
--reap
 
493
connection addconroot1;
 
494
--reap
 
495
connection default;
 
496
set debug_sync='create_table_like_before_binlog SIGNAL parked WAIT_FOR go';
 
497
--send create table t2 like t1;
 
498
connection addconroot1;
 
499
set debug_sync='now WAIT_FOR parked';
 
500
--send drop table t1;
 
501
connection addconroot2;
 
502
let $wait_condition=
 
503
    select count(*) = 1 from information_schema.processlist
 
504
    where state = "Waiting for table metadata lock" and
 
505
          info = "drop table t1";
 
506
--source include/wait_condition.inc
 
507
set debug_sync='now SIGNAL go';
 
508
connection default;
 
509
--reap
 
510
connection addconroot1;
 
511
--reap
 
512
connection default;
 
513
drop table t2;
 
514
disconnect addconroot1;
 
515
disconnect addconroot2;
 
516
disconnect addconroot3;
 
517
 
 
518
set debug_sync='RESET';
 
519
source include/show_binlog_events.inc;
 
520
# Check that all connections opened by test cases in this file are really
 
521
# gone so execution of other tests won't be affected by their presence.
 
522
--source include/wait_until_count_sessions.inc