Debian Codegraph @

mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test

raw
1 # The test verifies execution and binary logging of user XA that produce empty
2 # XA-PREPARE group of events.
3
4 --source include/have_binlog_format_mixed.inc
5 --source include/have_innodb.inc
6
7 RESET MASTER; # clear binlogs
8 # MDEV-22420 DDL on temporary object is prohibited when XA is in prepare state
9
10 # Temporary sequnce may not be created within a transaction
11 CREATE TEMPORARY SEQUENCE seq_1;
12
13 XA START '3';
14 CREATE TEMPORARY TABLE tmp_1(c INT);
15 XA END '3';
16 XA PREPARE '3';
17 --error ER_XAER_RMFAIL
18 DROP TEMPORARY TABLE tmp_1;
19 --error ER_XAER_RMFAIL
20 ALTER TABLE tmp_1 DROP COLUMN c;
21 --error ER_XAER_RMFAIL
22 DROP TEMPORARY SEQUENCE seq_1;
23 --error ER_XAER_RMFAIL
24 ALTER SEQUENCE seq_1 INCREMENT BY 1;
25
26 --error ER_XAER_RMFAIL
27 CREATE TEMPORARY TABLE tmp_2(c INT);
28 --error ER_XAER_RMFAIL
29 CREATE TEMPORARY SEQUENCE seq_2;
30
31 # Cleanup
32 XA ROLLBACK '3';
33
34 --echo # Proof of correct logging incl empty XA-PREPARE
35 --source include/show_binlog_events.inc
36
37 # The test verifies execution and binary logging of user XA that produce empty
38 # XA-PREPARE group of events.
39 #
40 # MDEV-22757 Assertion `!binlog || exist_hton_without_prepare'
41 # in MYSQL_BIN_LOG::unlog_xa_prepare
42
43 RESET MASTER;
44 CREATE TABLE t1 (a INT) ENGINE=MyISAM;
45 CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB;
46 INSERT INTO t1 VALUES (1),(2);
47 INSERT INTO t2 VALUES (1),(2);
48
49 XA START '1';
50 REPLACE INTO t1 SELECT * FROM t1;
51 REPLACE INTO t2 SELECT * FROM t2;
52 XA END '1';
53 XA PREPARE '1';
54
55 # Cleanup
56 XA ROLLBACK '1';
57 DROP TABLE t1, t2;
58
59 --echo # Proof of correct logging incl empty XA-PREPARE
60 --source include/show_binlog_events.inc
61
62
63 # MDEV-22430 Assertion ... in MYSQL_BIN_LOG::unlog_xa_prepare
64
65 RESET MASTER;
66 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
67 INSERT INTO t1 VALUES (1);
68 CREATE SEQUENCE s ENGINE=InnoDB;
69
70 XA START '2';
71 --disable_ps2_protocol
72 SELECT NEXT VALUE FOR s;
73 --enable_ps2_protocol
74 REPLACE INTO t1 SELECT * FROM t1;
75 XA END '2';
76 XA PREPARE '2';
77
78 # Cleanup
79 XA ROLLBACK '2';
80 DROP SEQUENCE s;
81 DROP TABLE t1;
82
83 --echo # Proof of correct logging incl empty XA-PREPARE
84 --source include/show_binlog_events.inc
85
86
87 # MDEV-25616 Binlog event for XA COMMIT is generated without matching XA START
88
89 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
90 INSERT INTO t1 VALUES (1);
91
92 --source include/count_sessions.inc
93 --connect(con1,localhost,root,,)
94
95 XA START '1';
96 --error ER_DUP_ENTRY
97 INSERT INTO t1 VALUES (2),(1);
98 SELECT * FROM t1 WHERE a = 2;
99 XA END '1';
100 XA PREPARE '1';
101
102 --disconnect con1
103
104 --connection default
105 --source include/wait_until_count_sessions.inc
106 XA RECOVER;
107
108 --error ER_XA_RBROLLBACK
109 XA COMMIT '1';
110 --echo Must be no XA PREPARE group nor XA completion one:
111 --source include/show_binlog_events.inc
112 DROP TABLE t1;
113
114 --source include/count_sessions.inc
115
116 --connect(con2,localhost,root,,)
117 CREATE TABLE tm (a INT PRIMARY KEY) ENGINE=MyISAM;
118 XA START '1';
119 --error ER_DUP_ENTRY
120 INSERT INTO tm VALUES (1),(1);
121 SELECT * FROM tm WHERE a = 2;
122 XA END '1';
123 XA PREPARE '1';
124
125 --disconnect con2
126
127 --connection default
128 --source include/wait_until_count_sessions.inc
129 XA RECOVER;
130
131 --error ER_XA_RBROLLBACK
132 XA ROLLBACK '1';
133 --echo Must be no XA PREPARE group nor XA completion one:
134 --source include/show_binlog_events.inc
135 DROP TABLE tm;
136
137
138 # MDEV-32257 dangling XA-rollback in binlog from emtpy XA
139 --connection default
140 --let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
141 --let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1)
142 SET pseudo_slave_mode=1;
143 XA START 'a';
144 XA END 'a';
145 XA PREPARE 'a';
146 --error ER_XA_RBROLLBACK
147 XA ROLLBACK 'a';
148 --source include/show_binlog_events.inc