| 1 |
# |
| 2 |
# Helper script to create an XA transaction and validate it was not |
| 3 |
# binlogged |
| 4 |
# |
| 5 |
# Parameters |
| 6 |
# $xa_completion_action : The action to end the XA transaction, either |
| 7 |
# COMMIT or ROLLBACK |
| 8 |
# $trx_statements : A comma separated list specifying how to build |
| 9 |
# the statements of the transaction. Each item in |
| 10 |
# the list is either T (for transactional) or N |
| 11 |
# (for non-transactional). An empty list will not |
| 12 |
# add any statements to the transaction. |
| 13 |
# $use_disconnect : When TRUE, disconnect after preparing the XA |
| 14 |
# transaction to test the detach/rollback case |
| 15 |
# |
| 16 |
|
| 17 |
# |
| 18 |
# Setup |
| 19 |
--let $generic_assert_text= should not binlog XA transaction |
| 20 |
|
| 21 |
--connection server_1 |
| 22 |
--let server_1_datadir=`select @@datadir` |
| 23 |
|
| 24 |
--connection server_2 |
| 25 |
--let server_2_datadir=`select @@datadir` |
| 26 |
|
| 27 |
--connection server_3 |
| 28 |
--let server_3_datadir=`select @@datadir` |
| 29 |
|
| 30 |
--let assert_file=$MYSQLTEST_VARDIR/tmp/binlog_decoded.out |
| 31 |
|
| 32 |
--connection server_1 |
| 33 |
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam; |
| 34 |
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb; |
| 35 |
--source include/save_master_gtid.inc |
| 36 |
|
| 37 |
--connection server_3 |
| 38 |
--source include/sync_with_master_gtid.inc |
| 39 |
|
| 40 |
--connection server_1 |
| 41 |
|
| 42 |
if ($use_disconnect) |
| 43 |
{ |
| 44 |
--source include/count_sessions.inc |
| 45 |
--connect(con1,localhost,root,,) |
| 46 |
} |
| 47 |
|
| 48 |
XA START 'x'; |
| 49 |
--let $_stmt_items= $trx_statements |
| 50 |
--let $_ctr= 1 |
| 51 |
while($_stmt_items) |
| 52 |
{ |
| 53 |
--let $_cur_stmt= `SELECT SUBSTRING_INDEX('$_stmt_items', ',', 1)` |
| 54 |
--let $_stmt_items= `SELECT LTRIM(SUBSTRING('$_stmt_items', LENGTH('$_cur_stmt') + 2))` |
| 55 |
|
| 56 |
if (`SELECT strcmp("$_cur_stmt","T") = 0`) |
| 57 |
{ |
| 58 |
--let $target_table= ti |
| 59 |
} |
| 60 |
|
| 61 |
if (`SELECT strcmp("$_cur_stmt","N") = 0`) |
| 62 |
{ |
| 63 |
--let $target_table= tm |
| 64 |
} |
| 65 |
|
| 66 |
--error ER_DUP_ENTRY |
| 67 |
--eval INSERT INTO $target_table VALUES ($_ctr),($_ctr); |
| 68 |
inc $_ctr; |
| 69 |
|
| 70 |
} |
| 71 |
XA END 'x'; |
| 72 |
XA PREPARE 'x'; |
| 73 |
|
| 74 |
if ($use_disconnect) |
| 75 |
{ |
| 76 |
--disconnect con1 |
| 77 |
--connection server_1 |
| 78 |
--source include/wait_until_count_sessions.inc |
| 79 |
XA RECOVER; |
| 80 |
|
| 81 |
--error ER_XA_RBROLLBACK |
| 82 |
--eval XA $xa_completion_action 'x'; |
| 83 |
} |
| 84 |
if (!$use_disconnect) |
| 85 |
{ |
| 86 |
--eval XA $xa_completion_action 'x'; |
| 87 |
} |
| 88 |
|
| 89 |
--source include/save_master_gtid.inc |
| 90 |
|
| 91 |
--let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) |
| 92 |
FLUSH LOGS; |
| 93 |
|
| 94 |
--echo # MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file |
| 95 |
--exec $MYSQL_BINLOG $server_1_datadir/$binlog_filename --result-file=$assert_file |
| 96 |
|
| 97 |
--let assert_text= server_1 $generic_assert_text |
| 98 |
--let assert_count= 0 |
| 99 |
--let assert_select= XA START|XA END|XA PREPARE|XA COMMIT|XA ROLLBACK |
| 100 |
--source include/assert_grep.inc |
| 101 |
|
| 102 |
--connection server_2 |
| 103 |
--source include/sync_with_master_gtid.inc |
| 104 |
--let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) |
| 105 |
FLUSH LOGS; |
| 106 |
|
| 107 |
--echo # MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file |
| 108 |
--exec $MYSQL_BINLOG $server_2_datadir/$binlog_filename --result-file=$assert_file |
| 109 |
|
| 110 |
--let assert_text= server_2 $generic_assert_text |
| 111 |
--source include/assert_grep.inc |
| 112 |
|
| 113 |
--connection server_3 |
| 114 |
--source include/sync_with_master_gtid.inc |
| 115 |
--let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) |
| 116 |
FLUSH LOGS; |
| 117 |
|
| 118 |
--echo # MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file |
| 119 |
--exec $MYSQL_BINLOG $server_3_datadir/$binlog_filename --result-file=$assert_file |
| 120 |
|
| 121 |
--let assert_text= server_3 $generic_assert_text |
| 122 |
--source include/assert_grep.inc |
| 123 |
|
| 124 |
# |
| 125 |
# Cleanup |
| 126 |
--connection server_1 |
| 127 |
DROP TABLE ti,tm; |
| 128 |
--source include/save_master_gtid.inc |
| 129 |
|
| 130 |
--connection server_3 |
| 131 |
--source include/sync_with_master_gtid.inc |