Created
June 9, 2016 17:03
-
-
Save nirbhayc/caff5e60d0d860c9ffa65b0cb7f6a402 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mysql-test/r/reopen_temp_table.result b/mysql-test/r/reopen_temp_table.result | |
index 6d85703..08affaa 100644 | |
--- a/mysql-test/r/reopen_temp_table.result | |
+++ b/mysql-test/r/reopen_temp_table.result | |
@@ -151,5 +151,18 @@ SELECT COUNT(*) FROM t4; | |
COUNT(*) | |
4 | |
DROP TABLE t4; | |
+CREATE TABLE t5 (a INT) ENGINE=INNODB; | |
+CREATE TEMPORARY TABLE t6 (a INT) ENGINE=INNODB; | |
+INSERT INTO t5 VALUES(1), (2); | |
+INSERT INTO t6 SELECT * FROM t5; | |
+INSERT INTO t6 SELECT * FROM t6; | |
+INSERT INTO t5 SELECT * FROM t6; | |
+SELECT COUNT(*)=6 FROM t5; | |
+COUNT(*)=6 | |
+1 | |
+SELECT COUNT(*)=4 FROM t6; | |
+COUNT(*)=4 | |
+1 | |
+DROP TABLE t5, t6; | |
# Cleanup | |
DROP DATABASE temp_db; | |
diff --git a/mysql-test/t/reopen_temp_table.test b/mysql-test/t/reopen_temp_table.test | |
index 1daca03..98de983 100644 | |
--- a/mysql-test/t/reopen_temp_table.test | |
+++ b/mysql-test/t/reopen_temp_table.test | |
@@ -149,5 +149,15 @@ INSERT INTO t4 SELECT * FROM t4; | |
SELECT COUNT(*) FROM t4; | |
DROP TABLE t4; | |
+CREATE TABLE t5 (a INT) ENGINE=INNODB; | |
+CREATE TEMPORARY TABLE t6 (a INT) ENGINE=INNODB; | |
+INSERT INTO t5 VALUES(1), (2); | |
+INSERT INTO t6 SELECT * FROM t5; | |
+INSERT INTO t6 SELECT * FROM t6; | |
+INSERT INTO t5 SELECT * FROM t6; | |
+SELECT COUNT(*)=6 FROM t5; | |
+SELECT COUNT(*)=4 FROM t6; | |
+DROP TABLE t5, t6; | |
+ | |
--echo # Cleanup | |
DROP DATABASE temp_db; | |
diff --git a/sql/sql_base.cc b/sql/sql_base.cc | |
index 663d8e8..432a378 100644 | |
--- a/sql/sql_base.cc | |
+++ b/sql/sql_base.cc | |
@@ -972,8 +972,7 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, | |
{ | |
for (; table; table= table->*link ) | |
{ | |
- if ((table->table == 0 || table->table->s->tmp_table == NO_TMP_TABLE) && | |
- strcmp(table->db, db_name) == 0 && | |
+ if (strcmp(table->db, db_name) == 0 && | |
strcmp(table->table_name, table_name) == 0) | |
break; | |
} | |
@@ -1038,9 +1037,6 @@ TABLE_LIST* find_dup_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, | |
/* All MyISAMMRG children are plain MyISAM tables. */ | |
DBUG_ASSERT(table->table->file->ht->db_type != DB_TYPE_MRG_MYISAM); | |
- /* temporary table is always unique */ | |
- if (table->table && table->table->s->tmp_table != NO_TMP_TABLE) | |
- DBUG_RETURN(0); | |
table= table->find_underlying_table(table->table); | |
/* | |
as far as we have table->table we have to find real TABLE_LIST of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment