MDEV-31618: Server crashes in process_i_s_table_temporary_tables/get_all_tables after alter in rename query

Any TMP_TABLE_SHARE must always have at least one TABLE instance.
So whenever a temporary TABLE that is marked for reopen is closed,
reopen it at once if its TMP_TABLE_SHARE list of tables becomes empty.
This commit is contained in:
Anel Husakovic 2023-08-08 10:58:44 +02:00 committed by Sergei Golubchik
commit 80439e6918
3 changed files with 96 additions and 2 deletions

View file

@ -1086,8 +1086,13 @@ TABLE *THD::find_temporary_table(const char *key, uint key_length,
{
share->all_tmp_tables.remove(table);
free_temporary_table(table);
it.rewind();
continue;
if (share->all_tmp_tables.is_empty())
table= open_temporary_table(share, share->table_name.str);
else
{
it.rewind();
continue;
}
}
result= table;
break;