diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-06-10 16:19:59 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-06-10 18:39:43 -0400 |
commit | 7305be2f7e724e5e62961606794beab199d79045 (patch) | |
tree | 403bd132ee82a16946e3208f5d535de6e5945b80 /sql/sql_insert.cc | |
parent | 547511153fb1f59688752aa5524ae411b5960c92 (diff) | |
download | mariadb-git-7305be2f7e724e5e62961606794beab199d79045.tar.gz |
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.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9f63216af88..13ff5a74b0b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4078,7 +4078,12 @@ static TABLE *create_table_from_items(THD *thd, } else { - if (open_temporary_table(thd, create_table)) + /* + The pointer to the newly created temporary table has been stored in + table->create_info. + */ + create_table->table= create_info->table; + if (!create_table->table) { /* This shouldn't happen as creation of temporary table should make @@ -4087,7 +4092,6 @@ static TABLE *create_table_from_items(THD *thd, */ DBUG_ASSERT(0); } - DBUG_ASSERT(create_table->table == create_info->table); } } else @@ -4461,6 +4465,7 @@ void select_create::abort_result_set() if (table) { bool tmp_table= table->s->tmp_table; + table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); table->auto_increment_field_not_null= FALSE; |