mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
#include "tztime.h" // MYSQL_TIME <-> my_time_t
|
||||
#include "sql_acl.h" // NO_ACCESS,
|
||||
// acl_getroot_no_password
|
||||
#include "sql_base.h" // close_temporary_tables
|
||||
#include "sql_base.h"
|
||||
#include "sql_handler.h" // mysql_ha_cleanup
|
||||
#include "rpl_rli.h"
|
||||
#include "rpl_filter.h"
|
||||
@ -883,7 +883,8 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
|
||||
main_da(0, false, false),
|
||||
m_stmt_da(&main_da),
|
||||
tdc_hash_pins(0),
|
||||
xid_hash_pins(0)
|
||||
xid_hash_pins(0),
|
||||
m_tmp_tables_locked(false)
|
||||
#ifdef WITH_WSREP
|
||||
,
|
||||
wsrep_applier(is_wsrep_applier),
|
||||
@ -1586,7 +1587,7 @@ void THD::cleanup(void)
|
||||
locked_tables_list.unlock_locked_tables(this);
|
||||
|
||||
delete_dynamic(&user_var_events);
|
||||
close_temporary_tables(this);
|
||||
close_temporary_tables();
|
||||
|
||||
transaction.xid_state.xa_state= XA_NOTR;
|
||||
trans_rollback(this);
|
||||
@ -4319,7 +4320,8 @@ void THD::restore_backup_open_tables_state(Open_tables_backup *backup)
|
||||
Before we will throw away current open tables state we want
|
||||
to be sure that it was properly cleaned up.
|
||||
*/
|
||||
DBUG_ASSERT(open_tables == 0 && temporary_tables == 0 &&
|
||||
DBUG_ASSERT(open_tables == 0 &&
|
||||
temporary_tables == 0 &&
|
||||
derived_tables == 0 &&
|
||||
lock == 0 &&
|
||||
locked_tables_mode == LTM_NONE &&
|
||||
@ -6982,24 +6984,6 @@ THD::signal_wakeup_ready()
|
||||
}
|
||||
|
||||
|
||||
void THD::rgi_lock_temporary_tables()
|
||||
{
|
||||
mysql_mutex_lock(&rgi_slave->rli->data_lock);
|
||||
temporary_tables= rgi_slave->rli->save_temporary_tables;
|
||||
}
|
||||
|
||||
void THD::rgi_unlock_temporary_tables()
|
||||
{
|
||||
rgi_slave->rli->save_temporary_tables= temporary_tables;
|
||||
mysql_mutex_unlock(&rgi_slave->rli->data_lock);
|
||||
}
|
||||
|
||||
bool THD::rgi_have_temporary_tables()
|
||||
{
|
||||
return rgi_slave->rli->save_temporary_tables != 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wait_for_commit::reinit()
|
||||
{
|
||||
|
Reference in New Issue
Block a user