|
| 1 | +############################################################################### |
| 2 | +# Bug#76727: SLAVE ASSERTION IN UNPACK_ROW WITH ROLLBACK TO |
| 3 | +# SAVEPOINT IN ERROR HANDLER |
| 4 | +# |
| 5 | +# Problem: |
| 6 | +# ======== |
| 7 | +# "SAVEPOINT", "ROLLBACK TO savepoint" wipe out table map on slave during |
| 8 | +# execution binary log events. For trigger the map is written to binary log once |
| 9 | +# for all trigger body and if trigger contains "SAVEPOINT" or |
| 10 | +# "ROLLBACK TO savepoint" statements any trigger's events after these |
| 11 | +# statements will not have table map. This results in an assert on slave. |
| 12 | +# |
| 13 | +# Test: |
| 14 | +# ===== |
| 15 | +# Test case 1: |
| 16 | +# Create a trigger with exception handler which rollsback to a savepoint. |
| 17 | +# Test proves that there will not be any assert during execution of rolling |
| 18 | +# back to savepoint. |
| 19 | +# |
| 20 | +# Test case 2: |
| 21 | +# Create a trigger which calls a procedure which in turn calls an exception |
| 22 | +# handler which rollsback to a savepoint. Prove that it doesn't cause any |
| 23 | +# assertion during execution. |
| 24 | +# |
| 25 | +# Test case 3: |
| 26 | +# Create a simple trigger which creates a SAVEPOINT and ROLLSBACK to savepoint |
| 27 | +# and doesn't follow with any other DML statement. Prove that it doesn't cause |
| 28 | +# any assertion during execution. |
| 29 | +# |
| 30 | +# Test case 4: |
| 31 | +# Create a trigger with SAVEPOINT and follows with a DML without ROLLBACK TO |
| 32 | +# savepoint. Ensure that data is replicated properly. |
| 33 | +# |
| 34 | +# Test case 5: |
| 35 | +# Create a trigger with SAVEPOINT and it does nothing. Do few DMLS following |
| 36 | +# the trigger ensure that the data is replicated properly |
| 37 | +# |
| 38 | +# Test case 6: |
| 39 | +# Create a stored function which creates a SAVEPOINT and ROLLSBACK to |
| 40 | +# savepoint. Do few inserts following the stored function call and ensure that |
| 41 | +# no assert is generated on slave and all the rows are replicated to slave. |
| 42 | +# |
| 43 | +# Test case 7: |
| 44 | +# Create a stored function which creates a SAVEPOINT alone and follows with |
| 45 | +# DMLS without ROLLBACK TO savepoint. Ensure that data is replicated properly. |
| 46 | +# |
| 47 | +# Test case 8: |
| 48 | +# Create a stored function which has SAVEPOINT inside it and does noting. It |
| 49 | +# should follow with other DMLs. Ensure that data is replicated properly. |
| 50 | +############################################################################### |
| 51 | +--source include/have_innodb.inc |
| 52 | +--source include/master-slave.inc |
| 53 | + |
| 54 | +--echo #Test case 1: |
| 55 | +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); |
| 56 | +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY); |
| 57 | +CREATE TABLE t3 (f1 INTEGER PRIMARY KEY); |
| 58 | +DELIMITER |; |
| 59 | + |
| 60 | +CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW |
| 61 | +BEGIN |
| 62 | + DECLARE EXIT HANDLER FOR SQLEXCEPTION |
| 63 | + BEGIN |
| 64 | + ROLLBACK TO event_logging_1; |
| 65 | + INSERT t3 VALUES (1); |
| 66 | + END; |
| 67 | + |
| 68 | + SAVEPOINT event_logging_1; |
| 69 | + |
| 70 | + INSERT INTO t2 VALUES (1); |
| 71 | + |
| 72 | + RELEASE SAVEPOINT event_logging_1; |
| 73 | + |
| 74 | +END| |
| 75 | +DELIMITER ;| |
| 76 | + |
| 77 | +INSERT INTO t2 VALUES (1); |
| 78 | +INSERT INTO t1 VALUES (1); |
| 79 | + |
| 80 | +--source include/show_binlog_events.inc |
| 81 | + |
| 82 | +--sync_slave_with_master |
| 83 | + |
| 84 | +--source include/rpl_connection_master.inc |
| 85 | + |
| 86 | +DROP TRIGGER tr1; |
| 87 | +DELETE FROM t1; |
| 88 | +DELETE FROM t2; |
| 89 | +DELETE FROM t3; |
| 90 | + |
| 91 | +--echo # Test case 2: |
| 92 | + |
| 93 | +DELIMITER |; |
| 94 | + |
| 95 | +CREATE PROCEDURE p1() |
| 96 | +BEGIN |
| 97 | + DECLARE EXIT HANDLER FOR SQLEXCEPTION |
| 98 | + BEGIN |
| 99 | + ROLLBACK TO event_logging_2; |
| 100 | + INSERT t3 VALUES (3); |
| 101 | + END; |
| 102 | + |
| 103 | + SAVEPOINT event_logging_2; |
| 104 | + |
| 105 | + INSERT INTO t2 VALUES (1); |
| 106 | + |
| 107 | + RELEASE SAVEPOINT event_logging_2; |
| 108 | +END| |
| 109 | + |
| 110 | +CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW CALL p1()| |
| 111 | + |
| 112 | +DELIMITER ;| |
| 113 | + |
| 114 | +INSERT INTO t2 VALUES (1); |
| 115 | +INSERT INTO t1 VALUES (1); |
| 116 | + |
| 117 | +--source include/show_binlog_events.inc |
| 118 | + |
| 119 | +--sync_slave_with_master |
| 120 | + |
| 121 | +--source include/rpl_connection_master.inc |
| 122 | + |
| 123 | +DROP TABLE t1; |
| 124 | +DROP TABLE t2; |
| 125 | +DROP TABLE t3; |
| 126 | + |
| 127 | +DROP PROCEDURE p1; |
| 128 | + |
| 129 | +--echo # Test case 3: |
| 130 | +--source include/rpl_reset.inc |
| 131 | +--source include/rpl_connection_master.inc |
| 132 | + |
| 133 | +CREATE TABLE t (f1 int(10) unsigned NOT NULL, PRIMARY KEY (f1)) ENGINE=InnoDB; |
| 134 | + |
| 135 | +--delimiter | |
| 136 | +CREATE TRIGGER t_insert_trig AFTER INSERT ON t |
| 137 | +FOR EACH ROW |
| 138 | +BEGIN |
| 139 | + |
| 140 | +SAVEPOINT savepoint_1; |
| 141 | +ROLLBACK TO savepoint_1; |
| 142 | + |
| 143 | +END | |
| 144 | +--delimiter ; |
| 145 | + |
| 146 | +INSERT INTO t VALUES (2); |
| 147 | +INSERT INTO t VALUES (3); |
| 148 | + |
| 149 | +--source include/show_binlog_events.inc |
| 150 | + |
| 151 | +SELECT * FROM t; |
| 152 | + |
| 153 | +--source include/sync_slave_sql_with_master.inc |
| 154 | + |
| 155 | +SELECT * FROM t; |
| 156 | + |
| 157 | +--source include/rpl_connection_master.inc |
| 158 | +DROP TABLE t; |
| 159 | + |
| 160 | +--echo # Test case 4: |
| 161 | +--source include/rpl_reset.inc |
| 162 | +--source include/rpl_connection_master.inc |
| 163 | +CREATE TABLE t (f1 int(10) unsigned NOT NULL) ENGINE=InnoDB; |
| 164 | +CREATE TABLE t1 (f1 int(10) unsigned NOT NULL) ENGINE=InnoDB; |
| 165 | + |
| 166 | +--delimiter | |
| 167 | +CREATE TRIGGER t_insert_trig BEFORE INSERT ON t |
| 168 | +FOR EACH ROW |
| 169 | +BEGIN |
| 170 | + |
| 171 | +SAVEPOINT savepoint_1; |
| 172 | +INSERT INTO t1 VALUES (5); |
| 173 | +END | |
| 174 | +--delimiter ; |
| 175 | + |
| 176 | +INSERT INTO t VALUES (2), (3); |
| 177 | +INSERT INTO t1 VALUES (30); |
| 178 | +--source include/show_binlog_events.inc |
| 179 | + |
| 180 | +SELECT * FROM t; |
| 181 | +SELECT * FROM t1; |
| 182 | +--source include/sync_slave_sql_with_master.inc |
| 183 | + |
| 184 | +SELECT * FROM t; |
| 185 | +SELECT * FROM t1; |
| 186 | + |
| 187 | +--source include/rpl_connection_master.inc |
| 188 | +DROP TABLE t; |
| 189 | +DROP TABLE t1; |
| 190 | + |
| 191 | +--echo # Test case 5: |
| 192 | +--source include/rpl_reset.inc |
| 193 | +--source include/rpl_connection_master.inc |
| 194 | +CREATE TABLE t (f1 int(10) unsigned NOT NULL) ENGINE=InnoDB; |
| 195 | +CREATE TABLE t1 (f1 int(10) unsigned NOT NULL) ENGINE=InnoDB; |
| 196 | + |
| 197 | +--delimiter | |
| 198 | +CREATE TRIGGER t_insert_trig BEFORE INSERT ON t |
| 199 | +FOR EACH ROW |
| 200 | +BEGIN |
| 201 | + |
| 202 | +SAVEPOINT savepoint_1; |
| 203 | +END | |
| 204 | + |
| 205 | +--delimiter ; |
| 206 | + |
| 207 | +INSERT INTO t VALUES (2), (3); |
| 208 | +INSERT INTO t1 VALUES (30); |
| 209 | +--source include/show_binlog_events.inc |
| 210 | + |
| 211 | +SELECT * FROM t; |
| 212 | +SELECT * FROM t1; |
| 213 | +--source include/sync_slave_sql_with_master.inc |
| 214 | + |
| 215 | +SELECT * FROM t; |
| 216 | +SELECT * FROM t1; |
| 217 | + |
| 218 | +--source include/rpl_connection_master.inc |
| 219 | +DROP TABLE t; |
| 220 | +DROP TABLE t1; |
| 221 | + |
| 222 | +--echo # Test case 6: |
| 223 | +--source include/rpl_reset.inc |
| 224 | +--source include/rpl_connection_master.inc |
| 225 | +CREATE TABLE t1 (f1 INTEGER ) ENGINE=INNODB; |
| 226 | +CREATE TABLE t2 (f1 INTEGER ) ENGINE=INNODB; |
| 227 | + |
| 228 | +--delimiter | |
| 229 | + |
| 230 | +CREATE FUNCTION f1() RETURNS INT |
| 231 | +BEGIN |
| 232 | + SAVEPOINT event_logging_2; |
| 233 | + |
| 234 | + INSERT INTO t1 VALUES (1); |
| 235 | + |
| 236 | + ROLLBACK TO event_logging_2; |
| 237 | + RETURN 0; |
| 238 | +END| |
| 239 | + |
| 240 | +--delimiter ; |
| 241 | + |
| 242 | +BEGIN; |
| 243 | +INSERT INTO t2 VALUES (1), (f1()), (2), (4); |
| 244 | +COMMIT; |
| 245 | +INSERT INTO t2 VALUES (10); |
| 246 | +--source include/show_binlog_events.inc |
| 247 | + |
| 248 | +--source include/rpl_connection_master.inc |
| 249 | +SELECT * FROM t2; |
| 250 | +SELECT * FROM t1; |
| 251 | +--source include/sync_slave_sql_with_master.inc |
| 252 | +SELECT * FROM t2; |
| 253 | +SELECT * FROM t1; |
| 254 | + |
| 255 | +--source include/rpl_connection_master.inc |
| 256 | +DROP TABLE t1; |
| 257 | +DROP TABLE t2; |
| 258 | +DROP FUNCTION f1; |
| 259 | + |
| 260 | +--echo # Test case 7: |
| 261 | +--source include/rpl_reset.inc |
| 262 | +--source include/rpl_connection_master.inc |
| 263 | +CREATE TABLE t1 (f1 INTEGER ) ENGINE=INNODB; |
| 264 | +CREATE TABLE t2 (f1 INTEGER ) ENGINE=INNODB; |
| 265 | + |
| 266 | +--delimiter | |
| 267 | + |
| 268 | +CREATE FUNCTION f1() RETURNS INT |
| 269 | +BEGIN |
| 270 | + SAVEPOINT event_logging_2; |
| 271 | + |
| 272 | + INSERT INTO t1 VALUES (1); |
| 273 | + |
| 274 | + RETURN 0; |
| 275 | +END| |
| 276 | + |
| 277 | +--delimiter ; |
| 278 | + |
| 279 | +BEGIN; |
| 280 | +INSERT INTO t2 VALUES (1), (f1()), (2), (4); |
| 281 | +COMMIT; |
| 282 | +INSERT INTO t2 VALUES (10); |
| 283 | +--source include/show_binlog_events.inc |
| 284 | + |
| 285 | +--source include/rpl_connection_master.inc |
| 286 | +SELECT * FROM t2; |
| 287 | +SELECT * FROM t1; |
| 288 | +--source include/sync_slave_sql_with_master.inc |
| 289 | +SELECT * FROM t2; |
| 290 | +SELECT * FROM t1; |
| 291 | + |
| 292 | +--source include/rpl_connection_master.inc |
| 293 | +DROP TABLE t1; |
| 294 | +DROP TABLE t2; |
| 295 | +DROP FUNCTION f1; |
| 296 | + |
| 297 | +--echo # Test case 8: |
| 298 | +--source include/rpl_reset.inc |
| 299 | +--source include/rpl_connection_master.inc |
| 300 | +CREATE TABLE t1 (f1 INTEGER ) ENGINE=INNODB; |
| 301 | + |
| 302 | +--delimiter | |
| 303 | + |
| 304 | +CREATE FUNCTION f1() RETURNS INT |
| 305 | +BEGIN |
| 306 | + SAVEPOINT event_logging_2; |
| 307 | + RETURN 0; |
| 308 | +END| |
| 309 | + |
| 310 | +--delimiter ; |
| 311 | + |
| 312 | +BEGIN; |
| 313 | +INSERT INTO t1 VALUES (1), (f1()), (2), (4); |
| 314 | +COMMIT; |
| 315 | +INSERT INTO t1 VALUES (10); |
| 316 | +--source include/show_binlog_events.inc |
| 317 | + |
| 318 | +--source include/rpl_connection_master.inc |
| 319 | +SELECT * FROM t1; |
| 320 | +--source include/sync_slave_sql_with_master.inc |
| 321 | +SELECT * FROM t1; |
| 322 | + |
| 323 | +--source include/rpl_connection_master.inc |
| 324 | +DROP TABLE t1; |
| 325 | +DROP FUNCTION f1; |
| 326 | + |
| 327 | +--source include/rpl_end.inc |
0 commit comments