Debian Codegraph @

mysql-test/suite/rpl/include/rpl_drop_create_temp_table.inc

raw
1 --source include/have_innodb.inc
2 --disable_abort_on_error
3
4 if (`SELECT HEX(@commands) = HEX('configure')`)
5 {
6 connection master;
7
8 #
9 # Index that is used as an Id to tables that trigger errors.
10 #
11 --let $tt_error_counter=0
12 --let $nt_error_counter=0
13
14 #
15 # Creates a T-table that is never dropped.
16 #
17 --eval CREATE TABLE tt_xx_1 ( id INT ) ENGINE = Innodb
18
19 #
20 # Creates a N-table that is never dropped.
21 #
22 --eval CREATE TABLE nt_xx_1 ( id INT ) ENGINE = MyIsam
23
24 #
25 # Creates a T-table that is never dropped.
26 #
27 --eval CREATE TABLE tt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb
28
29 #
30 # Creates a N-table that is never dropped.
31 #
32 --eval CREATE TABLE nt_error_1 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam
33
34 #
35 # Creates a T-table that is never dropped.
36 #
37 --eval CREATE TABLE tt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = Innodb
38
39 #
40 # Creates a N-table that is never dropped.
41 #
42 --eval CREATE TABLE nt_error_2 ( id INT, PRIMARY KEY (id) ) ENGINE = MyIsam
43
44 #
45 # Create a trigger nt_error_2 --> tt_error_2
46 #
47 DELIMITER |;
48 CREATE TRIGGER tr_i_nt_2_to_tt_2 AFTER INSERT ON nt_error_2 FOR EACH ROW
49 BEGIN
50 DECLARE in_stmt_id INTEGER;
51 INSERT INTO tt_error_2(id) VALUES (NEW.id);
52 END|
53 DELIMITER ;|
54
55 #
56 # Creates a Temporary N-table that is never dropped.
57 #
58 --eval CREATE TEMPORARY TABLE nt_tmp_xx_1 ( id INT ) ENGINE = MyIsam
59
60 #
61 # Creates a Temporary T-table that is never dropped.
62 #
63 --eval CREATE TEMPORARY TABLE tt_tmp_xx_1 ( id INT ) ENGINE = Innodb
64
65 #
66 # In what follows, we create a set of tables that are used
67 # throughout this test case. The number of tables to be
68 # created is give by the variable $tot_table.
69 #
70 #
71 # Creates Temporay N-tables that are automatically dropped and recreated
72 # when a command ends.
73 #
74 --let $n= $tot_table
75 while ($n)
76 {
77 --eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
78 --eval CREATE TEMPORARY TABLE nt_tmp_$n ( id INT ) ENGINE = MyIsam
79 --disable_query_log
80 --eval SET @check_temp='$available_n_temp'
81 --enable_query_log
82 #
83 # Updates the $available_n_temp that keeps track of the created
84 # temporary N-tables.
85 #
86 if (`SELECT HEX(@check_temp) != HEX('')`)
87 {
88 --let $available_n_temp= $available_n_temp,nt_tmp_$n
89 }
90 if (`SELECT HEX(@check_temp) = HEX('')`)
91 {
92 --let $available_n_temp= nt_tmp_$n
93 }
94 --dec $n
95 }
96
97 #
98 # Creates Temporay T-tables that are automatically dropped and recreated
99 # when a command ends.
100 #
101 --let $n= $tot_table
102 while ($n)
103 {
104 --eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
105 --eval CREATE TEMPORARY TABLE tt_tmp_$n ( id INT ) ENGINE = Innodb
106 --disable_query_log
107 --eval SET @check_temp='$available_t_temp'
108 --enable_query_log
109 #
110 # Updates the $available_t_temp that keeps track of the created
111 # temporary T-tables.
112 #
113 if (`SELECT HEX(@check_temp) != HEX('')`)
114 {
115 --let $available_t_temp= $available_t_temp,tt_tmp_$n
116 }
117 if (`SELECT HEX(@check_temp) = HEX('')`)
118 {
119 --let $available_t_temp= tt_tmp_$n
120 }
121 --dec $n
122 }
123
124 #
125 # Creates N-tables that are automatically dropped and recreated
126 # when a command ends.
127 #
128 --let $n= $tot_table
129 while ($n)
130 {
131 --eval DROP TABLE IF EXISTS nt_$n
132 --eval CREATE TABLE nt_$n ( id INT ) ENGINE = MyIsam
133 --disable_query_log
134 --eval SET @check_temp='$available_n'
135 --enable_query_log
136 #
137 # Updates the $available_n that keeps track of the created
138 # N-tables.
139 #
140 if (`SELECT HEX(@check_temp) != HEX('')`)
141 {
142 --let $available_n= $available_n,nt_$n
143 }
144 if (`SELECT HEX(@check_temp) = HEX('')`)
145 {
146 --let $available_n= nt_$n
147 }
148 --dec $n
149 }
150
151 #
152 # Creates T-tables that are automatically dropped and recreated
153 # when a command ends.
154 #
155 --let $n= $tot_table
156 while ($n)
157 {
158 --eval DROP TABLE IF EXISTS tt_$n
159 --eval CREATE TABLE tt_$n ( id INT ) ENGINE = Innodb
160 --disable_query_log
161 --eval SET @check_temp='$available_t'
162 --enable_query_log
163 #
164 # Updates the $available_t that keeps track of the created
165 # T-tables.
166 #
167 if (`SELECT HEX(@check_temp) != HEX('')`)
168 {
169 --let $available_t= $available_t,tt_$n
170 }
171 if (`SELECT HEX(@check_temp) = HEX('')`)
172 {
173 --let $available_t= tt_$n
174 }
175 --dec $n
176 }
177
178 --let $dropped_t_temp=
179 --let $dropped_n_temp=
180
181 --let $dropped_t=
182 --let $dropped_n=
183
184 let $pos_trans_command= query_get_value("SHOW MASTER STATUS", Position, 1);
185
186 SET @commands= '';
187 }
188
189 #
190 # Drops tables and synchronizes master and slave.
191 #
192
193 if (`SELECT HEX(@commands) = HEX('clean')`)
194 {
195 connection master;
196
197 DROP TABLE IF EXISTS tt_xx_1;
198
199 DROP TABLE IF EXISTS nt_xx_1;
200
201 DROP TABLE IF EXISTS tt_error_1;
202
203 DROP TABLE IF EXISTS nt_error_1;
204
205 DROP TABLE IF EXISTS tt_error_2;
206
207 DROP TABLE IF EXISTS nt_error_2;
208
209 DROP TEMPORARY TABLE IF EXISTS tt_tmp_xx_1;
210 DROP TEMPORARY TABLE IF EXISTS nt_tmp_xx_1;
211
212 --let $n= $tot_table
213 while ($n)
214 {
215 --eval DROP TABLE IF EXISTS nt_$n
216 --eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
217 --eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
218 --dec $n
219 }
220
221 --let $n= $tot_table
222 while ($n)
223 {
224 --eval DROP TABLE IF EXISTS tt_$n
225 --dec $n
226 }
227
228 sync_slave_with_master;
229
230 SET @commands= '';
231 }
232
233 #
234 # This is the core of the test is responsible for processing
235 # the following commands:
236 #
237 # B - Begin
238 # C - Commit
239 # R - Rollback
240 #
241 #
242 # T - Inserts a row into a T-table
243 # N-Temp - Inserts a row into a temporary N-table.
244 #
245 #
246 # T-SELECT-N-Temp - Selects from a temporary N-table and inserts
247 # into a T-table.
248 # N-SELECT-N-Temp - Selects from a temporary N-table and inserts
249 # into a N-table.
250 # T-SELECT-T-Temp - Selects from a temporary T-table and inserts
251 # into a T-table.
252 # N-SELECT-T-Temp - Selects from a temporary T-table and inserts
253 # into a N-table.
254 #
255 #
256 # Create-N-Temp - Creates a temporary N-table if a temporary N-table
257 # was dropped before
258 # Create-T-Temp - Creates a temporary T-table if a temporary T-table
259 # was dropped before
260 #
261 #
262 # Drop-Temp-T-Temp - Drops a temporary T-table if there is any
263 # Drop-Temp-N-Temp - Drops a temporary N-table if there is any
264 # Drop-Temp-TN-Temp - Drops both a temporary T-table and N-table if there
265 # is any
266 # Drop-Temp-TT-Temp - Drops two temporary T-tables if there is any
267 # Drop-Temp-NN-Temp - Drops two temporary N-tables if there is any
268 # Drop-Temp-Xe-Temp - Tries to drop a temporary table that does not exist
269 # Drop-Temp-NXe-Temp - Drops a temporary N-table if there is any and
270 # a temporary table that does not exist
271 # Drop-Temp-TXe-Temp - Drops a temporary T-table if there is any and
272 # a temporary table that does not exist
273 #
274 #
275 # Drop-Temp-If-Xe-Temp - Tries to drop a temporary table that does not exist
276 # Drop-Temp-If-TXe-Temp - Drops a temporary T-table if there is any and
277 # a temporary table that does not exist
278 #
279 #
280 # Drop-T - Drops a T-table if there is any
281 # Drop-N - Drops a N-table if there is any
282 # Drop-Xe - Tries to drop a table that does not exist
283 # Drop-TXe - Drops a T-table if there is any and a table that does
284 # not exist
285 # Drop-NXe - Drops a N-table if there is any and a table that does
286 # not exist
287 # Drop-TN - Drops both a T-table and N-table if there is any
288 # Drop-TT - Drops two T-tables if there is any
289 # Drop-NN - Drops two N-tables if there is any
290 # Drop-N-TN-Temp - Drops a N-table and both a temporary T-table and
291 # N-table if there is any
292 #
293 #
294 # Drop-If-Xe - Tries to drop a table that does not exist
295 # Drop-If-TXe - Drops a T-table if there is any and a table that does
296 # not exist
297 # Drop-If-NXe - Drops a N-table if there is any and a table that does
298 # not exist
299 #
300 while (`SELECT HEX(@commands) != HEX('')`)
301 {
302 --disable_query_log
303 SET @command= SUBSTRING_INDEX(@commands, ' ', 1);
304 let $command= `SELECT @command`;
305 --eval SET @check_commands= '$commands'
306 if (`SELECT HEX(@check_commands) = HEX('''')`)
307 {
308 let $commands= `SELECT @commands`;
309 }
310
311 if (`SELECT HEX(@command) = HEX('B')`)
312 {
313 --enable_query_log
314 eval BEGIN;
315 --disable_query_log
316 }
317
318 if (`SELECT HEX(@command) = HEX('T')`)
319 {
320 --enable_query_log
321 eval INSERT INTO tt_xx_1() VALUES (1);
322 --disable_query_log
323 }
324
325 if (`SELECT HEX(@command) = HEX('N')`)
326 {
327 --enable_query_log
328 eval INSERT INTO nt_xx_1() VALUES (1);
329 --disable_query_log
330 }
331
332 if (`SELECT HEX(@command) = HEX('Te')`)
333 {
334 --enable_query_log
335 --inc $tt_error_counter
336 eval INSERT INTO tt_error_1() VALUES ($tt_error_counter), ($tt_error_counter);
337 --disable_query_log
338 }
339
340 if (`SELECT HEX(@command) = HEX('Ne')`)
341 {
342 --enable_query_log
343 --inc $nt_error_counter
344 eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
345 --disable_query_log
346 }
347
348 if (`SELECT HEX(@command) = HEX('NeT-trig')`)
349 {
350 --enable_query_log
351 --inc $nt_error_counter
352 eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
353 --disable_query_log
354 }
355
356 if (`SELECT HEX(@command) = HEX('N-Temp')`)
357 {
358 --enable_query_log
359 eval INSERT INTO nt_tmp_xx_1() VALUES (1);
360 --disable_query_log
361 }
362
363 if (`SELECT HEX(@command) = HEX('N-SELECT-N-Temp')`)
364 {
365 --enable_query_log
366 eval INSERT INTO nt_xx_1 SELECT * FROM nt_tmp_xx_1;
367 --disable_query_log
368 }
369
370 if (`SELECT HEX(@command) = HEX('N-SELECT-T-Temp')`)
371 {
372 --enable_query_log
373 eval INSERT INTO nt_xx_1 SELECT * FROM tt_tmp_xx_1;
374 --disable_query_log
375 }
376
377 if (`SELECT HEX(@command) = HEX('T-SELECT-N-Temp')`)
378 {
379 --enable_query_log
380 eval INSERT INTO tt_xx_1 SELECT * FROM nt_tmp_xx_1;
381 --disable_query_log
382 }
383
384 if (`SELECT HEX(@command) = HEX('T-SELECT-T-Temp')`)
385 {
386 --enable_query_log
387 eval INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
388 --disable_query_log
389 }
390
391 if (`SELECT HEX(@command) = HEX('Create-N-Temp') || HEX(@command) = HEX('Create-T-Temp')`)
392 {
393 if (`SELECT HEX(@command) = HEX('Create-N-Temp')`)
394 {
395 --let $dropped_temp=$dropped_n_temp
396 --let $available_temp=$available_n_temp
397 }
398 if (`SELECT HEX(@command) = HEX('Create-T-Temp')`)
399 {
400 --let $dropped_temp=$dropped_t_temp
401 --let $available_temp=$available_t_temp
402 }
403
404 --eval SET @check_temp='$dropped_temp'
405 if (`SELECT HEX(@check_temp) != HEX('')`)
406 {
407 SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
408 let $table=`SELECT @temp`;
409 --eval SET @check_temp='$available_temp'
410 if (`SELECT HEX(@check_temp) != HEX('')`)
411 {
412 --let $available_temp= $available_temp,$table
413 }
414 if (`SELECT HEX(@check_temp) = HEX('')`)
415 {
416 --let $available_temp= $table
417 }
418 --eval SET @check_temp='$dropped_temp'
419 --eval SET @table_temp='$table'
420 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
421 --let $dropped_temp= `SELECT @check_temp`
422
423 if (`SELECT HEX(@command) = HEX('Create-N-Temp')`)
424 {
425 --enable_query_log
426 --eval CREATE TEMPORARY TABLE $table ( id INT ) engine= MyIsam
427 --disable_query_log
428
429 --let $available_n_temp= $available_temp
430 --let $dropped_n_temp= $dropped_temp
431 }
432 if (`SELECT HEX(@command) = HEX('Create-T-Temp')`)
433 {
434 --enable_query_log
435 --eval CREATE TEMPORARY TABLE $table ( id INT ) engine= Innodb
436 --disable_query_log
437
438 --let $available_t_temp= $available_temp
439 --let $dropped_t_temp= $dropped_temp
440 }
441 }
442 }
443
444 if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp') || HEX(@command) = HEX('Drop-Temp-T-Temp') || HEX(@command) = HEX('Drop-T') || HEX(@command) = HEX('Drop-N')`)
445 {
446 if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp')`)
447 {
448 --let $dropped_temp=$dropped_n_temp
449 --let $available_temp=$available_n_temp
450 }
451 if (`SELECT HEX(@command) = HEX('Drop-Temp-T-Temp')`)
452 {
453 --let $dropped_temp=$dropped_t_temp
454 --let $available_temp=$available_t_temp
455 }
456 if (`SELECT HEX(@command) = HEX('Drop-N')`)
457 {
458 --let $dropped_temp=$dropped_n
459 --let $available_temp=$available_n
460 }
461 if (`SELECT HEX(@command) = HEX('Drop-T')`)
462 {
463 --let $dropped_temp=$dropped_t
464 --let $available_temp=$available_t
465 }
466
467 --eval SET @check_temp='$available_temp'
468 if (`SELECT HEX(@check_temp) != HEX('')`)
469 {
470 SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
471 let $table=`SELECT @temp`;
472 --eval SET @check_temp='$dropped_temp'
473 if (`SELECT HEX(@check_temp) != HEX('')`)
474 {
475 --let $dropped_temp= $dropped_temp,$table
476 }
477 if (`SELECT HEX(@check_temp) = HEX('')`)
478 {
479 --let $dropped_temp= $table
480 }
481 --eval SET @check_temp='$available_temp'
482 --eval SET @table_temp='$table'
483 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
484 --let $available_temp= `SELECT @check_temp`
485
486 if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp')`)
487 {
488 --enable_query_log
489 --eval DROP TEMPORARY TABLE $table
490 --disable_query_log
491
492 --let $available_n_temp= $available_temp
493 --let $dropped_n_temp= $dropped_temp
494 }
495 if (`SELECT HEX(@command) = HEX('Drop-Temp-T-Temp')`)
496 {
497 --enable_query_log
498 --eval DROP TEMPORARY TABLE $table
499 --disable_query_log
500
501 --let $available_t_temp= $available_temp
502 --let $dropped_t_temp= $dropped_temp
503 }
504 if (`SELECT HEX(@command) = HEX('Drop-N')`)
505 {
506 --enable_query_log
507 --eval DROP TABLE $table
508 --disable_query_log
509
510 --let $available_n= $available_temp
511 --let $dropped_n= $dropped_temp
512 }
513 if (`SELECT HEX(@command) = HEX('Drop-T')`)
514 {
515 --enable_query_log
516 --eval DROP TABLE $table
517 --disable_query_log
518
519 --let $available_t= $available_temp
520 --let $dropped_t= $dropped_temp
521 }
522 }
523 }
524
525 if (`SELECT HEX(@command) = HEX('Drop-Temp-Xe-Temp')`)
526 {
527 --enable_query_log
528 --eval DROP TEMPORARY TABLE tt_xx_1
529 --disable_query_log
530 }
531
532 if (`SELECT HEX(@command) = HEX('Drop-Temp-If-Xe-Temp')`)
533 {
534 --enable_query_log
535 --eval DROP TEMPORARY TABLE IF EXISTS tt_xx_1
536 --disable_query_log
537 }
538
539 if (`SELECT HEX(@command) = HEX('Drop-Xe')`)
540 {
541 --enable_query_log
542 --eval DROP TABLE xx_1
543 --disable_query_log
544 }
545
546 if (`SELECT HEX(@command) = HEX('Drop-If-Xe')`)
547 {
548 --enable_query_log
549 --eval DROP TABLE IF EXISTS xx_1
550 --disable_query_log
551 }
552
553 if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp') || HEX(@command) = HEX('Drop-Temp-TXe-Temp') || HEX(@command) = HEX('Drop-NXe') || HEX(@command) = HEX('Drop-TXe') || HEX(@command) = HEX('Drop-Temp-If-NXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-TXe-Temp') || HEX(@command) = HEX('Drop-If-NXe') || HEX(@command) = HEX('Drop-If-TXe')`)
554 {
555 if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-NXe-Temp')`)
556 {
557 --let $dropped_temp=$dropped_n_temp
558 --let $available_temp=$available_n_temp
559 }
560 if (`SELECT HEX(@command) = HEX('Drop-Temp-TXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-TXe-Temp')`)
561 {
562 --let $dropped_temp=$dropped_t_temp
563 --let $available_temp=$available_t_temp
564 }
565 if (`SELECT HEX(@command) = HEX('Drop-NXe') || HEX(@command) = HEX('Drop-If-NXe')`)
566 {
567 --let $dropped_temp=$dropped_n
568 --let $available_temp=$available_n
569 }
570 if (`SELECT HEX(@command) = HEX('Drop-TXe') || HEX(@command) = HEX('Drop-If-TXe')`)
571 {
572 --let $dropped_temp=$dropped_t
573 --let $available_temp=$available_t
574 }
575
576 --eval SET @check_temp='$available_temp'
577 if (`SELECT HEX(@check_temp) != HEX('')`)
578 {
579 SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
580 let $table=`SELECT @temp`;
581 --eval SET @check_temp='$dropped_temp'
582 if (`SELECT HEX(@check_temp) != HEX('')`)
583 {
584 --let $dropped_temp= $dropped_temp,$table
585 }
586 if (`SELECT HEX(@check_temp) = HEX('')`)
587 {
588 --let $dropped_n_temp= $table
589 }
590 --eval SET @check_temp='$available_temp'
591 --eval SET @table_temp='$table'
592 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
593 --let $available_temp= `SELECT @check_temp`
594
595 if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp')`)
596 {
597 --enable_query_log
598 --eval DROP TEMPORARY TABLE $table, tt_1
599 --disable_query_log
600
601 --let $available_n_temp= $available_temp
602 --let $dropped_n_temp= $dropped_temp
603 }
604 if (`SELECT HEX(@command) = HEX('Drop-Temp-If-NXe-Temp')`)
605 {
606 --enable_query_log
607 --eval DROP TEMPORARY TABLE IF EXISTS $table, tt_1
608 --disable_query_log
609
610 --let $available_n_temp= $available_temp
611 --let $dropped_n_temp= $dropped_temp
612 }
613 if (`SELECT HEX(@command) = HEX('Drop-Temp-TXe-Temp')`)
614 {
615 --enable_query_log
616 --eval DROP TEMPORARY TABLE $table, tt_1
617 --disable_query_log
618
619 --let $available_t_temp= $available_temp
620 --let $dropped_t_temp= $dropped_temp
621 }
622 if (`SELECT HEX(@command) = HEX('Drop-Temp-If-TXe-Temp')`)
623 {
624 --enable_query_log
625 --eval DROP TEMPORARY TABLE IF EXISTS $table, tt_1
626 --disable_query_log
627
628 --let $available_t_temp= $available_temp
629 --let $dropped_t_temp= $dropped_temp
630 }
631 if (`SELECT HEX(@command) = HEX('Drop-NXe')`)
632 {
633 --enable_query_log
634 --eval DROP TABLE $table, xx_1
635 --disable_query_log
636
637 --let $available_n= $available_temp
638 --let $dropped_n= $dropped_temp
639 }
640 if (`SELECT HEX(@command) = HEX('Drop-If-NXe')`)
641 {
642 --enable_query_log
643 --eval DROP TABLE IF EXISTS $table, xx_1
644 --disable_query_log
645
646 --let $available_n= $available_temp
647 --let $dropped_n= $dropped_temp
648 }
649 if (`SELECT HEX(@command) = HEX('Drop-TXe')`)
650 {
651 --enable_query_log
652 --eval DROP TABLE $table, xx_1
653 --disable_query_log
654
655 --let $available_t= $available_temp
656 --let $dropped_t= $dropped_temp
657 }
658 if (`SELECT HEX(@command) = HEX('Drop-If-TXe')`)
659 {
660 --enable_query_log
661 --eval DROP TABLE IF EXISTS $table, xx_1
662 --disable_query_log
663
664 --let $available_t= $available_temp
665 --let $dropped_t= $dropped_temp
666 }
667 }
668 }
669
670 if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp') || HEX(@command) = HEX('Drop-Temp-TT-Temp') || HEX(@command) = HEX('Drop-NN') || HEX(@command) = HEX('Drop-TT')`)
671 {
672 if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp')`)
673 {
674 --let $dropped_temp=$dropped_n_temp
675 --let $available_temp=$available_n_temp
676 }
677 if (`SELECT HEX(@command) = HEX('Drop-Temp-TT-Temp')`)
678 {
679 --let $dropped_temp=$dropped_t_temp
680 --let $available_temp=$available_t_temp
681 }
682 if (`SELECT HEX(@command) = HEX('Drop-NN')`)
683 {
684 --let $dropped_temp=$dropped_n
685 --let $available_temp=$available_n
686 }
687 if (`SELECT HEX(@command) = HEX('Drop-TT')`)
688 {
689 --let $dropped_temp=$dropped_t
690 --let $available_temp=$available_t
691 }
692
693 --eval SET @check_temp='$available_temp'
694 if (`SELECT HEX(@check_temp) != HEX('')`)
695 {
696 --let $n= 2
697 while (`SELECT HEX(@check_temp) != HEX('') && $n != 0`)
698 {
699 SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
700 let $table=`SELECT @temp`;
701 --eval SET @check_temp='$dropped_temp'
702 if (`SELECT HEX(@check_temp) != HEX('')`)
703 {
704 --let $dropped_temp= $dropped_temp,$table
705 }
706 if (`SELECT HEX(@check_temp) = HEX('')`)
707 {
708 --let $dropped_temp= $table
709 }
710 if ($n == 1)
711 {
712 --let $table_1= $table
713 }
714 if ($n == 2)
715 {
716 --let $table_2= $table
717 }
718
719 --dec $n
720 --eval SET @check_temp='$available_temp'
721 --eval SET @table_temp='$table'
722 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
723 --let $available_temp= `SELECT @check_temp`
724 }
725
726 if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp') && $n = 0`)
727 {
728 --enable_query_log
729 --eval DROP TEMPORARY TABLE $table_1, $table_2
730 --disable_query_log
731
732 --let $available_n_temp= $available_temp
733 --let $dropped_n_temp= $dropped_temp
734 }
735 if (`SELECT HEX(@command) = HEX('Drop-Temp-TT-Temp') && $n= 0`)
736 {
737 --enable_query_log
738 --eval DROP TEMPORARY TABLE $table_1, $table_2
739 --disable_query_log
740
741 --let $available_t_temp= $available_temp
742 --let $dropped_t_temp= $dropped_temp
743 }
744 if (`SELECT HEX(@command) = HEX('Drop-NN') && $n = 0`)
745 {
746 --enable_query_log
747 --eval DROP TABLE $table_1, $table_2
748 --disable_query_log
749
750 --let $available_n= $available_temp
751 --let $dropped_n= $dropped_temp
752 }
753 if (`SELECT HEX(@command) = HEX('Drop-TT') && $n= 0`)
754 {
755 --enable_query_log
756 --eval DROP TABLE $table_1, $table_2
757 --disable_query_log
758
759 --let $available_t= $available_temp
760 --let $dropped_t= $dropped_temp
761 }
762 }
763 }
764
765 if (`SELECT HEX(@command) = HEX('Drop-Temp-TN-Temp')`)
766 {
767 --eval SET @check_temp_t='$available_t_temp'
768 --eval SET @check_temp_n='$available_n_temp'
769 if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('')`)
770 {
771 SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
772 let $table_t=`SELECT @temp_t`;
773 --eval SET @check_temp_t='$dropped_t_temp'
774 if (`SELECT HEX(@check_temp_t) != HEX('')`)
775 {
776 --let $dropped_t_temp= $dropped_t_temp,$table_t
777 }
778 if (`SELECT HEX(@check_temp_t) = HEX('')`)
779 {
780 --let $dropped_t_temp= $table_t
781 }
782 --eval SET @check_temp='$available_t_temp'
783 --eval SET @table_temp='$table_t'
784 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
785 --let $available_t_temp= `SELECT @check_temp`
786
787 SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
788 let $table_n=`SELECT @temp_n`;
789 --eval SET @check_temp_n='$dropped_n_temp'
790 if (`SELECT HEX(@check_temp_n) != HEX('')`)
791 {
792 --let $dropped_n_temp= $dropped_n_temp,$table_n
793 }
794 if (`SELECT HEX(@check_temp_n) = HEX('')`)
795 {
796 --let $dropped_n_temp= $table_n
797 }
798 --eval SET @check_temp='$available_n_temp'
799 --eval SET @table_temp='$table_n'
800 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
801 --let $available_n_temp= `SELECT @check_temp`
802
803 --enable_query_log
804 --eval DROP TEMPORARY TABLE $table_t, $table_n
805 --disable_query_log
806 }
807 }
808
809 if (`SELECT HEX(@command) = HEX('Drop-TN')`)
810 {
811 --eval SET @check_temp_t='$available_t'
812 --eval SET @check_temp_n='$available_n'
813 if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('')`)
814 {
815 SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
816 let $table_t=`SELECT @temp_t`;
817 --eval SET @check_temp_t='$dropped_t'
818 if (`SELECT HEX(@check_temp_t) != HEX('')`)
819 {
820 --let $dropped_t= $dropped_t,$table_t
821 }
822 if (`SELECT HEX(@check_temp_t) = HEX('')`)
823 {
824 --let $dropped_t= $table_t
825 }
826 --eval SET @check_temp='$available_t'
827 --eval SET @table_temp='$table_t'
828 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
829 --let $available_t= `SELECT @check_temp`
830
831 SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
832 let $table_n=`SELECT @temp_n`;
833 --eval SET @check_temp_n='$dropped_n'
834 if (`SELECT HEX(@check_temp_n) != HEX('')`)
835 {
836 --let $dropped_n= $dropped_n,$table_n
837 }
838 if (`SELECT HEX(@check_temp_n) = HEX('')`)
839 {
840 --let $dropped_n= $table_n
841 }
842 --eval SET @check_temp='$available_n'
843 --eval SET @table_temp='$table_n'
844 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
845 --let $available_t= `SELECT @check_temp`
846
847 --enable_query_log
848 --eval DROP TABLE $table_t, $table_n
849 --disable_query_log
850 }
851 }
852
853 if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp') || HEX(@command) = HEX('Drop-TN-Temp')`)
854 {
855 --eval SET @check_temp_t='$available_t_temp'
856 --eval SET @check_temp_n='$available_n_temp'
857 if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp')`)
858 {
859 --eval SET @check_n='$available_n'
860 }
861 if (`SELECT HEX(@command) = HEX('Drop-TN-Temp')`)
862 {
863 #
864 # Just to be possible to go through the next if...
865 #
866 --eval SET @check_n='...'
867 }
868 if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('') && HEX(@check_n) != HEX('')`)
869 {
870 SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
871 let $table_temp_t=`SELECT @temp_t`;
872 --eval SET @check_temp_t='$dropped_t_temp'
873 if (`SELECT HEX(@check_temp_t) != HEX('')`)
874 {
875 --let $dropped_t_temp= $dropped_t_temp,$table_temp_t
876 }
877 if (`SELECT HEX(@check_temp_t) = HEX('')`)
878 {
879 --let $dropped_t_temp= $table_temp_t
880 }
881 --eval SET @check_temp='$available_t_temp'
882 --eval SET @table_temp='$table_temp_t'
883 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
884 --let $available_t_temp= `SELECT @check_temp`
885
886 SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
887 let $table_temp_n=`SELECT @temp_n`;
888 --eval SET @check_temp_n='$dropped_n_temp'
889 if (`SELECT HEX(@check_temp_n) != HEX('')`)
890 {
891 --let $dropped_n_temp= $dropped_n_temp,$table_temp_n
892 }
893 if (`SELECT HEX(@check_temp_n) = HEX('')`)
894 {
895 --let $dropped_n_temp= $table_temp_n
896 }
897 --eval SET @check_temp='$available_n_temp'
898 --eval SET @table_temp='$table_temp_n'
899 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
900 --let $available_n_temp= `SELECT @check_temp`
901
902 if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp')`)
903 {
904 SET @temp_n= SUBSTRING_INDEX(@check_n, ',', 1);
905 let $table_n=`SELECT @temp_n`;
906 --eval SET @check_n='$dropped_n'
907 if (`SELECT HEX(@check_n) != HEX('')`)
908 {
909 --let $dropped_n= $dropped_n,$table_n
910 }
911 if (`SELECT HEX(@check_n) = HEX('')`)
912 {
913 --let $dropped_n= $table_n
914 }
915 --eval SET @check_temp='$available_n'
916 --eval SET @table_temp='$table_n'
917 SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
918 --let $available_n= `SELECT @check_temp`
919
920 --enable_query_log
921 --eval DROP TABLE $table_temp_t, $table_temp_n, $table_n
922 --disable_query_log
923 }
924 if (`SELECT HEX(@command) = HEX('Drop-TN-Temp')`)
925 {
926 --enable_query_log
927 --eval DROP TABLE $table_temp_t, $table_temp_n
928 --disable_query_log
929 }
930 }
931 }
932
933 if (`SELECT HEX(@command) = HEX('C')`)
934 {
935 --enable_query_log
936 --error 0, ER_GET_ERRMSG
937 eval COMMIT;
938 --disable_query_log
939 }
940
941 if (`SELECT HEX(@command) = HEX('R')`)
942 {
943 --enable_query_log
944 --error 0, ER_GET_ERRMSG
945 --replace_column 2 #
946 eval ROLLBACK;
947 --disable_query_log
948 }
949
950 SET @commands= LTRIM(SUBSTRING(@commands, LENGTH(@command) + 1));
951 if (`SELECT HEX(@commands) = HEX('')`)
952 {
953 let $binlog_start= $pos_trans_command;
954 --echo -b-b-b-b-b-b-b-b-b-b-b- >> $commands << -b-b-b-b-b-b-b-b-b-b-b-
955 # Use other connection because include/show_binlog_events.inc
956 # executes SELECT UUID(), which switches to row-logging when
957 # binlog_format=mixed, if there are open temporary tables. This is
958 # due to BUG#13692513.
959 --connection server_1
960 --source include/show_binlog_events.inc
961 --connection master
962 --echo -e-e-e-e-e-e-e-e-e-e-e- >> $commands << -e-e-e-e-e-e-e-e-e-e-e-
963 --echo
964
965 --disable_warnings
966 --let $available_n_temp=
967 --let $dropped_n_temp=
968 --let $n= $tot_table
969 while ($n)
970 {
971 --eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
972 --eval CREATE TEMPORARY TABLE nt_tmp_$n ( id INT ) ENGINE = MyIsam
973 --eval SET @check_temp='$available_n_temp'
974 if (`SELECT HEX(@check_temp) != HEX('')`)
975 {
976 --let $available_n_temp= $available_n_temp,nt_tmp_$n
977 }
978 if (`SELECT HEX(@check_temp) = HEX('')`)
979 {
980 --let $available_n_temp= nt_tmp_$n
981 }
982 --dec $n
983 }
984
985 --let $available_t_temp=
986 --let $dropped_t_temp=
987 --let $n= $tot_table
988 while ($n)
989 {
990 --eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
991 --eval CREATE TEMPORARY TABLE tt_tmp_$n ( id INT ) ENGINE = Innodb
992 --eval SET @check_temp='$available_t_temp'
993 if (`SELECT HEX(@check_temp) != HEX('')`)
994 {
995 --let $available_t_temp= $available_t_temp,tt_tmp_$n
996 }
997 if (`SELECT HEX(@check_temp) = HEX('')`)
998 {
999 --let $available_t_temp= tt_tmp_$n
1000 }
1001 --dec $n
1002 }
1003
1004 --let $available_t=
1005 --let $dropped_t=
1006 --let $n= $tot_table
1007 while ($n)
1008 {
1009 --eval DROP TABLE IF EXISTS tt_$n
1010 --eval CREATE TABLE tt_$n ( id INT ) ENGINE = Innodb
1011 --eval SET @check_temp='$available_t'
1012 if (`SELECT HEX(@check_temp) != HEX('')`)
1013 {
1014 --let $available_t= $available_t,tt_$n
1015 }
1016 if (`SELECT HEX(@check_temp) = HEX('')`)
1017 {
1018 --let $available_t= tt_$n
1019 }
1020 --dec $n
1021 }
1022
1023 --let $available_n=
1024 --let $dropped_n=
1025 --let $n= $tot_table
1026 while ($n)
1027 {
1028 --eval DROP TABLE IF EXISTS nt_$n
1029 --eval CREATE TABLE nt_$n ( id INT ) ENGINE = MyIsam
1030 --eval SET @check_temp='$available_n'
1031 if (`SELECT HEX(@check_temp) != HEX('')`)
1032 {
1033 --let $available_n= $available_n,nt_$n
1034 }
1035 if (`SELECT HEX(@check_temp) = HEX('')`)
1036 {
1037 --let $available_n= nt_$n
1038 }
1039 --dec $n
1040 }
1041 --enable_warnings
1042
1043 let $pos_trans_command= query_get_value("SHOW MASTER STATUS", Position, 1);
1044 let $commands= '';
1045 }
1046 --enable_query_log
1047 }