mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-5535: Cannot reopen temporary table
Since a query can now refer to the same temporary table multiple times, find_dup_table()/find_table_in_list() have been updated to also consider this new possibility.
This commit is contained in:
parent
e2087c6e8d
commit
b2ae32aafd
3 changed files with 24 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -910,8 +910,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;
|
||||
}
|
||||
|
@ -976,9 +975,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
|
||||
|
|
Loading…
Reference in a new issue