1# ==== Purpose ====
2#
3# This is an auxiliary file used by rpl_mixing_engines.test. It
4# executes SQL statements according to a format string, as specified in
5# rpl_mixing_engines.test. In addition, it accepts the special format
6# strings 'configure' and 'clean', used before and after everything else.
7#
8# ==== Usage ====
9#
10# --let $commands= command1 command2 ...
11# --let $database_name= name
12# [--let $verbose= 1]
13# --source include/rpl_mixing_engines.inc
14#
15#   Parameters:
16#
17#     $commands
18#       Space-separated list of commands. See rpl_mixing_engines.test
19#       for a list of all commands.
20#
21#     $database_name
22#       Name of database to use. If $commands is 'configure' or
23#       'clean', and the database name is not 'test', then the
24#       database is created or dropped, respectively.
25#
26#     $verbose
27#       By default, show_binlog_events.inc is sourced after all
28#       commands have been processed, showing the result of all
29#       commands.  If this flag is set, then show_binlog_events.inc is
30#       also sourced once after each command, showing only the result
31#       of that command.
32
33--echo rpl_mixing_engines.inc [commands=$commands]
34
35--let $rme_initial_commands= $commands
36
37if ($commands == 'configure')
38{
39  connection master;
40
41  --disable_query_log
42  if ($database_name != 'test')
43  {
44    --eval CREATE DATABASE $database_name
45  }
46  --eval use $database_name
47  --enable_query_log
48
49  eval CREATE TABLE nt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
50  eval CREATE TABLE nt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
51  eval CREATE TABLE nt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
52  eval CREATE TABLE nt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
53  eval CREATE TABLE nt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
54  eval CREATE TABLE nt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = MyISAM;
55  eval CREATE TABLE tt_1 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = $engine_type;
56  eval CREATE TABLE tt_2 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = $engine_type;
57  eval CREATE TABLE tt_3 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = $engine_type;
58  eval CREATE TABLE tt_4 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = $engine_type;
59  eval CREATE TABLE tt_5 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = $engine_type;
60  eval CREATE TABLE tt_6 (trans_id INT, stmt_id INT, info VARCHAR(64), PRIMARY KEY(trans_id, stmt_id)) ENGINE = $engine_type;
61
62  INSERT INTO nt_1(trans_id, stmt_id) VALUES(1,1);
63  INSERT INTO nt_2(trans_id, stmt_id) VALUES(1,1);
64  INSERT INTO nt_3(trans_id, stmt_id) VALUES(1,1);
65  INSERT INTO nt_4(trans_id, stmt_id) VALUES(1,1);
66  INSERT INTO nt_5(trans_id, stmt_id) VALUES(1,1);
67  INSERT INTO nt_6(trans_id, stmt_id) VALUES(1,1);
68
69  INSERT INTO tt_1(trans_id, stmt_id) VALUES(1,1);
70  INSERT INTO tt_2(trans_id, stmt_id) VALUES(1,1);
71  INSERT INTO tt_3(trans_id, stmt_id) VALUES(1,1);
72  INSERT INTO tt_4(trans_id, stmt_id) VALUES(1,1);
73  INSERT INTO tt_5(trans_id, stmt_id) VALUES(1,1);
74  INSERT INTO tt_6(trans_id, stmt_id) VALUES(1,1);
75
76  DELIMITER |;
77
78  CREATE PROCEDURE pc_i_tt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
79  BEGIN
80    DECLARE in_stmt_id INTEGER;
81    SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
82    SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
83    INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
84    INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
85  END|
86
87  CREATE PROCEDURE pc_i_nt_5_suc (IN p_trans_id INTEGER, IN p_stmt_id INTEGER)
88  BEGIN
89    DECLARE in_stmt_id INTEGER;
90    SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
91    SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
92    INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
93    INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
94  END|
95
96  CREATE FUNCTION fc_i_tt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
97  BEGIN
98    DECLARE in_stmt_id INTEGER;
99    SELECT max(stmt_id) INTO in_stmt_id FROM tt_5 WHERE trans_id= p_trans_id;
100    SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
101    INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
102    INSERT INTO tt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
103    RETURN "fc_i_tt_5_suc";
104  END|
105
106  CREATE FUNCTION fc_i_nt_5_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
107  BEGIN
108    DECLARE in_stmt_id INTEGER;
109    SELECT max(stmt_id) INTO in_stmt_id FROM nt_5 WHERE trans_id= p_trans_id;
110    SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
111    INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
112    INSERT INTO nt_5(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id + 1);
113    RETURN "fc_i_nt_5_suc";
114  END|
115
116  CREATE FUNCTION fc_i_nt_3_tt_3_suc (p_trans_id INTEGER, p_stmt_id INTEGER) RETURNS VARCHAR(64)
117  BEGIN
118    DECLARE in_stmt_id INTEGER;
119    SELECT max(stmt_id) INTO in_stmt_id FROM nt_3 WHERE trans_id= p_trans_id;
120    SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
121    INSERT INTO nt_3(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
122
123    SELECT max(stmt_id) INTO in_stmt_id FROM tt_3 WHERE trans_id= p_trans_id;
124    SELECT COALESCE(greatest(in_stmt_id + 1, p_stmt_id), 1) INTO in_stmt_id;
125    INSERT INTO tt_3(trans_id, stmt_id) VALUES (p_trans_id, in_stmt_id);
126    RETURN "fc_i_nt_3_tt_3_suc";
127  END|
128
129  CREATE TRIGGER tr_i_tt_3_to_nt_3 AFTER INSERT ON tt_3 FOR EACH ROW
130  BEGIN
131    DECLARE in_stmt_id INTEGER;
132    SELECT max(stmt_id) INTO in_stmt_id FROM nt_3 WHERE trans_id= NEW.trans_id;
133    SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
134    INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
135    INSERT INTO nt_3(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
136  END|
137
138  CREATE TRIGGER tr_i_nt_4_to_tt_4 AFTER INSERT ON nt_4 FOR EACH ROW
139  BEGIN
140    DECLARE in_stmt_id INTEGER;
141    SELECT max(stmt_id) INTO in_stmt_id FROM tt_4 WHERE trans_id= NEW.trans_id;
142    SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
143    INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
144    INSERT INTO tt_4(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
145  END|
146
147  CREATE TRIGGER tr_i_tt_5_to_tt_6 AFTER INSERT ON tt_5 FOR EACH ROW
148  BEGIN
149    DECLARE in_stmt_id INTEGER;
150    SELECT max(stmt_id) INTO in_stmt_id FROM tt_6 WHERE trans_id= NEW.trans_id;
151    SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id, 1), 1) INTO in_stmt_id;
152    INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
153    INSERT INTO tt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
154  END|
155
156  CREATE TRIGGER tr_i_nt_5_to_nt_6 AFTER INSERT ON nt_5 FOR EACH ROW
157  BEGIN
158    DECLARE in_stmt_id INTEGER;
159    SELECT max(stmt_id) INTO in_stmt_id FROM nt_6 WHERE trans_id= NEW.trans_id;
160    SELECT COALESCE(greatest(in_stmt_id + 1, NEW.stmt_id), 1) INTO in_stmt_id;
161    INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id);
162    INSERT INTO nt_6(trans_id, stmt_id) VALUES (NEW.trans_id, in_stmt_id + 1);
163  END|
164
165  DELIMITER ;|
166
167  let $pos_trans_command= query_get_value("SHOW MASTER STATUS", Position, 1);
168
169  let $trans_id= 7;
170  let $tb_id= 1;
171  let $stmt_id= 1;
172  --let $commands=
173  let $sn= 0;
174}
175
176if ($commands == 'clean')
177{
178  connection master;
179
180  --disable_query_log
181  --eval use $database_name
182  --enable_query_log
183
184  DROP TABLE tt_1;
185  DROP TABLE tt_2;
186  DROP TABLE tt_3;
187  DROP TABLE tt_4;
188  DROP TABLE tt_5;
189  DROP TABLE tt_6;
190
191  DROP TABLE nt_1;
192  DROP TABLE nt_2;
193  DROP TABLE nt_3;
194  DROP TABLE nt_4;
195  DROP TABLE nt_5;
196  DROP TABLE nt_6;
197
198  DROP PROCEDURE pc_i_tt_5_suc;
199  DROP PROCEDURE pc_i_nt_5_suc;
200  DROP FUNCTION fc_i_tt_5_suc;
201  DROP FUNCTION fc_i_nt_5_suc;
202  DROP FUNCTION fc_i_nt_3_tt_3_suc;
203
204  --disable_query_log
205  if ($database_name != 'test')
206  {
207    --eval DROP DATABASE $database_name
208  }
209  --enable_query_log
210
211  sync_slave_with_master;
212
213  --let $commands=
214}
215
216while ($commands != '')
217{
218  --disable_query_log
219  --eval use $database_name
220  --enable_query_log
221
222  --disable_query_log
223  --let $command= `SELECT SUBSTRING_INDEX('$commands', ' ', 1)`
224  if ($verbose)
225  {
226    --echo -b-b-b-b-b-b-b-b-b-b-b- >> $command << -b-b-b-b-b-b-b-b-b-b-b-
227    let $pos_command= query_get_value("SHOW MASTER STATUS", Position, 1);
228  }
229  --enable_query_log
230  if ($command == 'B')
231  {
232    eval BEGIN;
233  }
234  if ($command == 'T')
235  {
236    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
237    eval INSERT INTO tt_1(trans_id, stmt_id) VALUES ($trans_id, $stmt_id);
238    inc $stmt_id;
239  }
240  if ($command == 'T-trig')
241  {
242    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
243    eval INSERT INTO tt_5(trans_id, stmt_id) VALUES ($trans_id, $stmt_id);
244    inc $stmt_id;
245  }
246  if ($command == 'T-func')
247  {
248    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
249    eval SELECT fc_i_tt_5_suc ($trans_id, $stmt_id);
250    inc $stmt_id;
251  }
252  if ($command == 'T-proc')
253  {
254    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
255    eval CALL pc_i_tt_5_suc ($trans_id, $stmt_id);
256    inc $stmt_id;
257  }
258  if ($command == 'eT')
259  {
260    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
261    let $old_trans_id= `SELECT max(trans_id) from tt_1`;
262    let $old_stmt_id= `SELECT max(stmt_id) from tt_1 where trans_id= $old_trans_id`;
263    --error ER_DUP_ENTRY, ER_DUP_KEY
264    eval INSERT INTO tt_1(trans_id, stmt_id) VALUES ($old_trans_id, $old_stmt_id);
265    inc $stmt_id;
266  }
267  if ($command == 'Te')
268  {
269    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
270    let $old_trans_id= `SELECT max(trans_id) from tt_1`;
271    let $old_stmt_id= `SELECT max(stmt_id) from tt_1 where trans_id= $old_trans_id`;
272    --error ER_DUP_ENTRY, ER_DUP_KEY
273    eval INSERT INTO tt_1(trans_id, stmt_id) VALUES ($trans_id, $stmt_id), ($old_trans_id, $old_stmt_id);
274    inc $stmt_id;
275  }
276  if ($command == 'Te-trig')
277  {
278    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
279    let $old_trans_id= `SELECT max(trans_id) from tt_5`;
280    let $old_stmt_id= `SELECT max(stmt_id) from tt_5 where trans_id= $old_trans_id`;
281    --error ER_DUP_ENTRY, ER_DUP_KEY
282    eval INSERT INTO tt_5(trans_id, stmt_id) VALUES ($trans_id, $stmt_id), ($old_trans_id, $old_stmt_id);
283    inc $stmt_id;
284  }
285  if ($command == 'Te-func')
286  {
287    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
288    let $old_trans_id= `SELECT max(trans_id) from tt_1`;
289    let $old_stmt_id= `SELECT max(stmt_id) from tt_1 where trans_id= $old_trans_id`;
290    --error ER_DUP_ENTRY, ER_DUP_KEY
291    eval INSERT INTO tt_1(trans_id, stmt_id, info) VALUES ($trans_id, $stmt_id, ''), ($old_trans_id, $old_stmt_id, fc_i_tt_5_suc ($trans_id, $stmt_id));
292    inc $stmt_id;
293  }
294  if ($command == 'N')
295  {
296    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
297    eval INSERT INTO nt_1(trans_id, stmt_id) VALUES ($trans_id, $stmt_id);
298    inc $stmt_id;
299  }
300  if ($command == 'N-trig')
301  {
302    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
303    eval INSERT INTO nt_5(trans_id, stmt_id) VALUES ($trans_id, $stmt_id);
304    inc $stmt_id;
305  }
306  if ($command == 'N-func')
307  {
308    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
309    eval SELECT fc_i_nt_5_suc ($trans_id, $stmt_id);
310    inc $stmt_id;
311  }
312  if ($command == 'N-proc')
313  {
314    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
315    eval CALL pc_i_nt_5_suc ($trans_id, $stmt_id);
316    inc $stmt_id;
317  }
318  if ($command == 'eN')
319  {
320    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
321    let $old_trans_id= `SELECT max(trans_id) from nt_1`;
322    let $old_stmt_id= `SELECT max(stmt_id) from nt_1 where trans_id= $old_trans_id`;
323    --error ER_DUP_ENTRY, ER_DUP_KEY
324    eval INSERT INTO nt_1(trans_id, stmt_id) VALUES ($old_trans_id, $old_stmt_id);
325    inc $stmt_id;
326  }
327  if ($command == 'Ne')
328  {
329    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
330    let $old_trans_id= `SELECT max(trans_id) from nt_1`;
331    let $old_stmt_id= `SELECT max(stmt_id) from nt_1 where trans_id= $old_trans_id`;
332    --error ER_DUP_ENTRY, ER_DUP_KEY
333    eval INSERT INTO nt_1(trans_id, stmt_id) VALUES ($trans_id, $stmt_id), ($old_trans_id, $old_stmt_id);
334    inc $stmt_id;
335  }
336  if ($command == 'Ne-trig')
337  {
338    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
339    let $old_trans_id= `SELECT max(trans_id) from nt_5`;
340    let $old_stmt_id= `SELECT max(stmt_id) from nt_5 where trans_id= $old_trans_id`;
341    --error ER_DUP_ENTRY, ER_DUP_KEY
342    eval INSERT INTO nt_5(trans_id, stmt_id) VALUES ($trans_id, $stmt_id), ($old_trans_id, $old_stmt_id);
343    inc $stmt_id;
344  }
345  if ($command == 'Ne-func')
346  {
347    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
348    let $old_trans_id= `SELECT max(trans_id) from nt_1`;
349    let $old_stmt_id= `SELECT max(stmt_id) from nt_1 where trans_id= $old_trans_id`;
350    --error ER_DUP_ENTRY, ER_DUP_KEY
351    eval INSERT INTO nt_1(trans_id, stmt_id, info) VALUES ($trans_id, $stmt_id, ''), ($old_trans_id, $old_stmt_id, fc_i_nt_5_suc ($trans_id, $stmt_id));
352    inc $stmt_id;
353  }
354  if ($command == 'tN')
355  {
356    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
357    eval INSERT INTO nt_1(trans_id, stmt_id, info) SELECT $trans_id, $stmt_id, COUNT(*) FROM tt_1;
358    inc $stmt_id;
359  }
360  if ($command == 'tNe')
361  {
362    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
363    let $old_trans_id= `SELECT max(trans_id) from nt_1`;
364    let $old_stmt_id= `SELECT max(stmt_id) from nt_1 where trans_id= $old_trans_id`;
365    --error ER_DUP_ENTRY, ER_DUP_KEY
366    eval INSERT INTO nt_1(trans_id, stmt_id, info) SELECT $trans_id, $stmt_id, COUNT(*) FROM tt_1 UNION SELECT $old_trans_id, $old_stmt_id, COUNT(*) FROM tt_1;
367    inc $stmt_id;
368  }
369  if ($command == 'nT')
370  {
371    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
372    eval INSERT INTO tt_1(trans_id, stmt_id, info) SELECT $trans_id, $stmt_id, COUNT(*) FROM nt_1;
373    inc $stmt_id;
374  }
375  if ($command == 'nTe')
376  {
377    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
378    let $old_trans_id= `SELECT max(trans_id) from tt_1`;
379    let $old_stmt_id= `SELECT max(stmt_id) from tt_1 where trans_id= $old_trans_id`;
380    --error ER_DUP_ENTRY, ER_DUP_KEY
381    eval INSERT INTO tt_1(trans_id, stmt_id, info) SELECT $trans_id, $stmt_id, COUNT(*) FROM nt_1 UNION SELECT $old_trans_id, $old_stmt_id, COUNT(*) FROM nt_1;
382    inc $stmt_id;
383  }
384  if ($command == 'NT')
385  {
386    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
387    eval UPDATE nt_3, tt_3 SET nt_3.info= "new text $trans_id --> $stmt_id", tt_3.info= "new text $trans_id --> $stmt_id" where nt_3.trans_id = tt_3.trans_id and tt_3.trans_id = 1;
388    inc $stmt_id;
389  }
390  if ($command == 'NT-trig')
391  {
392    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
393    eval INSERT INTO nt_4(trans_id, stmt_id) VALUES ($trans_id, $stmt_id);
394    inc $stmt_id;
395  }
396  if ($command == 'NT-func')
397  {
398    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
399    eval INSERT INTO nt_5(trans_id, stmt_id, info) VALUES ($trans_id, $stmt_id, fc_i_tt_5_suc($trans_id, $stmt_id));
400    inc $stmt_id;
401  }
402  if ($command == 'NeT-trig')
403  {
404    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
405    let $old_trans_id= `SELECT max(trans_id) from nt_4`;
406    let $old_stmt_id= `SELECT max(stmt_id) from nt_4 where trans_id= $old_trans_id`;
407    --error ER_DUP_ENTRY, ER_DUP_KEY
408    eval INSERT INTO nt_4(trans_id, stmt_id) VALUES ($trans_id, $stmt_id), ($old_trans_id, $old_stmt_id);
409    inc $stmt_id;
410  }
411  if ($command == 'NeT-func')
412  {
413    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
414    let $old_trans_id= `SELECT max(trans_id) from nt_5`;
415    let $old_stmt_id= `SELECT max(stmt_id) from nt_5 where trans_id= $old_trans_id`;
416    --error ER_DUP_ENTRY, ER_DUP_KEY
417    eval INSERT INTO nt_5(trans_id, stmt_id, info) VALUES ($trans_id, $stmt_id, ''), ($old_trans_id, $old_stmt_id, fc_i_tt_5_suc ($trans_id, $stmt_id));
418    inc $stmt_id;
419  }
420  if ($command == 'TN')
421  {
422    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
423    eval UPDATE tt_4, nt_4 SET tt_4.info= "new text $trans_id --> $stmt_id", nt_4.info= "new text $trans_id --> $stmt_id" where nt_4.trans_id = tt_4.trans_id and tt_4.trans_id = 1;
424    inc $stmt_id;
425  }
426  if ($command == 'TN-trig')
427  {
428    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
429    eval INSERT INTO tt_3(trans_id, stmt_id) VALUES ($trans_id, $stmt_id);
430    inc $stmt_id;
431  }
432  if ($command == 'TN-func')
433  {
434    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
435    eval INSERT INTO tt_5(trans_id, stmt_id, info) VALUES ($trans_id, $stmt_id, fc_i_nt_5_suc($trans_id, $stmt_id));
436    inc $stmt_id;
437  }
438  if ($command == 'TeN-trig')
439  {
440    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
441    let $old_trans_id= `SELECT max(trans_id) from tt_3`;
442    let $old_stmt_id= `SELECT max(stmt_id) from tt_3 where trans_id= $old_trans_id`;
443    --error ER_DUP_ENTRY, ER_DUP_KEY
444    eval INSERT INTO tt_3(trans_id, stmt_id) VALUES ($trans_id, $stmt_id), ($old_trans_id, $old_stmt_id);
445    inc $stmt_id;
446  }
447  if ($command == 'TeN-func')
448  {
449    #--echo DEBUG-- (trans_id, stmt_id) --> ($trans_id, $stmt_id)
450    let $old_trans_id= `SELECT max(trans_id) from tt_5`;
451    let $old_stmt_id= `SELECT max(stmt_id) from tt_5 where trans_id= $old_trans_id`;
452    --error ER_DUP_ENTRY, ER_DUP_KEY
453    eval INSERT INTO tt_5(trans_id, stmt_id, info) VALUES ($trans_id, $stmt_id, ''), ($old_trans_id, $old_stmt_id, fc_i_nt_5_suc ($trans_id, $stmt_id));
454    inc $stmt_id;
455  }
456  if ($command == 'set-T')
457  {
458    --eval SET @var= fc_i_tt_5_suc($trans_id, $stmt_id)
459    inc $stmt_id;
460  }
461  if ($command == 'set-N')
462  {
463    --eval SET @var= fc_i_nt_5_suc($trans_id, $stmt_id)
464    inc $stmt_id;
465  }
466  if ($command == 'set-NT')
467  {
468    --eval SET @var= fc_i_nt_3_tt_3_suc($trans_id, $stmt_id)
469    inc $stmt_id;
470  }
471  if ($command == 'CS-T->T')
472  {
473    --eval CREATE TABLE tt_xx_$tb_id (PRIMARY KEY(trans_id, stmt_id)) engine=$engine_type SELECT * FROM tt_1;
474  }
475  if ($command == 'CS-N->N')
476  {
477    --eval CREATE TABLE nt_xx_$tb_id (PRIMARY KEY(trans_id, stmt_id)) engine=MyIsam SELECT * FROM nt_1;
478  }
479  if ($command == 'CS-T->N')
480  {
481    --eval CREATE TABLE tt_xx_$tb_id (PRIMARY KEY(trans_id, stmt_id)) engine=$engine_type SELECT * FROM nt_1;
482  }
483  if ($command == 'CS-N->T')
484  {
485    --eval CREATE TABLE nt_xx_$tb_id (PRIMARY KEY(trans_id, stmt_id)) engine=MyIsam SELECT * FROM tt_1;
486  }
487  if ($command == 'CSe-T->T')
488  {
489    --error ER_DUP_ENTRY, ER_DUP_KEY
490    --eval CREATE TABLE tt_xx_$tb_id (PRIMARY KEY (stmt_id)) engine=$engine_type SELECT stmt_id FROM tt_1;
491  }
492  if ($command == 'CSe-N->N')
493  {
494    --error ER_DUP_ENTRY, ER_DUP_KEY
495    --eval CREATE TABLE nt_xx_$tb_id (PRIMARY KEY (stmt_id)) engine=MyIsam SELECT stmt_id FROM nt_1;
496  }
497  if ($command == 'CSe-T->N')
498  {
499    --error ER_DUP_ENTRY, ER_DUP_KEY
500    --eval CREATE TABLE tt_xx_$tb_id (PRIMARY KEY (stmt_id)) engine=$engine_type SELECT stmt_id FROM nt_1;
501  }
502  if ($command == 'CSe-N->T')
503  {
504    --error ER_DUP_ENTRY, ER_DUP_KEY
505    --eval CREATE TABLE nt_xx_$tb_id (PRIMARY KEY (stmt_id)) engine=MyIsam SELECT stmt_id FROM tt_1;
506  }
507  if ($command == 'CT')
508  {
509    --eval CREATE TEMPORARY TABLE tt_xx_$tb_id (a int) engine=$engine_type;
510  }
511  if ($command == 'IS-T<-N')
512  {
513    --eval INSERT INTO tt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, stmt_id, USER() FROM nt_1;
514  }
515  if ($command == 'ISe-T<-N')
516  {
517    --error ER_DUP_ENTRY, ER_DUP_KEY
518    --eval INSERT INTO tt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, trans_id, USER() FROM nt_1;
519  }
520  if ($command == 'IS-N<-T')
521  {
522    --eval INSERT INTO nt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, stmt_id, USER() FROM tt_1;
523  }
524  if ($command == 'ISe-N<-T')
525  {
526    --error ER_DUP_ENTRY, ER_DUP_KEY
527    --eval INSERT INTO nt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, trans_id, USER() FROM tt_1;
528  }
529  if ($command == 'IS-T<-T')
530  {
531    --eval INSERT INTO tt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, stmt_id, USER() FROM tt_1;
532  }
533  if ($command == 'ISe-T<-T')
534  {
535    --error ER_DUP_ENTRY, ER_DUP_KEY
536    --eval INSERT INTO tt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, trans_id, USER() FROM tt_1;
537  }
538  if ($command == 'IS-N<-N')
539  {
540    --eval INSERT INTO nt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, stmt_id, USER() FROM nt_1;
541  }
542  if ($command == 'ISe-N<-N')
543  {
544    --error ER_DUP_ENTRY, ER_DUP_KEY
545    --eval INSERT INTO nt_xx_$tb_id(trans_id, stmt_id, info) SELECT trans_id, trans_id, USER() FROM nt_1;
546  }
547  if ($command == 'trunc-CS-T')
548  {
549    eval TRUNCATE TABLE tt_xx_$tb_id;
550  }
551  if ($command == 'trunc-CS-N')
552  {
553    eval TRUNCATE TABLE nt_xx_$tb_id;
554  }
555  if ($command == 'trunc-CT')
556  {
557    eval TRUNCATE TABLE tt_xx_$tb_id;
558  }
559  if ($command == 'drop-CS')
560  {
561    --disable_warnings
562    eval DROP TABLE IF EXISTS tt_xx_$tb_id, nt_xx_$tb_id;
563    inc $tb_id;
564    --enable_warnings
565  }
566  if ($command == 'drop-CT')
567  {
568    --disable_warnings
569    eval DROP TEMPORARY TABLE IF EXISTS tt_xx_$tb_id;
570    inc $tb_id;
571    --enable_warnings
572  }
573  if ($command == 'C')
574  {
575    --error 0, ER_GET_ERRMSG
576    eval COMMIT;
577  }
578  if ($command == 'R')
579  {
580    --replace_column 2 #
581    --error 0, ER_GET_ERRMSG
582    eval ROLLBACK;
583  }
584  if ($command == 'Sn')
585  {
586    eval SAVEPOINT S_$sn;
587    --inc $sn
588  }
589  if ($command == 'Rn')
590  {
591    if ($sn)
592    {
593      --dec $sn
594    }
595    --replace_column 2 #
596    eval ROLLBACK TO S_$sn;
597  }
598  if ($command == 'Cn')
599  {
600    if ($sn)
601    {
602      --dec $sn
603    }
604    eval RELEASE SAVEPOINT S_$sn;
605  }
606  --disable_query_log
607  --let $commands= `SELECT LTRIM(SUBSTRING('$commands', LENGTH('$command') + 1))`
608  inc $stmt_id;
609
610  let $binlog_start= $pos_command;
611  if ($verbose)
612  {
613    # Use other connection because include/show_binlog_events.inc
614    # executes SELECT UUID(), which switches to row-logging when
615    # binlog_format=mixed, if there are open temporary tables. This is
616    # due to BUG#13692513.
617    --connection server_1
618    --source include/show_binlog_events.inc
619    --connection master
620    --echo -e-e-e-e-e-e-e-e-e-e-e- >> $command << -e-e-e-e-e-e-e-e-e-e-e-
621  }
622  if ($commands == '')
623  {
624    let $binlog_start= $pos_trans_command;
625    --echo -b-b-b-b-b-b-b-b-b-b-b- >> $rme_initial_commands << -b-b-b-b-b-b-b-b-b-b-b-
626    --connection server_1
627    --source include/show_binlog_events.inc
628    --connection master
629    --echo -e-e-e-e-e-e-e-e-e-e-e- >> $rme_initial_commands << -e-e-e-e-e-e-e-e-e-e-e-
630    --echo
631    let $pos_trans_command= query_get_value("SHOW MASTER STATUS", Position, 1);
632    let $stmt_id= 1;
633    inc $trans_id;
634  }
635}
636
637--let $commands= $rme_initial_commands
638