diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-06-10 16:58:08 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-06-10 18:39:43 -0400 |
commit | e2087c6e8da5d22cea2fb5a05408f48b1a3e5b35 (patch) | |
tree | 906c32bcd4e02edde054e08c4d5e020bbae27852 /sql/temporary_tables.cc | |
parent | 7305be2f7e724e5e62961606794beab199d79045 (diff) | |
download | mariadb-git-e2087c6e8da5d22cea2fb5a05408f48b1a3e5b35.tar.gz |
MDEV-5535: Cannot reopen temporary table
Temporary table being created by outer statement
should not be visible to inner statement. And if
inner statement creates a table with same name.
The whole statement should fail with
ER_TABLE_EXISTS_ERROR.
Implemented by temporarily de-linking the TABLE_SHARE
being created by outer statement so that it remains
hidden to the inner statement.
Diffstat (limited to 'sql/temporary_tables.cc')
-rw-r--r-- | sql/temporary_tables.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index c23bbd4ff19..c40ea511aac 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -802,6 +802,50 @@ void THD::mark_tmp_table_as_free_for_reuse(TABLE *table) /** + Remove and return the specified table's TABLE_SHARE from the temporary + tables list. + + @param table [IN] Table + + @return TMP_TABLE_SHARE of the specified table. +*/ +TMP_TABLE_SHARE *THD::save_tmp_table_share(TABLE *table) +{ + DBUG_ENTER("THD::save_tmp_table_share"); + + TMP_TABLE_SHARE *share; + + lock_temporary_tables(); + DBUG_ASSERT(temporary_tables); + share= tmp_table_share(table); + temporary_tables->remove(share); + unlock_temporary_tables(); + + DBUG_RETURN(share); +} + + +/** + Add the specified TMP_TABLE_SHARE to the temporary tables list. + + @param share [IN] Table share + + @return void +*/ +void THD::restore_tmp_table_share(TMP_TABLE_SHARE *share) +{ + DBUG_ENTER("THD::restore_tmp_table_share"); + + lock_temporary_tables(); + DBUG_ASSERT(temporary_tables); + temporary_tables->push_front(share); + unlock_temporary_tables(); + + DBUG_VOID_RETURN; +} + + +/** If its a replication slave, report whether slave temporary tables exist (Relay_log_info::save_temporary_tables) or report about THD temporary table (Open_tables_state::temporary_tables) otherwise. |