mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-04 04:46:15 +01:00 
			
		
		
		
	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.
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			657 B
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			657 B
		
	
	
	
		
			Text
		
	
	
	
	
	
include/master-slave.inc
 | 
						|
[connection master]
 | 
						|
connection slave;
 | 
						|
reset master;
 | 
						|
#
 | 
						|
# MDEV-5535: Cannot reopen temporary table
 | 
						|
#
 | 
						|
connection master;
 | 
						|
DROP TABLE IF EXISTS t1, t2, t3;
 | 
						|
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;
 | 
						|
COUNT(*) = 5
 | 
						|
1
 | 
						|
SELECT COUNT(*) = 25 FROM t2;
 | 
						|
COUNT(*) = 25
 | 
						|
1
 | 
						|
SELECT COUNT(*) = 25 FROM t3;
 | 
						|
COUNT(*) = 25
 | 
						|
1
 | 
						|
connection slave;
 | 
						|
SELECT COUNT(*) = 25 FROM t3;
 | 
						|
COUNT(*) = 25
 | 
						|
1
 | 
						|
connection master;
 | 
						|
DROP TABLE t1, t2, t3;
 | 
						|
connection slave;
 | 
						|
include/rpl_end.inc
 |