Commit e414cbff authored by Nisha Gopalakrishnan's avatar Nisha Gopalakrishnan

BUG#20449914: HANDLE_FATAL_SIGNAL (SIG=11) IN

              FIELD_ITERATOR_TABLE::END_OF_FIELDS

Note: This a backport of the patch for bug#19894987
      to MySQL-5.5
parent f4ff086a
......@@ -1648,13 +1648,20 @@ bool close_temporary_tables(THD *thd)
if (!thd->temporary_tables)
DBUG_RETURN(FALSE);
/*
Ensure we don't have open HANDLERs for tables we are about to close.
This is necessary when close_temporary_tables() is called as part
of execution of BINLOG statement (e.g. for format description event).
*/
mysql_ha_rm_temporary_tables(thd);
if (!mysql_bin_log.is_open())
{
TABLE *tmp_next;
for (table= thd->temporary_tables; table; table= tmp_next)
for (TABLE *t= thd->temporary_tables; t; t= tmp_next)
{
tmp_next= table->next;
close_temporary(table, 1, 1);
tmp_next= t->next;
mysql_lock_remove(thd, thd->lock, t);
close_temporary(t, 1, 1);
}
thd->temporary_tables= 0;
DBUG_RETURN(FALSE);
......@@ -1744,6 +1751,7 @@ bool close_temporary_tables(THD *thd)
strlen(table->s->table_name.str));
s_query.append(',');
next= table->next;
mysql_lock_remove(thd, thd->lock, table);
close_temporary(table, 1, 1);
}
thd->clear_error();
......
/* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -1002,3 +1002,49 @@ void mysql_ha_set_explicit_lock_duration(THD *thd)
DBUG_VOID_RETURN;
}
/**
Remove temporary tables from the HANDLER's hash table. The reason
for having a separate function, rather than calling
mysql_ha_rm_tables() is that it is not always feasible (e.g. in
close_temporary_tables) to obtain a TABLE_LIST containing the
temporary tables.
@See close_temporary_tables
@param thd Thread identifier.
*/
void mysql_ha_rm_temporary_tables(THD *thd)
{
DBUG_ENTER("mysql_ha_rm_temporary_tables");
TABLE_LIST *tmp_handler_tables= NULL;
for (uint i= 0; i < thd->handler_tables_hash.records; i++)
{
TABLE_LIST *handler_table= reinterpret_cast<TABLE_LIST*>
(my_hash_element(&thd->handler_tables_hash, i));
if (handler_table->table && handler_table->table->s->tmp_table)
{
handler_table->next_local= tmp_handler_tables;
tmp_handler_tables= handler_table;
}
}
while (tmp_handler_tables)
{
TABLE_LIST *nl= tmp_handler_tables->next_local;
mysql_ha_close_table(thd, tmp_handler_tables);
my_hash_delete(&thd->handler_tables_hash, (uchar*) tmp_handler_tables);
tmp_handler_tables= nl;
}
/*
Mark MDL_context as no longer breaking protocol if we have
closed last HANDLER.
*/
if (thd->handler_tables_hash.records == 0)
{
thd->mdl_context.set_needs_thr_lock_abort(FALSE);
}
DBUG_VOID_RETURN;
}
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -32,5 +32,6 @@ void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables);
void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables);
void mysql_ha_cleanup(THD *thd);
void mysql_ha_set_explicit_lock_duration(THD *thd);
void mysql_ha_rm_temporary_tables(THD *thd);
#endif /* SQL_HANDLER_INCLUDED */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment