MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rpl_drop_create_temp_table.inc
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 N-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. Note that temporary
191 # tables are not explitcily dropped as they will be dropped while
192 # closing the connection.
193 #
194 if (`SELECT HEX(@commands) = HEX('clean')`)
195 {
196  connection master;
197 
198  DROP TABLE IF EXISTS tt_xx_1;
199 
200  DROP TABLE IF EXISTS nt_xx_1;
201 
202  DROP TABLE IF EXISTS tt_error_1;
203 
204  DROP TABLE IF EXISTS nt_error_1;
205 
206  DROP TABLE IF EXISTS tt_error_2;
207 
208  DROP TABLE IF EXISTS nt_error_2;
209 
210  --let $n= $tot_table
211  while ($n)
212  {
213  --eval DROP TABLE IF EXISTS nt_$n
214  --dec $n
215  }
216 
217  --let $n= $tot_table
218  while ($n)
219  {
220  --eval DROP TABLE IF EXISTS tt_$n
221  --dec $n
222  }
223 
224  sync_slave_with_master;
225 
226  SET @commands= '';
227 }
228 
229 #
230 # This is the core of the test is responsible for processing
231 # the following commands:
232 #
233 # B - Begin
234 # C - Commit
235 # R - Rollback
236 #
237 #
238 # T - Inserts a row into a T-table
239 # N-Temp - Inserts a row into a temporary N-table.
240 #
241 #
242 # T-SELECT-N-Temp - Selects from a temporary N-table and inserts
243 # into a T-table.
244 # N-SELECT-N-Temp - Selects from a temporary N-table and inserts
245 # into a N-table.
246 # T-SELECT-T-Temp - Selects from a temporary T-table and inserts
247 # into a T-table.
248 # N-SELECT-T-Temp - Selects from a temporary T-table and inserts
249 # into a N-table.
250 #
251 #
252 # Create-N-Temp - Creates a temporary N-table if a temporary N-table
253 # was dropped before
254 # Create-T-Temp - Creates a temporary T-table if a temporary T-table
255 # was dropped before
256 #
257 #
258 # Drop-Temp-T-Temp - Drops a temporary T-table if there is any
259 # Drop-Temp-N-Temp - Drops a temporary N-table if there is any
260 # Drop-Temp-TN-Temp - Drops both a temporary T-table and N-table if there
261 # is any
262 # Drop-Temp-TT-Temp - Drops two temporary T-tables if there is any
263 # Drop-Temp-NN-Temp - Drops two temporary N-tables if there is any
264 # Drop-Temp-Xe-Temp - Tries to drop a temporary table that does not exist
265 # Drop-Temp-NXe-Temp - Drops a temporary N-table if there is any and
266 # a temporary table that does not exist
267 # Drop-Temp-TXe-Temp - Drops a temporary T-table if there is any and
268 # a temporary table that does not exist
269 #
270 #
271 # Drop-Temp-If-Xe-Temp - Tries to drop a temporary table that does not exist
272 # Drop-Temp-If-TXe-Temp - Drops a temporary T-table if there is any and
273 # a temporary table that does not exist
274 #
275 #
276 # Drop-T - Drops a T-table if there is any
277 # Drop-N - Drops a N-table if there is any
278 # Drop-Xe - Tries to drop a table that does not exist
279 # Drop-TXe - Drops a T-table if there is any and a table that does
280 # not exist
281 # Drop-NXe - Drops a N-table if there is any and a table that does
282 # not exist
283 # Drop-TN - Drops both a T-table and N-table if there is any
284 # Drop-TT - Drops two T-tables if there is any
285 # Drop-NN - Drops two N-tables if there is any
286 # Drop-N-TN-Temp - Drops a N-table and both a temporary T-table and
287 # N-table if there is any
288 #
289 #
290 # Drop-If-Xe - Tries to drop a table that does not exist
291 # Drop-If-TXe - Drops a T-table if there is any and a table that does
292 # not exist
293 # Drop-If-NXe - Drops a N-table if there is any and a table that does
294 # not exist
295 #
296 while (`SELECT HEX(@commands) != HEX('')`)
297 {
298  --disable_query_log
299  SET @command= SUBSTRING_INDEX(@commands, ' ', 1);
300  let $command= `SELECT @command`;
301  --eval SET @check_commands= '$commands'
302  if (`SELECT HEX(@check_commands) = HEX('''')`)
303  {
304  let $commands= `SELECT @commands`;
305  }
306 
307  if (`SELECT HEX(@command) = HEX('B')`)
308  {
309  --enable_query_log
310  eval BEGIN;
311  --disable_query_log
312  }
313 
314  if (`SELECT HEX(@command) = HEX('T')`)
315  {
316  --enable_query_log
317  eval INSERT INTO tt_xx_1() VALUES (1);
318  --disable_query_log
319  }
320 
321  if (`SELECT HEX(@command) = HEX('N')`)
322  {
323  --enable_query_log
324  eval INSERT INTO nt_xx_1() VALUES (1);
325  --disable_query_log
326  }
327 
328  if (`SELECT HEX(@command) = HEX('Te')`)
329  {
330  --enable_query_log
331  --inc $tt_error_counter
332  eval INSERT INTO tt_error_1() VALUES ($tt_error_counter), ($tt_error_counter);
333  --disable_query_log
334  }
335 
336  if (`SELECT HEX(@command) = HEX('Ne')`)
337  {
338  --enable_query_log
339  --inc $nt_error_counter
340  eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
341  --disable_query_log
342  }
343 
344  if (`SELECT HEX(@command) = HEX('NeT-trig')`)
345  {
346  --enable_query_log
347  --inc $nt_error_counter
348  eval INSERT INTO nt_error_1() VALUES ($nt_error_counter), ($nt_error_counter);
349  --disable_query_log
350  }
351 
352  if (`SELECT HEX(@command) = HEX('N-Temp')`)
353  {
354  --enable_query_log
355  eval INSERT INTO nt_tmp_xx_1() VALUES (1);
356  --disable_query_log
357  }
358 
359  if (`SELECT HEX(@command) = HEX('N-SELECT-N-Temp')`)
360  {
361  --enable_query_log
362  eval INSERT INTO nt_xx_1 SELECT * FROM nt_tmp_xx_1;
363  --disable_query_log
364  }
365 
366  if (`SELECT HEX(@command) = HEX('N-SELECT-T-Temp')`)
367  {
368  --enable_query_log
369  eval INSERT INTO nt_xx_1 SELECT * FROM tt_tmp_xx_1;
370  --disable_query_log
371  }
372 
373  if (`SELECT HEX(@command) = HEX('T-SELECT-N-Temp')`)
374  {
375  --enable_query_log
376  eval INSERT INTO tt_xx_1 SELECT * FROM nt_tmp_xx_1;
377  --disable_query_log
378  }
379 
380  if (`SELECT HEX(@command) = HEX('T-SELECT-T-Temp')`)
381  {
382  --enable_query_log
383  eval INSERT INTO tt_xx_1 SELECT * FROM tt_tmp_xx_1;
384  --disable_query_log
385  }
386 
387  if (`SELECT HEX(@command) = HEX('Create-N-Temp') || HEX(@command) = HEX('Create-T-Temp')`)
388  {
389  if (`SELECT HEX(@command) = HEX('Create-N-Temp')`)
390  {
391  --let $dropped_temp=$dropped_n_temp
392  --let $available_temp=$available_n_temp
393  }
394  if (`SELECT HEX(@command) = HEX('Create-T-Temp')`)
395  {
396  --let $dropped_temp=$dropped_t_temp
397  --let $available_temp=$available_t_temp
398  }
399 
400  --eval SET @check_temp='$dropped_temp'
401  if (`SELECT HEX(@check_temp) != HEX('')`)
402  {
403  SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
404  let $table=`SELECT @temp`;
405  --eval SET @check_temp='$available_temp'
406  if (`SELECT HEX(@check_temp) != HEX('')`)
407  {
408  --let $available_temp= $available_temp,$table
409  }
410  if (`SELECT HEX(@check_temp) = HEX('')`)
411  {
412  --let $available_temp= $table
413  }
414  --eval SET @check_temp='$dropped_temp'
415  --eval SET @table_temp='$table'
416  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
417  --let $dropped_temp= `SELECT @check_temp`
418 
419  if (`SELECT HEX(@command) = HEX('Create-N-Temp')`)
420  {
421  --enable_query_log
422  --eval CREATE TEMPORARY TABLE $table ( id INT ) engine= MyIsam
423  --disable_query_log
424 
425  --let $available_n_temp= $available_temp
426  --let $dropped_n_temp= $dropped_temp
427  }
428  if (`SELECT HEX(@command) = HEX('Create-T-Temp')`)
429  {
430  --enable_query_log
431  --eval CREATE TEMPORARY TABLE $table ( id INT ) engine= Innodb
432  --disable_query_log
433 
434  --let $available_t_temp= $available_temp
435  --let $dropped_t_temp= $dropped_temp
436  }
437  }
438  }
439 
440  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')`)
441  {
442  if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp')`)
443  {
444  --let $dropped_temp=$dropped_n_temp
445  --let $available_temp=$available_n_temp
446  }
447  if (`SELECT HEX(@command) = HEX('Drop-Temp-T-Temp')`)
448  {
449  --let $dropped_temp=$dropped_t_temp
450  --let $available_temp=$available_t_temp
451  }
452  if (`SELECT HEX(@command) = HEX('Drop-N')`)
453  {
454  --let $dropped_temp=$dropped_n
455  --let $available_temp=$available_n
456  }
457  if (`SELECT HEX(@command) = HEX('Drop-T')`)
458  {
459  --let $dropped_temp=$dropped_t
460  --let $available_temp=$available_t
461  }
462 
463  --eval SET @check_temp='$available_temp'
464  if (`SELECT HEX(@check_temp) != HEX('')`)
465  {
466  SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
467  let $table=`SELECT @temp`;
468  --eval SET @check_temp='$dropped_temp'
469  if (`SELECT HEX(@check_temp) != HEX('')`)
470  {
471  --let $dropped_temp= $dropped_temp,$table
472  }
473  if (`SELECT HEX(@check_temp) = HEX('')`)
474  {
475  --let $dropped_temp= $table
476  }
477  --eval SET @check_temp='$available_temp'
478  --eval SET @table_temp='$table'
479  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
480  --let $available_temp= `SELECT @check_temp`
481 
482  if (`SELECT HEX(@command) = HEX('Drop-Temp-N-Temp')`)
483  {
484  --enable_query_log
485  --eval DROP TEMPORARY TABLE $table
486  --disable_query_log
487 
488  --let $available_n_temp= $available_temp
489  --let $dropped_n_temp= $dropped_temp
490  }
491  if (`SELECT HEX(@command) = HEX('Drop-Temp-T-Temp')`)
492  {
493  --enable_query_log
494  --eval DROP TEMPORARY TABLE $table
495  --disable_query_log
496 
497  --let $available_t_temp= $available_temp
498  --let $dropped_t_temp= $dropped_temp
499  }
500  if (`SELECT HEX(@command) = HEX('Drop-N')`)
501  {
502  --enable_query_log
503  --eval DROP TABLE $table
504  --disable_query_log
505 
506  --let $available_n= $available_temp
507  --let $dropped_n= $dropped_temp
508  }
509  if (`SELECT HEX(@command) = HEX('Drop-T')`)
510  {
511  --enable_query_log
512  --eval DROP TABLE $table
513  --disable_query_log
514 
515  --let $available_t= $available_temp
516  --let $dropped_t= $dropped_temp
517  }
518  }
519  }
520 
521  if (`SELECT HEX(@command) = HEX('Drop-Temp-Xe-Temp')`)
522  {
523  --enable_query_log
524  --eval DROP TEMPORARY TABLE tt_xx_1
525  --disable_query_log
526  }
527 
528  if (`SELECT HEX(@command) = HEX('Drop-Temp-If-Xe-Temp')`)
529  {
530  --enable_query_log
531  --eval DROP TEMPORARY TABLE IF EXISTS tt_xx_1
532  --disable_query_log
533  }
534 
535  if (`SELECT HEX(@command) = HEX('Drop-Xe')`)
536  {
537  --enable_query_log
538  --eval DROP TABLE xx_1
539  --disable_query_log
540  }
541 
542  if (`SELECT HEX(@command) = HEX('Drop-If-Xe')`)
543  {
544  --enable_query_log
545  --eval DROP TABLE IF EXISTS xx_1
546  --disable_query_log
547  }
548 
549  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')`)
550  {
551  if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-NXe-Temp')`)
552  {
553  --let $dropped_temp=$dropped_n_temp
554  --let $available_temp=$available_n_temp
555  }
556  if (`SELECT HEX(@command) = HEX('Drop-Temp-TXe-Temp') || HEX(@command) = HEX('Drop-Temp-If-TXe-Temp')`)
557  {
558  --let $dropped_temp=$dropped_t_temp
559  --let $available_temp=$available_t_temp
560  }
561  if (`SELECT HEX(@command) = HEX('Drop-NXe') || HEX(@command) = HEX('Drop-If-NXe')`)
562  {
563  --let $dropped_temp=$dropped_n
564  --let $available_temp=$available_n
565  }
566  if (`SELECT HEX(@command) = HEX('Drop-TXe') || HEX(@command) = HEX('Drop-If-TXe')`)
567  {
568  --let $dropped_temp=$dropped_t
569  --let $available_temp=$available_t
570  }
571 
572  --eval SET @check_temp='$available_temp'
573  if (`SELECT HEX(@check_temp) != HEX('')`)
574  {
575  SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
576  let $table=`SELECT @temp`;
577  --eval SET @check_temp='$dropped_temp'
578  if (`SELECT HEX(@check_temp) != HEX('')`)
579  {
580  --let $dropped_temp= $dropped_temp,$table
581  }
582  if (`SELECT HEX(@check_temp) = HEX('')`)
583  {
584  --let $dropped_n_temp= $table
585  }
586  --eval SET @check_temp='$available_temp'
587  --eval SET @table_temp='$table'
588  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
589  --let $available_temp= `SELECT @check_temp`
590 
591  if (`SELECT HEX(@command) = HEX('Drop-Temp-NXe-Temp')`)
592  {
593  --enable_query_log
594  --eval DROP TEMPORARY TABLE $table, tt_1
595  --disable_query_log
596 
597  --let $available_n_temp= $available_temp
598  --let $dropped_n_temp= $dropped_temp
599  }
600  if (`SELECT HEX(@command) = HEX('Drop-Temp-If-NXe-Temp')`)
601  {
602  --enable_query_log
603  --eval DROP TEMPORARY TABLE IF EXISTS $table, tt_1
604  --disable_query_log
605 
606  --let $available_n_temp= $available_temp
607  --let $dropped_n_temp= $dropped_temp
608  }
609  if (`SELECT HEX(@command) = HEX('Drop-Temp-TXe-Temp')`)
610  {
611  --enable_query_log
612  --eval DROP TEMPORARY TABLE $table, tt_1
613  --disable_query_log
614 
615  --let $available_t_temp= $available_temp
616  --let $dropped_t_temp= $dropped_temp
617  }
618  if (`SELECT HEX(@command) = HEX('Drop-Temp-If-TXe-Temp')`)
619  {
620  --enable_query_log
621  --eval DROP TEMPORARY TABLE IF EXISTS $table, tt_1
622  --disable_query_log
623 
624  --let $available_t_temp= $available_temp
625  --let $dropped_t_temp= $dropped_temp
626  }
627  if (`SELECT HEX(@command) = HEX('Drop-NXe')`)
628  {
629  --enable_query_log
630  --eval DROP TABLE $table, xx_1
631  --disable_query_log
632 
633  --let $available_n= $available_temp
634  --let $dropped_n= $dropped_temp
635  }
636  if (`SELECT HEX(@command) = HEX('Drop-If-NXe')`)
637  {
638  --enable_query_log
639  --eval DROP TABLE IF EXISTS $table, xx_1
640  --disable_query_log
641 
642  --let $available_n= $available_temp
643  --let $dropped_n= $dropped_temp
644  }
645  if (`SELECT HEX(@command) = HEX('Drop-TXe')`)
646  {
647  --enable_query_log
648  --eval DROP TABLE $table, xx_1
649  --disable_query_log
650 
651  --let $available_t= $available_temp
652  --let $dropped_t= $dropped_temp
653  }
654  if (`SELECT HEX(@command) = HEX('Drop-If-TXe')`)
655  {
656  --enable_query_log
657  --eval DROP TABLE IF EXISTS $table, xx_1
658  --disable_query_log
659 
660  --let $available_t= $available_temp
661  --let $dropped_t= $dropped_temp
662  }
663  }
664  }
665 
666  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')`)
667  {
668  if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp')`)
669  {
670  --let $dropped_temp=$dropped_n_temp
671  --let $available_temp=$available_n_temp
672  }
673  if (`SELECT HEX(@command) = HEX('Drop-Temp-TT-Temp')`)
674  {
675  --let $dropped_temp=$dropped_t_temp
676  --let $available_temp=$available_t_temp
677  }
678  if (`SELECT HEX(@command) = HEX('Drop-NN')`)
679  {
680  --let $dropped_temp=$dropped_n
681  --let $available_temp=$available_n
682  }
683  if (`SELECT HEX(@command) = HEX('Drop-TT')`)
684  {
685  --let $dropped_temp=$dropped_t
686  --let $available_temp=$available_t
687  }
688 
689  --eval SET @check_temp='$available_temp'
690  if (`SELECT HEX(@check_temp) != HEX('')`)
691  {
692  --let $n= 2
693  while (`SELECT HEX(@check_temp) != HEX('') && $n != 0`)
694  {
695  SET @temp= SUBSTRING_INDEX(@check_temp, ',', 1);
696  let $table=`SELECT @temp`;
697  --eval SET @check_temp='$dropped_temp'
698  if (`SELECT HEX(@check_temp) != HEX('')`)
699  {
700  --let $dropped_temp= $dropped_temp,$table
701  }
702  if (`SELECT HEX(@check_temp) = HEX('')`)
703  {
704  --let $dropped_temp= $table
705  }
706  if ($n == 1)
707  {
708  --let $table_1= $table
709  }
710  if ($n == 2)
711  {
712  --let $table_2= $table
713  }
714 
715  --dec $n
716  --eval SET @check_temp='$available_temp'
717  --eval SET @table_temp='$table'
718  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
719  --let $available_temp= `SELECT @check_temp`
720  }
721 
722  if (`SELECT HEX(@command) = HEX('Drop-Temp-NN-Temp') && $n = 0`)
723  {
724  --enable_query_log
725  --eval DROP TEMPORARY TABLE $table_1, $table_2
726  --disable_query_log
727 
728  --let $available_n_temp= $available_temp
729  --let $dropped_n_temp= $dropped_temp
730  }
731  if (`SELECT HEX(@command) = HEX('Drop-Temp-TT-Temp') && $n= 0`)
732  {
733  --enable_query_log
734  --eval DROP TEMPORARY TABLE $table_1, $table_2
735  --disable_query_log
736 
737  --let $available_t_temp= $available_temp
738  --let $dropped_t_temp= $dropped_temp
739  }
740  if (`SELECT HEX(@command) = HEX('Drop-NN') && $n = 0`)
741  {
742  --enable_query_log
743  --eval DROP TABLE $table_1, $table_2
744  --disable_query_log
745 
746  --let $available_n= $available_temp
747  --let $dropped_n= $dropped_temp
748  }
749  if (`SELECT HEX(@command) = HEX('Drop-TT') && $n= 0`)
750  {
751  --enable_query_log
752  --eval DROP TABLE $table_1, $table_2
753  --disable_query_log
754 
755  --let $available_t= $available_temp
756  --let $dropped_t= $dropped_temp
757  }
758  }
759  }
760 
761  if (`SELECT HEX(@command) = HEX('Drop-Temp-TN-Temp')`)
762  {
763  --eval SET @check_temp_t='$available_t_temp'
764  --eval SET @check_temp_n='$available_n_temp'
765  if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('')`)
766  {
767  SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
768  let $table_t=`SELECT @temp_t`;
769  --eval SET @check_temp_t='$dropped_t_temp'
770  if (`SELECT HEX(@check_temp_t) != HEX('')`)
771  {
772  --let $dropped_t_temp= $dropped_t_temp,$table_t
773  }
774  if (`SELECT HEX(@check_temp_t) = HEX('')`)
775  {
776  --let $dropped_t_temp= $table_t
777  }
778  --eval SET @check_temp='$available_t_temp'
779  --eval SET @table_temp='$table_t'
780  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
781  --let $available_t_temp= `SELECT @check_temp`
782 
783  SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
784  let $table_n=`SELECT @temp_n`;
785  --eval SET @check_temp_n='$dropped_n_temp'
786  if (`SELECT HEX(@check_temp_n) != HEX('')`)
787  {
788  --let $dropped_n_temp= $dropped_n_temp,$table_n
789  }
790  if (`SELECT HEX(@check_temp_n) = HEX('')`)
791  {
792  --let $dropped_n_temp= $table_n
793  }
794  --eval SET @check_temp='$available_n_temp'
795  --eval SET @table_temp='$table_n'
796  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
797  --let $available_n_temp= `SELECT @check_temp`
798 
799  --enable_query_log
800  --eval DROP TEMPORARY TABLE $table_t, $table_n
801  --disable_query_log
802  }
803  }
804 
805  if (`SELECT HEX(@command) = HEX('Drop-TN')`)
806  {
807  --eval SET @check_temp_t='$available_t'
808  --eval SET @check_temp_n='$available_n'
809  if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('')`)
810  {
811  SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
812  let $table_t=`SELECT @temp_t`;
813  --eval SET @check_temp_t='$dropped_t'
814  if (`SELECT HEX(@check_temp_t) != HEX('')`)
815  {
816  --let $dropped_t= $dropped_t,$table_t
817  }
818  if (`SELECT HEX(@check_temp_t) = HEX('')`)
819  {
820  --let $dropped_t= $table_t
821  }
822  --eval SET @check_temp='$available_t'
823  --eval SET @table_temp='$table_t'
824  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
825  --let $available_t= `SELECT @check_temp`
826 
827  SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
828  let $table_n=`SELECT @temp_n`;
829  --eval SET @check_temp_n='$dropped_n'
830  if (`SELECT HEX(@check_temp_n) != HEX('')`)
831  {
832  --let $dropped_n= $dropped_n,$table_n
833  }
834  if (`SELECT HEX(@check_temp_n) = HEX('')`)
835  {
836  --let $dropped_n= $table_n
837  }
838  --eval SET @check_temp='$available_n'
839  --eval SET @table_temp='$table_n'
840  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
841  --let $available_t= `SELECT @check_temp`
842 
843  --enable_query_log
844  --eval DROP TABLE $table_t, $table_n
845  --disable_query_log
846  }
847  }
848 
849  if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp') || HEX(@command) = HEX('Drop-TN-Temp')`)
850  {
851  --eval SET @check_temp_t='$available_t_temp'
852  --eval SET @check_temp_n='$available_n_temp'
853  if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp')`)
854  {
855  --eval SET @check_n='$available_n'
856  }
857  if (`SELECT HEX(@command) = HEX('Drop-TN-Temp')`)
858  {
859  #
860  # Just to be possible to go through the next if...
861  #
862  --eval SET @check_n='...'
863  }
864  if (`SELECT HEX(@check_temp_t) != HEX('') && HEX(@check_temp_n) != HEX('') && HEX(@check_n) != HEX('')`)
865  {
866  SET @temp_t= SUBSTRING_INDEX(@check_temp_t, ',', 1);
867  let $table_temp_t=`SELECT @temp_t`;
868  --eval SET @check_temp_t='$dropped_t_temp'
869  if (`SELECT HEX(@check_temp_t) != HEX('')`)
870  {
871  --let $dropped_t_temp= $dropped_t_temp,$table_temp_t
872  }
873  if (`SELECT HEX(@check_temp_t) = HEX('')`)
874  {
875  --let $dropped_t_temp= $table_temp_t
876  }
877  --eval SET @check_temp='$available_t_temp'
878  --eval SET @table_temp='$table_temp_t'
879  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
880  --let $available_t_temp= `SELECT @check_temp`
881 
882  SET @temp_n= SUBSTRING_INDEX(@check_temp_n, ',', 1);
883  let $table_temp_n=`SELECT @temp_n`;
884  --eval SET @check_temp_n='$dropped_n_temp'
885  if (`SELECT HEX(@check_temp_n) != HEX('')`)
886  {
887  --let $dropped_n_temp= $dropped_n_temp,$table_temp_n
888  }
889  if (`SELECT HEX(@check_temp_n) = HEX('')`)
890  {
891  --let $dropped_n_temp= $table_temp_n
892  }
893  --eval SET @check_temp='$available_n_temp'
894  --eval SET @table_temp='$table_temp_n'
895  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
896  --let $available_n_temp= `SELECT @check_temp`
897 
898  if (`SELECT HEX(@command) = HEX('Drop-N-TN-Temp')`)
899  {
900  SET @temp_n= SUBSTRING_INDEX(@check_n, ',', 1);
901  let $table_n=`SELECT @temp_n`;
902  --eval SET @check_n='$dropped_n'
903  if (`SELECT HEX(@check_n) != HEX('')`)
904  {
905  --let $dropped_n= $dropped_n,$table_n
906  }
907  if (`SELECT HEX(@check_n) = HEX('')`)
908  {
909  --let $dropped_n= $table_n
910  }
911  --eval SET @check_temp='$available_n'
912  --eval SET @table_temp='$table_n'
913  SET @check_temp= LTRIM(SUBSTRING(@check_temp, LENGTH(@table_temp) + 2));
914  --let $available_n= `SELECT @check_temp`
915 
916  --enable_query_log
917  --eval DROP TABLE $table_temp_t, $table_temp_n, $table_n
918  --disable_query_log
919  }
920  if (`SELECT HEX(@command) = HEX('Drop-TN-Temp')`)
921  {
922  --enable_query_log
923  --eval DROP TABLE $table_temp_t, $table_temp_n
924  --disable_query_log
925  }
926  }
927  }
928 
929  if (`SELECT HEX(@command) = HEX('C')`)
930  {
931  --enable_query_log
932  --error 0, ER_GET_ERRMSG
933  eval COMMIT;
934  --disable_query_log
935  }
936 
937  if (`SELECT HEX(@command) = HEX('R')`)
938  {
939  --enable_query_log
940  --error 0, ER_GET_ERRMSG
941  --replace_column 2 #
942  eval ROLLBACK;
943  --disable_query_log
944  }
945 
946  SET @commands= LTRIM(SUBSTRING(@commands, LENGTH(@command) + 1));
947  if (`SELECT HEX(@commands) = HEX('')`)
948  {
949  let $binlog_start= $pos_trans_command;
950  --echo -b-b-b-b-b-b-b-b-b-b-b- >> $commands << -b-b-b-b-b-b-b-b-b-b-b-
951  # Use other connection because include/show_binlog_events.inc
952  # executes SELECT UUID(), which switches to row-logging when
953  # binlog_format=mixed, if there are open temporary tables. This is
954  # due to BUG#13692513.
955  --connection server_1
956  --source include/show_binlog_events.inc
957  --connection master
958  --echo -e-e-e-e-e-e-e-e-e-e-e- >> $commands << -e-e-e-e-e-e-e-e-e-e-e-
959  --echo
960 
961  --disable_warnings
962  --let $available_n_temp=
963  --let $dropped_n_temp=
964  --let $n= $tot_table
965  while ($n)
966  {
967  --eval DROP TEMPORARY TABLE IF EXISTS nt_tmp_$n
968  --eval CREATE TEMPORARY TABLE nt_tmp_$n ( id INT ) ENGINE = MyIsam
969  --eval SET @check_temp='$available_n_temp'
970  if (`SELECT HEX(@check_temp) != HEX('')`)
971  {
972  --let $available_n_temp= $available_n_temp,nt_tmp_$n
973  }
974  if (`SELECT HEX(@check_temp) = HEX('')`)
975  {
976  --let $available_n_temp= nt_tmp_$n
977  }
978  --dec $n
979  }
980 
981  --let $available_t_temp=
982  --let $dropped_t_temp=
983  --let $n= $tot_table
984  while ($n)
985  {
986  --eval DROP TEMPORARY TABLE IF EXISTS tt_tmp_$n
987  --eval CREATE TEMPORARY TABLE tt_tmp_$n ( id INT ) ENGINE = Innodb
988  --eval SET @check_temp='$available_t_temp'
989  if (`SELECT HEX(@check_temp) != HEX('')`)
990  {
991  --let $available_t_temp= $available_t_temp,tt_tmp_$n
992  }
993  if (`SELECT HEX(@check_temp) = HEX('')`)
994  {
995  --let $available_t_temp= tt_tmp_$n
996  }
997  --dec $n
998  }
999 
1000  --let $available_t=
1001  --let $dropped_t=
1002  --let $n= $tot_table
1003  while ($n)
1004  {
1005  --eval DROP TABLE IF EXISTS tt_$n
1006  --eval CREATE TABLE tt_$n ( id INT ) ENGINE = Innodb
1007  --eval SET @check_temp='$available_t'
1008  if (`SELECT HEX(@check_temp) != HEX('')`)
1009  {
1010  --let $available_t= $available_t,tt_$n
1011  }
1012  if (`SELECT HEX(@check_temp) = HEX('')`)
1013  {
1014  --let $available_t= tt_$n
1015  }
1016  --dec $n
1017  }
1018 
1019  --let $available_n=
1020  --let $dropped_n=
1021  --let $n= $tot_table
1022  while ($n)
1023  {
1024  --eval DROP TABLE IF EXISTS nt_$n
1025  --eval CREATE TABLE nt_$n ( id INT ) ENGINE = MyIsam
1026  --eval SET @check_temp='$available_n'
1027  if (`SELECT HEX(@check_temp) != HEX('')`)
1028  {
1029  --let $available_n= $available_n,nt_$n
1030  }
1031  if (`SELECT HEX(@check_temp) = HEX('')`)
1032  {
1033  --let $available_n= nt_$n
1034  }
1035  --dec $n
1036  }
1037  --enable_warnings
1038 
1039  let $pos_trans_command= query_get_value("SHOW MASTER STATUS", Position, 1);
1040  let $commands= '';
1041  }
1042  --enable_query_log
1043 }