# ==== Purpose ====
#
# Test that temporary tables are correctly replicated after switching to ROW format in MIX mode.
# This test case will test the condition of the bug#40013.
# The test step is:
#   1: create temp table on connection 'master';
#   2: switch to ROW format using 'INSERT INTO t1 VALUES (UUID());'
#   3: disconnect 'master' and connect to a new connection 'master1';
#   4: sync to slave and check the number of temp tables on slave.
#

source include/master-slave.inc;
source include/have_binlog_format_mixed.inc;

--echo ==== Initialize ====

--echo [on master]
--connection master

CREATE TABLE t1 (a CHAR(48));
CREATE TEMPORARY TABLE t1_tmp1(a INT);
INSERT INTO t1 VALUES (UUID());

--echo [on slave]
sync_slave_with_master;

--echo ==== Verify results on slave ====
SHOW STATUS LIKE "Slave_open_temp_tables";

--echo [on master]
--connection master

disconnect master;
--connection master1

--echo [on slave]
sync_slave_with_master;

--echo ==== Verify results on slave ====
SHOW STATUS LIKE "Slave_open_temp_tables";

--echo ==== Clean up ====

--echo [on master]
--connection master1
DROP TABLE t1;

--echo [on slave]
sync_slave_with_master;
