Commit 6c2b3251 authored by Alfranio Correia's avatar Alfranio Correia

BUG#28976 Mixing trans and non-trans tables in one transaction results in incorrect

binlog

Mixing transactional (T) and non-transactional (N) tables on behalf of a
transaction may lead to inconsistencies among masters and slaves in STATEMENT
mode. The problem stems from the fact that although modifications done to
non-transactional tables on behalf of a transaction become immediately visible
to other connections they do not immediately get to the binary log and therefore
consistency is broken. Although there may be issues in mixing T and M tables in
STATEMENT mode, there are safe combinations that clients find useful.

In this bug, we fix the following issue. Mixing N and T tables in multi-level
(e.g. a statement that fires a trigger) or multi-table table statements (e.g.
update t1, t2...) were not handled correctly. In such cases, it was not possible
to distinguish when a T table was updated if the sequence of changes was N and T.
In a nutshell, just the flag "modified_non_trans_table" was not enough to reflect
that both a N and T tables were changed. To circumvent this issue, we check if an
engine is registered in the handler's list and changed something which means that
a T table was modified.

Check WL 2687 for a full-fledged patch that will make the use of either the MIXED or
ROW modes completely safe.

mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
parent fc394595
###################################################################################
# This test checks if transactions that mixes transactional and non-transactional
# tables are correctly handled in statement mode. In an nutshell, we have what
# follows:
#
# 1) "B T T C" generates in binlog the "B T T C" entries.
#
# 2) "B T T R" generates in binlog an "empty" entry.
#
# 3) "B T N C" generates in binlog the "B T N C" entries.
#
# 4) "B T N R" generates in binlog the "B T N R" entries.
#
# 5) "T" generates in binlog the "B T C" entry.
#
# 6) "N" generates in binlog the "N" entry.
#
# 7) "M" generates in binglog the "B M C" entries.
#
# 8) "B N N T C" generates in binglog the "N N B T C" entries.
#
# 9) "B N N T R" generates in binlog the "N N B T R" entries.
#
# 10) "B N N C" generates in binglog the "N N" entries.
#
# 11) "B N N R" generates in binlog the "N N" entries.
#
# 12) "B M T C" generates in the binlog the "B M T C" entries.
#
# 13) "B M T R" generates in the binlog the "B M T R" entries.
###################################################################################
--echo ###################################################################################
--echo # CONFIGURATION
--echo ###################################################################################
connection master;
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
connection slave;
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
connection master;
DELIMITER |;
CREATE FUNCTION f1 () RETURNS VARCHAR(64)
BEGIN
RETURN "Testing...";
END|
CREATE FUNCTION f2 () RETURNS VARCHAR(64)
BEGIN
RETURN f1();
END|
CREATE PROCEDURE pc_i_tt_3 (IN x INT, IN y VARCHAR(64))
BEGIN
INSERT INTO tt_3 VALUES (y,x,x);
END|
CREATE TRIGGER tr_i_tt_3_to_nt_3 BEFORE INSERT ON tt_3 FOR EACH ROW
BEGIN
INSERT INTO nt_3 VALUES (NEW.a, NEW.b, NEW.c);
END|
CREATE TRIGGER tr_i_nt_4_to_tt_4 BEFORE INSERT ON nt_4 FOR EACH ROW
BEGIN
INSERT INTO tt_4 VALUES (NEW.a, NEW.b, NEW.c);
END|
DELIMITER ;|
--echo ###################################################################################
--echo # MIXING TRANSACTIONAL and NON-TRANSACTIONAL TABLES
--echo ###################################################################################
connection master;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #1) "B T T C" generates in binlog the "B T T C" entries.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 4", 4, "new text 4");
INSERT INTO tt_2 VALUES ("new text 4", 4, "new text 4");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #1.e) "B T T C" with error in T generates in binlog the "B T T C" entries.
--echo #
INSERT INTO tt_1 VALUES ("new text -2", -2, "new text -2");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -2", -2, "new text -2");
INSERT INTO tt_2 VALUES ("new text -3", -3, "new text -3");
COMMIT;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -5", -5, "new text -5");
--error ER_DUP_ENTRY
INSERT INTO tt_2 VALUES ("new text -4", -4, "new text -4"), ("new text -5", -5, "new text -5");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #2) "B T T R" generates in binlog an "empty" entry.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 5", 5, "new text 5");
INSERT INTO tt_2 VALUES ("new text 5", 5, "new text 5");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #2.e) "B T T R" with error in T generates in binlog an "empty" entry.
--echo #
INSERT INTO tt_1 VALUES ("new text -7", -7, "new text -7");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -6", -6, "new text -6"), ("new text -7", -7, "new text -7");
INSERT INTO tt_2 VALUES ("new text -8", -8, "new text -8");
ROLLBACK;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -10", -10, "new text -10");
--error ER_DUP_ENTRY
INSERT INTO tt_2 VALUES ("new text -9", -9, "new text -9"), ("new text -10", -10, "new text -10");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #3) "B T N C" generates in binlog the "B T N C" entries.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 6", 6, "new text 6");
INSERT INTO nt_1 VALUES ("new text 6", 6, "new text 6");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #3.e) "B T N C" with error in either T or N generates in binlog the "B T N C" entries.
--echo #
INSERT INTO tt_1 VALUES ("new text -12", -12, "new text -12");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -11", -11, "new text -11"), ("new text -12", -12, "new text -12");
INSERT INTO nt_1 VALUES ("new text -13", -13, "new text -13");
COMMIT;
BEGIN;
INSERT INTO tt_1 VALUES ("new text -14", -14, "new text -14");
INSERT INTO nt_1 VALUES ("new text -16", -16, "new text -16");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -15", -15, "new text -15"), ("new text -16", -16, "new text -16");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #4) "B T N R" generates in binlog the "B T N R" entries.
--echo #
BEGIN;
INSERT INTO tt_1 VALUES ("new text 7", 7, "new text 7");
INSERT INTO nt_1 VALUES ("new text 7", 7, "new text 7");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #4.e) "B T N R" with error in either T or N generates in binlog the "B T N R" entries.
--echo #
INSERT INTO tt_1 VALUES ("new text -17", -17, "new text -17");
BEGIN;
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -16", -16, "new text -16"), ("new text -17", -17, "new text -17");
INSERT INTO nt_1 VALUES ("new text -18", -18, "new text -18");
ROLLBACK;
BEGIN;
INSERT INTO tt_1 VALUES ("new text -19", -19, "new text -19");
INSERT INTO nt_1 VALUES ("new text -21", -21, "new text -21");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -20", -20, "new text -20"), ("new text -21", -21, "new text -21");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #5) "T" generates in binlog the "B T C" entry.
--echo #
INSERT INTO tt_1 VALUES ("new text 8", 8, "new text 8");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #5.e) "T" with error in T generates in binlog an "empty" entry.
--echo #
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1");
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -22", -22, "new text -22");
--error ER_DUP_ENTRY
INSERT INTO tt_1 VALUES ("new text -23", -23, "new text -23"), ("new text -1", -1, "new text -1");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #6) "N" generates in binlog the "N" entry.
--echo #
INSERT INTO nt_1 VALUES ("new text 9", 9, "new text 9");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #6.e) "N" with error in N generates in binlog an empty entry if the error
--echo # happens in the first tuple. Otherwise, generates the "N" entry and
--echo # the error is appended.
--echo #
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
--error ER_DUP_ENTRY
INSERT INTO nt_1 VALUES ("new text -24", -24, "new text -24"), ("new text -1", -1, "new text -1");
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #7) "M" generates in binglog the "B M C" entries.
--echo #
DELETE FROM nt_1;
INSERT INTO nt_1 SELECT * FROM tt_1;
DELETE FROM tt_1;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_3 VALUES ("new text 000", 000, '');
INSERT INTO tt_3 VALUES("new text 100", 100, f1());
INSERT INTO nt_4 VALUES("new text 100", 100, f1());
INSERT INTO tt_3 VALUES("new text 200", 200, f2());
INSERT INTO nt_4 VALUES ("new text 300", 300, '');
INSERT INTO nt_4 VALUES ("new text 400", 400, f1());
INSERT INTO nt_4 VALUES ("new text 500", 500, f2());
CALL pc_i_tt_3(600, "Testing...");
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 1", nt_4.a= "new text 1", tt_3.a= "new text 1", tt_4.a= "new text 1" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 2", tt_4.a= "new text 2", nt_3.a= "new text 2", nt_4.a = "new text 2" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 3", nt_3.a= "new text 3", nt_4.a= "new text 3", tt_4.a = "new text 3" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 4", nt_3.a= "new text 4", nt_4.a= "new text 4", tt_4.a = "new text 4" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #7.e) "M" with error in M generates in binglog the "B M R" entries.
--echo #
INSERT INTO nt_3 VALUES ("new text -26", -26, '');
SELECT * FROM tt_3;
--error ER_DUP_ENTRY
INSERT INTO tt_3 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
SELECT * FROM tt_3;
INSERT INTO tt_4 VALUES ("new text -26", -26, '');
SELECT * FROM nt_4;
--error ER_DUP_ENTRY
INSERT INTO nt_4 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
SELECT * FROM nt_4;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #8) "B N N T C" generates in binglog the "N N B T C" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 10", 10, "new text 10");
INSERT INTO nt_2 VALUES ("new text 10", 10, "new text 10");
INSERT INTO tt_1 VALUES ("new text 10", 10, "new text 10");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
--echo #
--echo #8.e) "B N N T R" See 6.e and 9.e.
--echo #
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #9) "B N N T R" generates in binlog the "N N B T R" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 11", 11, "new text 11");
INSERT INTO nt_2 VALUES ("new text 11", 11, "new text 11");
INSERT INTO tt_1 VALUES ("new text 11", 11, "new text 11");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #9.e) "B N N T R" with error in N generates in binlog the "N N B T R" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text -25", -25, "new text -25");
INSERT INTO nt_2 VALUES ("new text -25", -25, "new text -25");
--error ER_DUP_ENTRY
INSERT INTO nt_2 VALUES ("new text -26", -26, "new text -26"), ("new text -25", -25, "new text -25");
INSERT INTO tt_1 VALUES ("new text -27", -27, "new text -27");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #10) "B N N C" generates in binglog the "N N" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 12", 12, "new text 12");
INSERT INTO nt_2 VALUES ("new text 12", 12, "new text 12");
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
--echo #
--echo #10.e) "B N N C" See 6.e and 9.e.
--echo #
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #11) "B N N R" generates in binlog the "N N" entries.
--echo #
BEGIN;
INSERT INTO nt_1 VALUES ("new text 13", 13, "new text 13");
INSERT INTO nt_2 VALUES ("new text 13", 13, "new text 13");
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
--echo #
--echo #11.e) "B N N R" See 6.e and 9.e.
--echo #
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #12) "B M T C" generates in the binlog the "B M T C" entries.
--echo #
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 14", 14, "new text 14");
COMMIT;
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 15", 15, "new text 15");
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 700", 700, '');
INSERT INTO tt_1 VALUES ("new text 800", 800, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES("new text 900", 900, f1());
INSERT INTO tt_1 VALUES ("new text 1000", 1000, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES(1100, 1100, f2());
INSERT INTO tt_1 VALUES ("new text 1200", 1200, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES ("new text 1300", 1300, '');
INSERT INTO tt_1 VALUES ("new text 1400", 1400, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1500", 1500, f1());
INSERT INTO tt_1 VALUES ("new text 1600", 1600, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1700", 1700, f2());
INSERT INTO tt_1 VALUES ("new text 1800", 1800, '');
COMMIT;
BEGIN;
CALL pc_i_tt_3(1900, "Testing...");
INSERT INTO tt_1 VALUES ("new text 2000", 2000, '');
COMMIT;
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 5", nt_4.a= "new text 5", tt_3.a= "new text 5", tt_4.a= "new text 5" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2100", 2100, '');
COMMIT;
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 6", tt_4.a= "new text 6", nt_3.a= "new text 6", nt_4.a = "new text 6" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2200", 2200, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 7", nt_3.a= "new text 7", nt_4.a= "new text 7", tt_4.a = "new text 7" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2300", 2300, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 8", nt_3.a= "new text 8", nt_4.a= "new text 8", tt_4.a = "new text 8" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2400", 2400, '');
COMMIT;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #12.e) "B M T C" with error in M generates in the binlog the "B M T C" entries.
--echo #
--echo # There is a bug in the slave that needs to be fixed before enabling
--echo # this part of the test. A bug report will be filed referencing this
--echo # test case.
#
#BEGIN;
#INSERT INTO nt_3 VALUES ("new text -28", -28, '');
#--error ER_DUP_ENTRY
#INSERT INTO tt_3 VALUES ("new text -27", -27, ''), ("new text -28", -28, '');
#INSERT INTO tt_1 VALUES ("new text -27", -27, '');
#COMMIT;
#
#BEGIN;
#INSERT INTO tt_4 VALUES ("new text -28", -28, '');
#--error ER_DUP_ENTRY
#INSERT INTO nt_4 VALUES ("new text -27", -27, ''), ("new text -28", -28, '');
#INSERT INTO tt_1 VALUES ("new text -28", -28, '');
#COMMIT;
#
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #13) "B M T R" generates in the binlog the "B M T R" entries
--echo #
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 17", 17, "new text 17");
ROLLBACK;
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 18", 18, "new text 18");
ROLLBACK;
INSERT INTO tt_1 SELECT * FROM nt_1;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 2500", 2500, '');
INSERT INTO tt_1 VALUES ("new text 2600", 2600, '');
ROLLBACK;
BEGIN;
INSERT INTO tt_3 VALUES("new text 2700", 2700, f1());
INSERT INTO tt_1 VALUES ("new text 2800", 2800, '');
ROLLBACK;
BEGIN;
INSERT INTO tt_3 VALUES(2900, 2900, f2());
INSERT INTO tt_1 VALUES ("new text 3000", 3000, '');
ROLLBACK;
BEGIN;
INSERT INTO nt_4 VALUES ("new text 3100", 3100, '');
INSERT INTO tt_1 VALUES ("new text 3200", 3200, '');
ROLLBACK;
BEGIN;
INSERT INTO nt_4 VALUES("new text 3300", 3300, f1());
INSERT INTO tt_1 VALUES ("new text 3400", 3400, '');
ROLLBACK;
BEGIN;
INSERT INTO nt_4 VALUES("new text 3500", 3500, f2());
INSERT INTO tt_1 VALUES ("new text 3600", 3600, '');
ROLLBACK;
BEGIN;
CALL pc_i_tt_3(3700, "Testing...");
INSERT INTO tt_1 VALUES ("new text 3700", 3700, '');
ROLLBACK;
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 9", nt_4.a= "new text 9", tt_3.a= "new text 9", tt_4.a= "new text 9" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3800", 3800, '');
ROLLBACK;
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 10", tt_4.a= "new text 10", nt_3.a= "new text 10", nt_4.a = "new text 10" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3900", 3900, '');
ROLLBACK;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 11", nt_3.a= "new text 11", nt_4.a= "new text 11", tt_4.a = "new text 11" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4000", 4000, '');
ROLLBACK;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 12", nt_3.a= "new text 12", nt_4.a= "new text 12", tt_4.a = "new text 12" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4100", 4100, '');
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #13.e) "B M T R" with error in M generates in the binlog the "B M T R" entries.
--echo #
BEGIN;
INSERT INTO nt_3 VALUES ("new text -30", -30, '');
--error ER_DUP_ENTRY
INSERT INTO tt_3 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
INSERT INTO tt_1 VALUES ("new text -30", -30, '');
ROLLBACK;
BEGIN;
INSERT INTO tt_4 VALUES ("new text -30", -30, '');
--error ER_DUP_ENTRY
INSERT INTO nt_4 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
INSERT INTO tt_1 VALUES ("new text -31", -31, '');
ROLLBACK;
--source include/show_binlog_events.inc
--echo
--echo
--echo
--echo
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
--echo #
--echo #14) "B M T R" with error in M generates in the binlog the "B M T R" entries.
--echo #
BEGIN;
INSERT INTO tt_4 VALUES ("new text -32", -32, '');
TRUNCATE TABLE tt_4;
INSERT INTO tt_4 VALUES ("new text -33", -33, '');
ROLLBACK;
--source include/show_binlog_events.inc
connection master;
sync_slave_with_master;
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-slave.sql
--diff_files $MYSQLTEST_VARDIR/tmp/test-master.sql $MYSQLTEST_VARDIR/tmp/test-slave.sql
--echo ###################################################################################
--echo # CLEAN
--echo ###################################################################################
connection master;
DROP TABLE tt_1;
DROP TABLE tt_2;
DROP TABLE tt_3;
DROP TABLE tt_4;
DROP TABLE nt_1;
DROP TABLE nt_2;
DROP TABLE nt_3;
DROP TABLE nt_4;
DROP PROCEDURE pc_i_tt_3;
DROP FUNCTION f1;
DROP FUNCTION f2;
sync_slave_with_master;
......@@ -725,9 +725,9 @@ call p_verify_status_increment(4, 4, 4, 4);
alter table t3 add column (b int);
call p_verify_status_increment(2, 0, 2, 0);
alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
truncate table t3;
call p_verify_status_increment(4, 4, 4, 4);
create view v1 as select * from t2;
......
......@@ -841,17 +841,17 @@ call p_verify_status_increment(2, 0, 2, 0);
SUCCESS
alter table t3 rename t4;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
rename table t4 to t3;
call p_verify_status_increment(1, 0, 1, 0);
call p_verify_status_increment(2, 2, 2, 2);
SUCCESS
truncate table t3;
call p_verify_status_increment(4, 4, 4, 4);
ERROR
Expected commit increment: 4 actual: 2
SUCCESS
create view v1 as select * from t2;
call p_verify_status_increment(1, 0, 1, 0);
SUCCESS
......
......@@ -379,7 +379,9 @@ master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
......@@ -838,8 +840,10 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=6
master-bin.000001 # Query # # use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
master-bin.000001 # Query # # ROLLBACK
select count(*) from t1 /* must be 4 */;
count(*)
4
......
......@@ -346,7 +346,9 @@ master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (3,3)
master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS t2
master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4,4)
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE table t2
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5,5)
master-bin.000001 # Query # # use `test`; DROP TABLE t2
master-bin.000001 # Query # # use `test`; INSERT INTO t1 values (6,6)
......@@ -545,8 +547,10 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=6
master-bin.000001 # Query # # use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
master-bin.000001 # Query # # ROLLBACK
/* the output must denote there is the query */;
select count(*) from t1 /* must be 4 */;
count(*)
......@@ -782,8 +786,10 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Intvar # # INSERT_ID=6
master-bin.000001 # Query # # use `test`; UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */
master-bin.000001 # Query # # ROLLBACK
select count(*) from t1 /* must be 4 */;
count(*)
4
......
......@@ -963,7 +963,9 @@ master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 't1, text 1')
master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; TRUNCATE t1
master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1
master-bin.000001 # Xid 1 # #
......
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
###################################################################################
# CONFIGURATION
###################################################################################
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
SET SQL_LOG_BIN=0;
CREATE TABLE nt_1 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_2 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_3 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE nt_4 (a text, b int PRIMARY KEY, c text) ENGINE = MyISAM;
CREATE TABLE tt_1 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_2 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_3 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
CREATE TABLE tt_4 (a text, b int PRIMARY KEY, c text) ENGINE = Innodb;
SET SQL_LOG_BIN=1;
CREATE FUNCTION f1 () RETURNS VARCHAR(64)
BEGIN
RETURN "Testing...";
END|
CREATE FUNCTION f2 () RETURNS VARCHAR(64)
BEGIN
RETURN f1();
END|
CREATE PROCEDURE pc_i_tt_3 (IN x INT, IN y VARCHAR(64))
BEGIN
INSERT INTO tt_3 VALUES (y,x,x);
END|
CREATE TRIGGER tr_i_tt_3_to_nt_3 BEFORE INSERT ON tt_3 FOR EACH ROW
BEGIN
INSERT INTO nt_3 VALUES (NEW.a, NEW.b, NEW.c);
END|
CREATE TRIGGER tr_i_nt_4_to_tt_4 BEFORE INSERT ON nt_4 FOR EACH ROW
BEGIN
INSERT INTO tt_4 VALUES (NEW.a, NEW.b, NEW.c);
END|
###################################################################################
# MIXING TRANSACTIONAL and NON-TRANSACTIONAL TABLES
###################################################################################
#
#1) "B T T C" generates in binlog the "B T T C" entries.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 4", 4, "new text 4");
INSERT INTO tt_2 VALUES ("new text 4", 4, "new text 4");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 4", 4, "new text 4")
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 4", 4, "new text 4")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#1.e) "B T T C" with error in T generates in binlog the "B T T C" entries.
#
INSERT INTO tt_1 VALUES ("new text -2", -2, "new text -2");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -2", -2, "new text -2");
ERROR 23000: Duplicate entry '-2' for key 'PRIMARY'
INSERT INTO tt_2 VALUES ("new text -3", -3, "new text -3");
COMMIT;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -5", -5, "new text -5");
INSERT INTO tt_2 VALUES ("new text -4", -4, "new text -4"), ("new text -5", -5, "new text -5");
ERROR 23000: Duplicate entry '-5' for key 'PRIMARY'
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -2", -2, "new text -2")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text -3", -3, "new text -3")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text -5", -5, "new text -5")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#2) "B T T R" generates in binlog an "empty" entry.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 5", 5, "new text 5");
INSERT INTO tt_2 VALUES ("new text 5", 5, "new text 5");
ROLLBACK;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
#
#2.e) "B T T R" with error in T generates in binlog an "empty" entry.
#
INSERT INTO tt_1 VALUES ("new text -7", -7, "new text -7");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -6", -6, "new text -6"), ("new text -7", -7, "new text -7");
ERROR 23000: Duplicate entry '-7' for key 'PRIMARY'
INSERT INTO tt_2 VALUES ("new text -8", -8, "new text -8");
ROLLBACK;
BEGIN;
INSERT INTO tt_2 VALUES ("new text -10", -10, "new text -10");
INSERT INTO tt_2 VALUES ("new text -9", -9, "new text -9"), ("new text -10", -10, "new text -10");
ERROR 23000: Duplicate entry '-10' for key 'PRIMARY'
ROLLBACK;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -7", -7, "new text -7")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#3) "B T N C" generates in binlog the "B T N C" entries.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 6", 6, "new text 6");
INSERT INTO nt_1 VALUES ("new text 6", 6, "new text 6");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 6", 6, "new text 6")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 6", 6, "new text 6")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#3.e) "B T N C" with error in either T or N generates in binlog the "B T N C" entries.
#
INSERT INTO tt_1 VALUES ("new text -12", -12, "new text -12");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -11", -11, "new text -11"), ("new text -12", -12, "new text -12");
ERROR 23000: Duplicate entry '-12' for key 'PRIMARY'
INSERT INTO nt_1 VALUES ("new text -13", -13, "new text -13");
COMMIT;
BEGIN;
INSERT INTO tt_1 VALUES ("new text -14", -14, "new text -14");
INSERT INTO nt_1 VALUES ("new text -16", -16, "new text -16");
INSERT INTO nt_1 VALUES ("new text -15", -15, "new text -15"), ("new text -16", -16, "new text -16");
ERROR 23000: Duplicate entry '-16' for key 'PRIMARY'
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -12", -12, "new text -12")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -13", -13, "new text -13")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -14", -14, "new text -14")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -16", -16, "new text -16")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -15", -15, "new text -15"), ("new text -16", -16, "new text -16")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#4) "B T N R" generates in binlog the "B T N R" entries.
#
BEGIN;
INSERT INTO tt_1 VALUES ("new text 7", 7, "new text 7");
INSERT INTO nt_1 VALUES ("new text 7", 7, "new text 7");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 7", 7, "new text 7")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 7", 7, "new text 7")
master-bin.000001 # Query # # ROLLBACK
#
#4.e) "B T N R" with error in either T or N generates in binlog the "B T N R" entries.
#
INSERT INTO tt_1 VALUES ("new text -17", -17, "new text -17");
BEGIN;
INSERT INTO tt_1 VALUES ("new text -16", -16, "new text -16"), ("new text -17", -17, "new text -17");
ERROR 23000: Duplicate entry '-17' for key 'PRIMARY'
INSERT INTO nt_1 VALUES ("new text -18", -18, "new text -18");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_1 VALUES ("new text -19", -19, "new text -19");
INSERT INTO nt_1 VALUES ("new text -21", -21, "new text -21");
INSERT INTO nt_1 VALUES ("new text -20", -20, "new text -20"), ("new text -21", -21, "new text -21");
ERROR 23000: Duplicate entry '-21' for key 'PRIMARY'
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -17", -17, "new text -17")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -18", -18, "new text -18")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -19", -19, "new text -19")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -21", -21, "new text -21")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -20", -20, "new text -20"), ("new text -21", -21, "new text -21")
master-bin.000001 # Query # # ROLLBACK
#
#5) "T" generates in binlog the "B T C" entry.
#
INSERT INTO tt_1 VALUES ("new text 8", 8, "new text 8");
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 8", 8, "new text 8")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#5.e) "T" with error in T generates in binlog an "empty" entry.
#
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1");
INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1"), ("new text -22", -22, "new text -22");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -23", -23, "new text -23"), ("new text -1", -1, "new text -1");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -1", -1, "new text -1")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#6) "N" generates in binlog the "N" entry.
#
INSERT INTO nt_1 VALUES ("new text 9", 9, "new text 9");
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 9", 9, "new text 9")
#
#6.e) "N" with error in N generates in binlog an empty entry if the error
# happens in the first tuple. Otherwise, generates the "N" entry and
# the error is appended.
#
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
INSERT INTO nt_1 VALUES ("new text -24", -24, "new text -24"), ("new text -1", -1, "new text -1");
ERROR 23000: Duplicate entry '-1' for key 'PRIMARY'
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -1", -1, "new text -1")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -24", -24, "new text -24"), ("new text -1", -1, "new text -1")
#
#7) "M" generates in binglog the "B M C" entries.
#
DELETE FROM nt_1;
INSERT INTO nt_1 SELECT * FROM tt_1;
DELETE FROM tt_1;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_3 VALUES ("new text 000", 000, '');
INSERT INTO tt_3 VALUES("new text 100", 100, f1());
INSERT INTO nt_4 VALUES("new text 100", 100, f1());
INSERT INTO tt_3 VALUES("new text 200", 200, f2());
INSERT INTO nt_4 VALUES ("new text 300", 300, '');
INSERT INTO nt_4 VALUES ("new text 400", 400, f1());
INSERT INTO nt_4 VALUES ("new text 500", 500, f2());
CALL pc_i_tt_3(600, "Testing...");
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 1", nt_4.a= "new text 1", tt_3.a= "new text 1", tt_4.a= "new text 1" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 2", tt_4.a= "new text 2", nt_3.a= "new text 2", nt_4.a = "new text 2" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 3", nt_3.a= "new text 3", nt_4.a= "new text 3", tt_4.a = "new text 3" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 4", nt_3.a= "new text 4", nt_4.a= "new text 4", tt_4.a = "new text 4" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; DELETE FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 SELECT * FROM tt_1
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DELETE FROM tt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 SELECT * FROM nt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text 000", 000, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 100", 100, f1())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 100", 100, f1())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 200", 200, f2())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 300", 300, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 400", 400, f1())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 500", 500, f2())
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ( NAME_CONST('y',_latin1'Testing...' COLLATE 'latin1_swedish_ci'), NAME_CONST('x',600), NAME_CONST('x',600))
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 1", nt_4.a= "new text 1", tt_3.a= "new text 1", tt_4.a= "new text 1" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 2", tt_4.a= "new text 2", nt_3.a= "new text 2", nt_4.a = "new text 2" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 3", nt_3.a= "new text 3", nt_4.a= "new text 3", tt_4.a = "new text 3" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 4", nt_3.a= "new text 4", nt_4.a= "new text 4", tt_4.a = "new text 4" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Xid # # COMMIT /* XID */
#
#7.e) "M" with error in M generates in binglog the "B M R" entries.
#
INSERT INTO nt_3 VALUES ("new text -26", -26, '');
SELECT * FROM tt_3;
a b c
new text 000 0
new text 4 100 Testing...
new text 200 200 Testing...
Testing... 600 600
INSERT INTO tt_3 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
ERROR 23000: Duplicate entry '-26' for key 'PRIMARY'
SELECT * FROM tt_3;
a b c
new text 000 0
new text 4 100 Testing...
new text 200 200 Testing...
Testing... 600 600
INSERT INTO tt_4 VALUES ("new text -26", -26, '');
SELECT * FROM nt_4;
a b c
new text 4 100 Testing...
new text 300 300
new text 400 400 Testing...
new text 500 500 Testing...
INSERT INTO nt_4 VALUES ("new text -25", -25, ''), ("new text -26", -26, '');
ERROR 23000: Duplicate entry '-26' for key 'PRIMARY'
SELECT * FROM nt_4;
a b c
new text 4 100 Testing...
new text 300 300
new text 400 400 Testing...
new text 500 500 Testing...
new text -25 -25
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_3 VALUES ("new text -26", -26, '')
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text -25", -25, ''), ("new text -26", -26, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_4 VALUES ("new text -26", -26, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text -25", -25, ''), ("new text -26", -26, '')
master-bin.000001 # Query # # ROLLBACK
#
#8) "B N N T C" generates in binglog the "N N B T C" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 10", 10, "new text 10");
INSERT INTO nt_2 VALUES ("new text 10", 10, "new text 10");
INSERT INTO tt_1 VALUES ("new text 10", 10, "new text 10");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 10", 10, "new text 10")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 10", 10, "new text 10")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 10", 10, "new text 10")
master-bin.000001 # Xid # # COMMIT /* XID */
#
#8.e) "B N N T R" See 6.e and 9.e.
#
#
#9) "B N N T R" generates in binlog the "N N B T R" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 11", 11, "new text 11");
INSERT INTO nt_2 VALUES ("new text 11", 11, "new text 11");
INSERT INTO tt_1 VALUES ("new text 11", 11, "new text 11");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 11", 11, "new text 11")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 11", 11, "new text 11")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 11", 11, "new text 11")
master-bin.000001 # Query # # ROLLBACK
#
#9.e) "B N N T R" with error in N generates in binlog the "N N B T R" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text -25", -25, "new text -25");
INSERT INTO nt_2 VALUES ("new text -25", -25, "new text -25");
INSERT INTO nt_2 VALUES ("new text -26", -26, "new text -26"), ("new text -25", -25, "new text -25");
ERROR 23000: Duplicate entry '-25' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -27", -27, "new text -27");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text -25", -25, "new text -25")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text -25", -25, "new text -25")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text -26", -26, "new text -26"), ("new text -25", -25, "new text -25")
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -27", -27, "new text -27")
master-bin.000001 # Query # # ROLLBACK
#
#10) "B N N C" generates in binglog the "N N" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 12", 12, "new text 12");
INSERT INTO nt_2 VALUES ("new text 12", 12, "new text 12");
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 12", 12, "new text 12")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 12", 12, "new text 12")
#
#10.e) "B N N C" See 6.e and 9.e.
#
#
#11) "B N N R" generates in binlog the "N N" entries.
#
BEGIN;
INSERT INTO nt_1 VALUES ("new text 13", 13, "new text 13");
INSERT INTO nt_2 VALUES ("new text 13", 13, "new text 13");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 VALUES ("new text 13", 13, "new text 13")
master-bin.000001 # Query # # use `test`; INSERT INTO nt_2 VALUES ("new text 13", 13, "new text 13")
#
#11.e) "B N N R" See 6.e and 9.e.
#
#
#12) "B M T C" generates in the binlog the "B M T C" entries.
#
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 14", 14, "new text 14");
COMMIT;
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 15", 15, "new text 15");
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 700", 700, '');
INSERT INTO tt_1 VALUES ("new text 800", 800, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES("new text 900", 900, f1());
INSERT INTO tt_1 VALUES ("new text 1000", 1000, '');
COMMIT;
BEGIN;
INSERT INTO tt_3 VALUES(1100, 1100, f2());
INSERT INTO tt_1 VALUES ("new text 1200", 1200, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES ("new text 1300", 1300, '');
INSERT INTO tt_1 VALUES ("new text 1400", 1400, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1500", 1500, f1());
INSERT INTO tt_1 VALUES ("new text 1600", 1600, '');
COMMIT;
BEGIN;
INSERT INTO nt_4 VALUES("new text 1700", 1700, f2());
INSERT INTO tt_1 VALUES ("new text 1800", 1800, '');
COMMIT;
BEGIN;
CALL pc_i_tt_3(1900, "Testing...");
INSERT INTO tt_1 VALUES ("new text 2000", 2000, '');
COMMIT;
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 5", nt_4.a= "new text 5", tt_3.a= "new text 5", tt_4.a= "new text 5" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2100", 2100, '');
COMMIT;
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 6", tt_4.a= "new text 6", nt_3.a= "new text 6", nt_4.a = "new text 6" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2200", 2200, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 7", nt_3.a= "new text 7", nt_4.a= "new text 7", tt_4.a = "new text 7" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2300", 2300, '');
COMMIT;
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 8", nt_3.a= "new text 8", nt_4.a= "new text 8", tt_4.a = "new text 8" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 2400", 2400, '');
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; DELETE FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 SELECT * FROM tt_1
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 14", 14, "new text 14")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DELETE FROM tt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 SELECT * FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 15", 15, "new text 15")
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text 700", 700, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 800", 800, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 900", 900, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1000", 1000, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES(1100, 1100, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1200", 1200, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 1300", 1300, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1400", 1400, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 1500", 1500, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1600", 1600, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 1700", 1700, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 1800", 1800, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ( NAME_CONST('y',_latin1'Testing...' COLLATE 'latin1_swedish_ci'), NAME_CONST('x',1900), NAME_CONST('x',1900))
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2000", 2000, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 5", nt_4.a= "new text 5", tt_3.a= "new text 5", tt_4.a= "new text 5" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2100", 2100, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 6", tt_4.a= "new text 6", nt_3.a= "new text 6", nt_4.a = "new text 6" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2200", 2200, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 7", nt_3.a= "new text 7", nt_4.a= "new text 7", tt_4.a = "new text 7" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2300", 2300, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 8", nt_3.a= "new text 8", nt_4.a= "new text 8", tt_4.a = "new text 8" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2400", 2400, '')
master-bin.000001 # Xid # # COMMIT /* XID */
#
#12.e) "B M T C" with error in M generates in the binlog the "B M T C" entries.
#
# There is a bug in the slave that needs to be fixed before enabling
# this part of the test. A bug report will be filed referencing this
# test case.
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
#
#13) "B M T R" generates in the binlog the "B M T R" entries
#
DELETE FROM nt_1;
BEGIN;
INSERT INTO nt_1 SELECT * FROM tt_1;
INSERT INTO tt_2 VALUES ("new text 17", 17, "new text 17");
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
DELETE FROM tt_1;
BEGIN;
INSERT INTO tt_1 SELECT * FROM nt_1;
INSERT INTO tt_2 VALUES ("new text 18", 18, "new text 18");
ROLLBACK;
INSERT INTO tt_1 SELECT * FROM nt_1;
BEGIN;
INSERT INTO tt_3 VALUES ("new text 2500", 2500, '');
INSERT INTO tt_1 VALUES ("new text 2600", 2600, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_3 VALUES("new text 2700", 2700, f1());
INSERT INTO tt_1 VALUES ("new text 2800", 2800, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_3 VALUES(2900, 2900, f2());
INSERT INTO tt_1 VALUES ("new text 3000", 3000, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO nt_4 VALUES ("new text 3100", 3100, '');
INSERT INTO tt_1 VALUES ("new text 3200", 3200, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO nt_4 VALUES("new text 3300", 3300, f1());
INSERT INTO tt_1 VALUES ("new text 3400", 3400, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO nt_4 VALUES("new text 3500", 3500, f2());
INSERT INTO tt_1 VALUES ("new text 3600", 3600, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
CALL pc_i_tt_3(3700, "Testing...");
INSERT INTO tt_1 VALUES ("new text 3700", 3700, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 9", nt_4.a= "new text 9", tt_3.a= "new text 9", tt_4.a= "new text 9" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3800", 3800, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 10", tt_4.a= "new text 10", nt_3.a= "new text 10", nt_4.a = "new text 10" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 3900", 3900, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 11", nt_3.a= "new text 11", nt_4.a= "new text 11", tt_4.a = "new text 11" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4000", 4000, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 12", nt_3.a= "new text 12", nt_4.a= "new text 12", tt_4.a = "new text 12" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100;
INSERT INTO tt_1 VALUES ("new text 4100", 4100, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; DELETE FROM nt_1
master-bin.000001 # Query # # use `test`; INSERT INTO nt_1 SELECT * FROM tt_1
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_2 VALUES ("new text 17", 17, "new text 17")
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DELETE FROM tt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 SELECT * FROM nt_1
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text 2500", 2500, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2600", 2600, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES("new text 2700", 2700, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 2800", 2800, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES(2900, 2900, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3000", 3000, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text 3100", 3100, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3200", 3200, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 3300", 3300, f1())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3400", 3400, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES("new text 3500", 3500, f2())
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3600", 3600, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ( NAME_CONST('y',_latin1'Testing...' COLLATE 'latin1_swedish_ci'), NAME_CONST('x',3700), NAME_CONST('x',3700))
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3700", 3700, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE nt_3, nt_4, tt_3, tt_4 SET nt_3.a= "new text 9", nt_4.a= "new text 9", tt_3.a= "new text 9", tt_4.a= "new text 9" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3800", 3800, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, tt_4, nt_3, nt_4 SET tt_3.a= "new text 10", tt_4.a= "new text 10", nt_3.a= "new text 10", nt_4.a = "new text 10" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 3900", 3900, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 11", nt_3.a= "new text 11", nt_4.a= "new text 11", tt_4.a = "new text 11" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 4000", 4000, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; UPDATE tt_3, nt_3, nt_4, tt_4 SET tt_3.a= "new text 12", nt_3.a= "new text 12", nt_4.a= "new text 12", tt_4.a = "new text 12" where nt_3.b = nt_4.b and nt_4.b = tt_3.b and tt_3.b = tt_4.b and tt_4.b = 100
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text 4100", 4100, '')
master-bin.000001 # Query # # ROLLBACK
#
#13.e) "B M T R" with error in M generates in the binlog the "B M T R" entries.
#
BEGIN;
INSERT INTO nt_3 VALUES ("new text -30", -30, '');
INSERT INTO tt_3 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
ERROR 23000: Duplicate entry '-30' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -30", -30, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO tt_4 VALUES ("new text -30", -30, '');
INSERT INTO nt_4 VALUES ("new text -29", -29, ''), ("new text -30", -30, '');
ERROR 23000: Duplicate entry '-30' for key 'PRIMARY'
INSERT INTO tt_1 VALUES ("new text -31", -31, '');
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO nt_3 VALUES ("new text -30", -30, '')
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_3 VALUES ("new text -29", -29, ''), ("new text -30", -30, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -30", -30, '')
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_4 VALUES ("new text -30", -30, '')
master-bin.000001 # Query # # use `test`; INSERT INTO nt_4 VALUES ("new text -29", -29, ''), ("new text -30", -30, '')
master-bin.000001 # Query # # use `test`; INSERT INTO tt_1 VALUES ("new text -31", -31, '')
master-bin.000001 # Query # # ROLLBACK
#
#14) "B M T R" with error in M generates in the binlog the "B M T R" entries.
#
BEGIN;
INSERT INTO tt_4 VALUES ("new text -32", -32, '');
TRUNCATE TABLE tt_4;
INSERT INTO tt_4 VALUES ("new text -33", -33, '');
ROLLBACK;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_4 VALUES ("new text -32", -32, '')
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; TRUNCATE TABLE tt_4
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tt_4 VALUES ("new text -33", -33, '')
master-bin.000001 # Xid # # COMMIT /* XID */
###################################################################################
# CLEAN
###################################################################################
DROP TABLE tt_1;
DROP TABLE tt_2;
DROP TABLE tt_3;
DROP TABLE tt_4;
DROP TABLE nt_1;
DROP TABLE nt_2;
DROP TABLE nt_3;
DROP TABLE nt_4;
DROP PROCEDURE pc_i_tt_3;
DROP FUNCTION f1;
DROP FUNCTION f2;
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
--source include/have_innodb.inc
--source extra/rpl_tests/rpl_mixing_engines.test
......@@ -1264,6 +1264,25 @@ int LOGGER::set_handlers(uint error_log_printer,
return 0;
}
/**
This function checks if a transactional talbe was updated by the
current statement.
@param thd The client thread that executed the current statement.
@return
@c true if a transactional table was updated, @false otherwise.
*/
static bool stmt_has_updated_trans_table(THD *thd)
{
Ha_trx_info *ha_info;
for (ha_info= thd->transaction.stmt.ha_list; ha_info; ha_info= ha_info->next())
{
if (ha_info->is_trx_read_write() && ha_info->ht() != binlog_hton)
return (TRUE);
}
return (FALSE);
}
/*
Save position of binary log transaction cache.
......@@ -4060,7 +4079,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
(binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
IO_CACHE *trans_log= &trx_data->trans_log;
my_off_t trans_log_pos= my_b_tell(trans_log);
if (event_info->get_cache_stmt() || trans_log_pos != 0)
if (event_info->get_cache_stmt() || trans_log_pos != 0 ||
stmt_has_updated_trans_table(thd))
{
DBUG_PRINT("info", ("Using trans_log: cache: %d, trans_log_pos: %lu",
event_info->get_cache_stmt(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment