Commit 68ecc965 authored by Alfranio Correia's avatar Alfranio Correia
Browse files

WL#5344

parent c9221a2a
This diff is collapsed.
###############################################################################
# In this test case, we check how changes to temporary tables are written
# to the binary log.
#
# (TODO --- GET INFO AS SOON AS THE SITE IS AVAILABLE)
#
# This test uses the commands available at:
# extra/rpl_tests/rpl_drop_create_temp_table.inc
#
###############################################################################
--echo #########################################################################
--echo # CONFIGURATION
--echo #########################################################################
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT.");
--let $tot_table= 2
SET @commands= 'configure';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo #########################################################################
--echo # 1 - Tables dropped by "DROP TEMPORARY TABLE"
--echo #########################################################################
connection master;
--echo
--echo #
--echo #1) Generates in the binlog what follows:
--echo #
SET @commands= 'Drop-Temp-T-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-N-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-Xe-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-If-Xe-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-TXe-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-If-TXe-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-NXe-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-If-NXe-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-TN-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-TT-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-NN-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo
--echo #
--echo #2) Generates in the binlog what follows:
--echo #
SET @commands= 'B T Drop-Temp-T-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-T-Temp N Drop-Temp-T-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-N-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-N-Temp N Drop-Temp-N-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-Xe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-Xe-Temp N Drop-Temp-Xe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-Xe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TXe-Temp N Drop-Temp-TXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-TXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-TXe-Temp N Drop-Temp-If-TXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NXe-Temp N Drop-Temp-NXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-NXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-NXe-Temp N Drop-Temp-If-NXe-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp N Drop-Temp-TN-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TT-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TT-Temp N Drop-Temp-TT-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NN-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo
--echo #
--echo #3) Generates in the binlog what follows:
--echo #
SET @commands= 'B T Drop-Temp-T-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-T-Temp N Drop-Temp-T-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-N-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-N-Temp N Drop-Temp-N-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-Xe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-Xe-Temp N Drop-Temp-Xe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-Xe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-Xe-Temp N Drop-Temp-If-Xe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TXe-Temp N Drop-Temp-TXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-TXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-TXe-Temp N Drop-Temp-If-TXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NXe-Temp N Drop-Temp-NXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-NXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-If-NXe-Temp N Drop-Temp-If-NXe-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TN-Temp N Drop-Temp-TN-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TT-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-TT-Temp N Drop-Temp-TT-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NN-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Temp-NN-Temp N Drop-Temp-NN-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo #########################################################################
--echo # 2 - Tables dropped by "DROP TABLE"
--echo #########################################################################
connection master;
--echo
--echo #
--echo #1) Generates in the binlog what follows:
--echo #
SET @commands= 'Drop-T';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-N';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Xe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-If-Xe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-TXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-If-TXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-NXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-If-NXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-TN';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-TT';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-NN';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-N-TN-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-TN-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo
--echo #
--echo #2) Generates in the binlog what follows:
--echo #
SET @commands= 'B T Drop-T';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-N';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-Xe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-If-Xe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-TXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-If-TXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-NXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-If-NXe';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-TN';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-TT';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-NN';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-N-TN-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B T Drop-TN-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo #########################################################################
--echo # 3 - CREATE TEMPORARY TABLE
--echo #########################################################################
connection master;
--echo
--echo #
--echo #1) Generates in the binlog what follows:
--echo #
SET @commands= 'Drop-Temp-N-Temp Create-N-Temp Drop-Temp-N-Temp Drop-Temp-N-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo
--echo #
--echo #2) Generates in the binlog what follows:
--echo #
SET @commands= 'B T Drop-Temp-N-Temp Create-N-Temp Drop-Temp-N-Temp Drop-Temp-N-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo
--echo #
--echo #3) Generates in the binlog what follows:
--echo #
SET @commands= 'B T Drop-Temp-N-Temp Create-N-Temp Drop-Temp-N-Temp Drop-Temp-N-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B Drop-Temp-T-Temp Create-T-Temp Drop-Temp-T-Temp Drop-Temp-T-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo #########################################################################
--echo # 4 - CHANGING TEMPORARY TABLES
--echo #########################################################################
connection master;
--echo
--echo #
--echo #1) Generates in the binlog what follows:
--echo #
SET @commands= 'B N N-Temp N-SELECT-N-Temp N-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B N N-Temp T-SELECT-N-Temp N-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B N N-Temp N-SELECT-T-Temp N-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp C';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo
--echo
--echo #
--echo #2) Generates in the binlog what follows:
--echo #
SET @commands= 'B N N-Temp N-SELECT-N-Temp N-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B N N-Temp T-SELECT-N-Temp N-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B N N-Temp N-SELECT-T-Temp N-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
SET @commands= 'B N N-Temp T-SELECT-T-Temp N-Temp R';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
--echo ###################################################################################
--echo # CHECK CONSISTENCY
--echo ###################################################################################
connection master;
sync_slave_with_master;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-temporary-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-temporary-slave.sql
--diff_files $MYSQLD_DATADIR/test-temporary-master.sql $MYSQLD_DATADIR/test-temporary-slave.sql
--echo #########################################################################
--echo # CLEAN
--echo #########################################################################
SET @commands= 'clean';
--source extra/rpl_tests/rpl_drop_create_temp_table.inc
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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;
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
########################################################################
# VERIFY ITEMS 1 and 2
########################################################################
#
# Create temporary tables to verify when statements involving temporary
# tables are classified as safe or unsafe by printing out the warning
# messages.
#
CREATE TABLE t_myisam(id int) engine= MyIsam;
INSERT INTO t_myisam VALUES(1);
CREATE TABLE t_innodb(id int) engine= Innodb;
INSERT INTO t_innodb VALUES(1);
CREATE TEMPORARY TABLE t_myisam_temp(id int) engine= MyIsam;
INSERT INTO t_myisam_temp VALUES(1);
CREATE TEMPORARY TABLE t_innodb_temp(id int) engine= Innodb;
INSERT INTO t_innodb_temp VALUES(1);
BEGIN;
INSERT INTO t_myisam SELECT * FROM t_myisam_temp;
INSERT INTO t_innodb SELECT * FROM t_myisam_temp;
INSERT INTO t_innodb SELECT * FROM t_innodb_temp;
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
BEGIN;
INSERT INTO t_myisam SELECT * FROM t_innodb_temp;
INSERT INTO t_innodb SELECT * FROM t_myisam_temp;
INSERT INTO t_innodb SELECT * FROM t_innodb_temp;
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
########################################################################
# VERIFY ITEM 3
########################################################################
#
# When there is a temporary table we can switch between the mixed and
# row formats. However, we cannot switch to the statement format.
#
SET BINLOG_FORMAT=MIXED;
SET BINLOG_FORMAT=ROW;
SET BINLOG_FORMAT=MIXED;
SET BINLOG_FORMAT=STATEMENT;
ERROR HY000: Cannot switch out of the row-based binary log format when the session has open temporary tables
#
# When there is a temporary table we can switch between the mixed and
# row formats. However, we cannot swith to the statement format.
#
SET BINLOG_FORMAT=MIXED;
DROP TABLE t_myisam_temp, t_innodb_temp, t_myisam, t_innodb;
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 t_myisam SELECT * FROM t_myisam_temp
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb SELECT * FROM t_myisam_temp
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb SELECT * FROM t_innodb_temp
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t_myisam SELECT * FROM t_innodb_temp
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb SELECT * FROM t_myisam_temp
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb SELECT * FROM t_innodb_temp
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # use `test`; DROP TABLE `t_myisam`,`t_innodb` /* generated by server */
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `t_myisam_temp`,`t_innodb_temp` /* generated by server */
########################################################################
# VERIFY ITEMS 4 and 5
########################################################################
#
BEGIN;
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
INSERT INTO tmp1 VALUES(1);
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
INSERT INTO tmp2 VALUES(1);
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp1;
DROP TEMPORARY TABLE tmp2;
DROP TEMPORARY TABLE tmp3;
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`; CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam
master-bin.000001 # Query # # use `test`; INSERT INTO tmp1 VALUES(1)
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp2 LIKE tmp1
master-bin.000001 # Query # # use `test`; INSERT INTO tmp2 VALUES(1)
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1
master-bin.000001 # Query # # use `test`; INSERT INTO tmp3 VALUES(1)
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE tmp1
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE tmp2
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE tmp3
master-bin.000001 # Query # # COMMIT
BEGIN;
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
INSERT INTO tmp1 VALUES(1);
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
INSERT INTO tmp2 VALUES(1);
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp1;
DROP TEMPORARY TABLE tmp2;
DROP TEMPORARY TABLE tmp3;
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`; CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam
master-bin.000001 # Query # # use `test`; INSERT INTO tmp1 VALUES(1)
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp2 LIKE tmp1
master-bin.000001 # Query # # use `test`; INSERT INTO tmp2 VALUES(1)
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1
master-bin.000001 # Query # # use `test`; INSERT INTO tmp3 VALUES(1)
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE tmp1
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE tmp2
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE tmp3
master-bin.000001 # Query # # ROLLBACK
########################################################################
# VERIFY ITEM 6
########################################################################
SET BINLOG_FORMAT=STATEMENT;
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
SET BINLOG_FORMAT=ROW;
DROP TEMPORARY TABLE tmp1;
BEGIN;
INSERT INTO tmp2 VALUES(1);
DROP TEMPORARY TABLE tmp2;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp3;
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp2 LIKE tmp1
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tmp1` /* generated by server */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tmp2` /* generated by server */
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tmp3` /* generated by server */
master-bin.000001 # Query # # COMMIT
SET BINLOG_FORMAT=STATEMENT;
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
SET BINLOG_FORMAT=ROW;
DROP TEMPORARY TABLE tmp1;
BEGIN;
INSERT INTO tmp2 VALUES(1);
DROP TEMPORARY TABLE tmp2;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp3;
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`; CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp2 LIKE tmp1
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tmp1` /* generated by server */
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tmp2` /* generated by server */
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `tmp3` /* generated by server */
master-bin.000001 # Query # # ROLLBACK
########################################################################
# VERIFY ITEM 7
########################################################################
SET BINLOG_FORMAT=STATEMENT;
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
CREATE TABLE t_myisam (f1 BIGINT) ENGINE = MyISAM;
CREATE TABLE t_innodb (f1 BIGINT) ENGINE = Innodb;
BEGIN;
INSERT INTO t_myisam VALUES(CONNECTION_ID());
INSERT INTO tmp1 VALUES(1);
INSERT INTO t_myisam VALUES(1);
INSERT INTO t_innodb VALUES(1);
INSERT INTO t_myisam VALUES(CONNECTION_ID());
INSERT INTO t_innodb VALUES(1);
COMMIT;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam
master-bin.000001 # Query # # use `test`; CREATE TABLE t_myisam (f1 BIGINT) ENGINE = MyISAM
master-bin.000001 # Query # # use `test`; CREATE TABLE t_innodb (f1 BIGINT) ENGINE = Innodb
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t_myisam VALUES(CONNECTION_ID())
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO tmp1 VALUES(1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t_myisam VALUES(1)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t_myisam VALUES(CONNECTION_ID())
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Xid # # COMMIT /* XID */
########################################################################
# VERIFY ITEM 8
########################################################################
SET BINLOG_FORMAT=MIXED;
BEGIN;
CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb;
INSERT INTO t_innodb VALUES(1);
INSERT INTO t_innodb VALUES(1);
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`; CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Query # # ROLLBACK
###################################################################################
# CHECK CONSISTENCY
###################################################################################
###################################################################################
# CLEAN UP
###################################################################################
DROP TABLE t_myisam;
DROP TABLE t_innodb;
###################################################################################
# This test cases evaluates the mixture of non-transactional and transcational
# tables. Specifically when drop temporary tables and create temporary tables
# are used.
###################################################################################
--source include/have_binlog_format_mixed.inc
--source include/master-slave.inc
--source include/have_innodb.inc
--source extra/rpl_tests/rpl_drop_create_temp_table.test
###################################################################################
# This test cases evaluates the mixture of non-transactional and transcational
# tables. Specifically when drop temporary tables and create temporary tables
# are used.
###################################################################################
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
--source include/have_innodb.inc
--source extra/rpl_tests/rpl_drop_create_temp_table.test
###################################################################################
# This test cases evaluates the mixture of non-transactional and transcational
# tables. Specifically when drop temporary tables and create temporary tables
# are used.
###################################################################################
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc
--source include/have_innodb.inc
--source extra/rpl_tests/rpl_drop_create_temp_table.test
--default-storage-engine=MyISAM
################################################################################
# BUG#51894 Replication failure with SBR on DROP TEMPORARY TABLE inside a
# transaction
# BUG#52616 Temp table prevents switch binlog format from STATEMENT to ROW
#
# This test verifies what follows:
#
# 1 - If the following statements are classified as unsafe:
# 1.1 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
# 1.2 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
#
# 2 - If the following statements are classified as safe:
# 1.7 - INSERT INTO t_innodb SELECT * FROM t_myisam_temp
# 1.8 - INSERT INTO t_myisam_temp SELECT * FROM t_innodb
#
# 3 - If we can switch from statement to row format.
#
# 4 - If statements that can manipulate a temporary table and do not cause an
# implicit commit are kept in the boundaries of an on-going transaction. For
# instance:
# 4.1 - CREATE TEMPORARY TABLE
# 4.2 - CREATE TEMPORARY TABLE LIKE
# 4.3 - CREATE TEMPORARY TABLE SELECT * FROM
# 4.4 - INSERT/UPDATE/DELETE (Note that only inserts are verified)
# 4.5 - INSERT INTO t_myisam SELECT * FROM t_myisam_temp
# 4.6 - INSERT INTO t_myisam_temp SELECT * FROM t_myisam
# 4.7 - INSERT INTO t_innodb SELECT * FROM t_myisam_temp
# 4.8 - INSERT INTO t_myisam_temp SELECT * FROM t_innodb
#
# 5 - If transactions that have a DROP TEMPORARY are always written to the
# binary log regardless of the mode and the outcome: commit or rollback.
#
# 6 - In particular, if the current statement logging format is set to row
# the CREATE TEMPORARY is not logged and the DROP TEMPORARY is extended with
# the IF EXISTS clause.
#
# 7 - It verifies if the CONNECTION_ID along with a non-transactional
# table is written outside the transaction boundaries and is not classified
# as unsafe. See BUG#53075.
#
# 8 - It verifies if OPTION_KEEP_LOG is set and thus forcing to write the
# trx-cache to the binary log when an rollback is issued and only trx-tables
# were updated. See BUG#53421.
################################################################################
source include/master-slave.inc;
source include/have_binlog_format_statement.inc;
source include/have_innodb.inc;
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
--echo ########################################################################
--echo # VERIFY ITEMS 1 and 2
--echo ########################################################################
--echo #
--echo # Create temporary tables to verify when statements involving temporary
--echo # tables are classified as safe or unsafe by printing out the warning
--echo # messages.
--echo #
connection master;
CREATE TABLE t_myisam(id int) engine= MyIsam;
INSERT INTO t_myisam VALUES(1);
CREATE TABLE t_innodb(id int) engine= Innodb;
INSERT INTO t_innodb VALUES(1);
CREATE TEMPORARY TABLE t_myisam_temp(id int) engine= MyIsam;
INSERT INTO t_myisam_temp VALUES(1);
CREATE TEMPORARY TABLE t_innodb_temp(id int) engine= Innodb;
INSERT INTO t_innodb_temp VALUES(1);
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
BEGIN;
INSERT INTO t_myisam SELECT * FROM t_myisam_temp;
INSERT INTO t_innodb SELECT * FROM t_myisam_temp;
INSERT INTO t_innodb SELECT * FROM t_innodb_temp;
ROLLBACK;
BEGIN;
INSERT INTO t_myisam SELECT * FROM t_innodb_temp;
INSERT INTO t_innodb SELECT * FROM t_myisam_temp;
INSERT INTO t_innodb SELECT * FROM t_innodb_temp;
ROLLBACK;
--echo ########################################################################
--echo # VERIFY ITEM 3
--echo ########################################################################
--echo #
--echo # When there is a temporary table we can switch between the mixed and
--echo # row formats. However, we cannot switch to the statement format.
--echo #
SET BINLOG_FORMAT=MIXED;
SET BINLOG_FORMAT=ROW;
SET BINLOG_FORMAT=MIXED;
--error ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
SET BINLOG_FORMAT=STATEMENT;
--echo #
--echo # When there is a temporary table we can switch between the mixed and
--echo # row formats. However, we cannot swith to the statement format.
--echo #
SET BINLOG_FORMAT=MIXED;
DROP TABLE t_myisam_temp, t_innodb_temp, t_myisam, t_innodb;
source include/show_binlog_events.inc;
--echo ########################################################################
--echo # VERIFY ITEMS 4 and 5
--echo ########################################################################
--echo #
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
BEGIN;
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
INSERT INTO tmp1 VALUES(1);
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
INSERT INTO tmp2 VALUES(1);
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp1;
DROP TEMPORARY TABLE tmp2;
DROP TEMPORARY TABLE tmp3;
COMMIT;
source include/show_binlog_events.inc;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
BEGIN;
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
INSERT INTO tmp1 VALUES(1);
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
INSERT INTO tmp2 VALUES(1);
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp1;
DROP TEMPORARY TABLE tmp2;
DROP TEMPORARY TABLE tmp3;
ROLLBACK;
source include/show_binlog_events.inc;
--echo ########################################################################
--echo # VERIFY ITEM 6
--echo ########################################################################
SET BINLOG_FORMAT=STATEMENT;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
SET BINLOG_FORMAT=ROW;
DROP TEMPORARY TABLE tmp1;
BEGIN;
INSERT INTO tmp2 VALUES(1);
DROP TEMPORARY TABLE tmp2;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp3;
COMMIT;
source include/show_binlog_events.inc;
SET BINLOG_FORMAT=STATEMENT;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
CREATE TEMPORARY TABLE tmp2 LIKE tmp1;
CREATE TEMPORARY TABLE tmp3 engine= MyIsam SELECT * FROM tmp1;
SET BINLOG_FORMAT=ROW;
DROP TEMPORARY TABLE tmp1;
BEGIN;
INSERT INTO tmp2 VALUES(1);
DROP TEMPORARY TABLE tmp2;
INSERT INTO tmp3 VALUES(1);
DROP TEMPORARY TABLE tmp3;
ROLLBACK;
source include/show_binlog_events.inc;
--echo ########################################################################
--echo # VERIFY ITEM 7
--echo ########################################################################
SET BINLOG_FORMAT=STATEMENT;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam;
CREATE TABLE t_myisam (f1 BIGINT) ENGINE = MyISAM;
CREATE TABLE t_innodb (f1 BIGINT) ENGINE = Innodb;
BEGIN;
INSERT INTO t_myisam VALUES(CONNECTION_ID());
INSERT INTO tmp1 VALUES(1);
INSERT INTO t_myisam VALUES(1);
INSERT INTO t_innodb VALUES(1);
INSERT INTO t_myisam VALUES(CONNECTION_ID());
INSERT INTO t_innodb VALUES(1);
COMMIT;
source include/show_binlog_events.inc;
--echo ########################################################################
--echo # VERIFY ITEM 8
--echo ########################################################################
#
# Before the patch for BUG#53421, nothing were written to the binary log on
# behalf of the transaction presented below:
#
SET BINLOG_FORMAT=MIXED;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
BEGIN;
CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb;
INSERT INTO t_innodb VALUES(1);
INSERT INTO t_innodb VALUES(1);
ROLLBACK;
source include/show_binlog_events.inc;
--echo ###################################################################################
--echo # CHECK CONSISTENCY
--echo ###################################################################################
sync_slave_with_master;
connection master;
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-nmt-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-nmt-slave.sql
--diff_files $MYSQLTEST_VARDIR/tmp/test-nmt-master.sql $MYSQLTEST_VARDIR/tmp/test-nmt-slave.sql
--echo ###################################################################################
--echo # CLEAN UP
--echo ###################################################################################
connection master;
DROP TABLE t_myisam;
DROP TABLE t_innodb;
sync_slave_with_master;
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