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/wsrep_mysqld.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/wsrep_mysqld.cc')
-rw-r--r-- | sql/wsrep_mysqld.cc | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 54fb484bad0..9f7c3c9baa7 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1085,8 +1085,6 @@ static bool wsrep_prepare_keys_for_isolation(THD* thd, ka->keys= 0; ka->keys_len= 0; - extern TABLE* find_temporary_table(THD*, const TABLE_LIST*); - if (db || table) { TABLE_LIST tmp_table; @@ -1098,7 +1096,7 @@ static bool wsrep_prepare_keys_for_isolation(THD* thd, (table) ? table : "", MDL_INTENTION_EXCLUSIVE, MDL_STATEMENT); - if (!table || !find_temporary_table(thd, &tmp_table)) + if (!table || !thd->find_temporary_table(&tmp_table)) { if (!(ka->keys= (wsrep_key_t*)my_malloc(sizeof(wsrep_key_t), MYF(0)))) { @@ -1126,7 +1124,7 @@ static bool wsrep_prepare_keys_for_isolation(THD* thd, for (const TABLE_LIST* table= table_list; table; table= table->next_global) { - if (!find_temporary_table(thd, table)) + if (!thd->find_temporary_table(table)) { wsrep_key_t* tmp; tmp= (wsrep_key_t*)my_realloc( @@ -2443,26 +2441,13 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, HA_CREATE_INFO *create_info) { - TABLE *tmp_table; - bool is_tmp_table= FALSE; - - for (tmp_table= thd->temporary_tables; tmp_table; tmp_table=tmp_table->next) - { - if (!strcmp(src_table->db, tmp_table->s->db.str) && - !strcmp(src_table->table_name, tmp_table->s->table_name.str)) - { - is_tmp_table= TRUE; - break; - } - } if (create_info->tmp_table()) { - /* CREATE TEMPORARY TABLE LIKE must be skipped from replication */ WSREP_DEBUG("CREATE TEMPORARY TABLE LIKE... skipped replication\n %s", thd->query()); } - else if (!is_tmp_table) + else if (!(thd->find_temporary_table(src_table))) { /* this is straight CREATE TABLE LIKE... eith no tmp tables */ WSREP_TO_ISOLATION_BEGIN(table->db, table->table_name, NULL); @@ -2477,7 +2462,7 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, bzero((void*) &tbl, sizeof(tbl)); tbl.db= src_table->db; tbl.table_name= tbl.alias= src_table->table_name; - tbl.table= tmp_table; + tbl.table= src_table->table; char buf[2048]; String query(buf, sizeof(buf), system_charset_info); query.length(0); // Have to zero it since constructor doesn't |