--let $gtid_violation= 0 --let $error_code= 0 --let $statement_ends_transaction= 1 --let $sync_point= end_decide_logging_format CREATE TABLE myisam1 (a INT) ENGINE = MyISAM; CREATE TABLE myisam2 (a INT) ENGINE = MyISAM; CREATE TABLE innodb (a INT) ENGINE = InnoDB; # Mixing two MyISAM updates in the same statement or transaction is # GTID-consistent (it is only when *both* transactional and # non-transactional updates are mixed that it violates # GTID-consistency). # if gtid_next=GTID, it generates ER_GTID_NEXT_TYPE_UNDEFINED_GROUP. if ($gtid_next != 'GTID') { --echo ---- MyISAM followed by MyISAM, in one 'trx' ---- --let $pre_statement= BEGIN; INSERT INTO myisam1 VALUES (1) --let $statement= INSERT INTO myisam2 VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc } --echo ---- MyISAM and MyISAM in one statement ---- CREATE TRIGGER trig BEFORE INSERT ON myisam1 FOR EACH ROW INSERT INTO myisam2 VALUES (1); --let $statement= INSERT INTO myisam2 VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc DROP TRIGGER trig; # if gtid_next=GTID, it generates ER_GTID_NEXT_TYPE_UNDEFINED_GROUP. if ($gtid_next != 'GTID') { # As a special case, when MyISAM precedes InnoDB in a transaction, the # MyISAM is executed as if it was outside the transaction, so that is # GTID-consistent too. --echo ---- MyISAM followed by InnoDB, in one 'trx' ---- --let $pre_statement= BEGIN; INSERT INTO myisam1 VALUES (1) --let $statement= INSERT INTO innodb VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc } # When InnoDB is mixed with *temporary* MyISAM and binlog_format=row, # or binlog_format=mixed and it logs in row format, it is # GTID-consistent since DML on temporary tables is not logged at all # in row format. # Use binlog_format=mixed and force it to switch to row format. SET SESSION BINLOG_FORMAT = MIXED; --echo ---- InnoDB followed by temp MyISAM in one trx, binlog_format=mix ---- # For this case, server should switch to row format specifically # because the transaction mixes InnoDB with temporary MyISAM. Thus, it # becomes GTID consistent since it doesn't need to write a mix of # InnoDB and MyISAM to the binlog. CREATE TEMPORARY TABLE tmp_myisam1 (a INT) ENGINE = MyISAM; --let $pre_statement= BEGIN; INSERT INTO innodb VALUES (1) --let $statement= INSERT INTO tmp_myisam1 VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc DROP TEMPORARY TABLE tmp_myisam1; --echo ---- InnoDB and temp MyISAM in one autocommit statement, binlog_format=mix ---- # For this case, server should switch to row format specifically # because the transaction mixes InnoDB with temporary MyISAM. Thus, it # becomes GTID consistent since it doesn't need to write a mix of # InnoDB and MyISAM to the binlog. CREATE TEMPORARY TABLE tmp_myisam1 (a INT) ENGINE = MyISAM; CREATE TEMPORARY TABLE tmp_myisam2 (a INT) ENGINE = MyISAM; --eval CREATE TRIGGER trig BEFORE INSERT ON innodb FOR EACH ROW BEGIN INSERT INTO tmp_myisam1 VALUES (1); INSERT INTO tmp_myisam2 VALUES (1); END --let $statement= INSERT INTO innodb VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc DROP TRIGGER trig; DROP TEMPORARY TABLE tmp_myisam1, tmp_myisam2; SET BINLOG_FORMAT = ROW; CREATE TEMPORARY TABLE tmp_myisam1 (a INT) ENGINE = MyISAM; CREATE TEMPORARY TABLE tmp_myisam2 (a INT) ENGINE = MyISAM; --echo ---- InnoDB followed by temp MyISAM in one trx, binlog_format=row ---- --let $pre_statement= BEGIN; INSERT INTO innodb VALUES (1) --let $statement= INSERT INTO tmp_myisam1 VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc --echo ---- InnoDB and temp MyISAM in one statement, binlog_format=row ---- --eval CREATE TRIGGER trig BEFORE INSERT ON innodb FOR EACH ROW BEGIN INSERT INTO tmp_myisam1 VALUES (1); INSERT INTO tmp_myisam2 VALUES (1); END --let $statement= INSERT INTO innodb VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc DROP TRIGGER trig; # Drop temp tables and recreate them after SET BINLOG_FORMAT, since # it's not allowed to have temp tables open when switching from # binlog_format=row to statement. DROP TEMPORARY TABLE tmp_myisam1, tmp_myisam2; --replace_regex /'[A-Z]*'/#/ eval SET BINLOG_FORMAT = '$binlog_format'; CREATE TEMPORARY TABLE tmp_myisam1 (a INT) ENGINE = MyISAM; CREATE TEMPORARY TABLE tmp_myisam2 (a INT) ENGINE = MyISAM; # When SQL_LOG_BIN=0, it is GTID-consistent since nothing is logged. SET SQL_LOG_BIN = 0; --echo ---- InnoDB and MyISAM in one statement, SQL_LOG_BIN=0 ---- --eval CREATE TRIGGER trig BEFORE INSERT ON innodb FOR EACH ROW BEGIN INSERT INTO myisam1 VALUES (1); INSERT INTO myisam2 VALUES (1); END --let $statement= INSERT INTO innodb VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc DROP TRIGGER trig; --echo ---- InnoDB followed by MyISAM, in one trx, SQL_LOG_BIN=0 ---- --let $pre_statement= BEGIN; INSERT INTO innodb VALUES (1) --let $statement= INSERT INTO myisam1 VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc --echo ---- InnoDB and MyISAM in one statement inside trx, SQL_LOG_BIN=0 ---- --eval CREATE TRIGGER trig BEFORE INSERT ON innodb FOR EACH ROW BEGIN INSERT INTO myisam1 VALUES (1); INSERT INTO myisam2 VALUES (1); END --let $pre_statement= BEGIN --let $statement= INSERT INTO innodb VALUES (1) --source extra/binlog_tests/enforce_gtid_consistency_statement.inc DROP TRIGGER trig; SET SQL_LOG_BIN = 1; DROP TABLE myisam1, myisam2, tmp_myisam1, tmp_myisam2, innodb;