mariadb/mysql-test/suite/rpl/t/rpl_reopen_temp_table.test
Nirbhay Choubey 7305be2f7e MDEV-5535: Cannot reopen temporary table
mysqld maintains a list of TABLE objects for all temporary
tables created within a session in THD. Here each table is
represented by a TABLE object.

A query referencing a particular temporary table for more
than once, however, failed with ER_CANT_REOPEN_TABLE error
because a TABLE_SHARE was allocate together with the TABLE,
so temporary tables always had only one TABLE per TABLE_SHARE.

This patch lift this restriction by separating TABLE and
TABLE_SHARE objects and storing TABLE_SHAREs for temporary
tables in a list in THD, and TABLEs in a list within their
respective TABLE_SHAREs.
2016-06-10 18:39:43 -04:00

43 lines
980 B
Text

--source include/have_innodb.inc
--source include/master-slave.inc
# Clean up old slave's binlogs (see rpl_temporary.test for explanation).
save_master_pos;
connection slave;
sync_with_master;
reset master;
--echo #
--echo # MDEV-5535: Cannot reopen temporary table
--echo #
connection master;
--disable_query_log
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
--enable_query_log
disable_warnings;
DROP TABLE IF EXISTS t1, t2, t3;
enable_warnings;
CREATE TEMPORARY TABLE t1(c1 INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
CREATE TEMPORARY TABLE t2 SELECT A.c1 a, B.c1 b FROM t1 AS A, t1 AS B;
CREATE TABLE t3 SELECT * FROM t2;
SELECT COUNT(*) = 5 FROM t1;
SELECT COUNT(*) = 25 FROM t2;
SELECT COUNT(*) = 25 FROM t3;
sync_slave_with_master;
SELECT COUNT(*) = 25 FROM t3;
connection master;
DROP TABLE t1, t2, t3;
sync_slave_with_master;
--source include/rpl_end.inc