Smart ALTER TABLE dropping non-existing tmp table (Re: CREATE INDEX is not committed?)
On Thu, Jun 21, 2007 at 12:42:17PM +0300, Marko Mäkelä wrote:
> Monty, > > On Thu, Jun 21, 2007 at 12:53:51AM +0300, Michael Widenius wrote: > > Marko> Another thing: mysql_alter_table() is trying to drop a temporary table > > Marko> it did not create: > > > > Marko> err1: > > Marko> if (new_table) > > Marko> { > > Marko> /* close_temporary_table() frees the new_table pointer. */ > > Marko> close_temporary_table(thd, new_table, 1, 1); > > Marko> } > > Marko> else > > Marko> VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP)); > > > > Marko> I believe that the else branch should be removed altogether, because > > Marko> new_table==NULL should mean that handler::add_index() was called and > > Marko> no temporary table was created. > > > > The above branch is also taken if we created a temporary table but was > > not able to open it. In this case we have to remove it. > > Okay, I didn't analyze this thoroughly, but our modified InnoDB (which > implements ha_innobase::add_index()) is complaining that MySQL is deleting > a non-existing table. I didn't check if MySQL asked InnoDB to create > that table, but I strongly doubt it. I will look at this after my vacation, > sometime in August.
The problem appears to be that a .frm file is created for the temporary
table, but the table is not created in the storage engine, because
create_info->frm_only == true. However, here in mysql_alter_table()
MySQL will attempt to remove the table also from the storage engine:
err1:
if (new_table)
{
/* close_temporary_table() frees the new_table pointer. */
close_temporary_table(thd, new_table, 1, 1);
}
else
VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP));
Proposed fix: add the parameter bool frm_only to quick_rm_table.
Marko
--
MySQL Internals Mailing List
For list archives:
http://lists.mysql.com/internals
To unsubscribe:
http://lists.mysql.com/internals?unsub=lists@pantek.com
Received on Mon Aug 13 06:36:50 2007
This archive was generated by hypermail 2.1.8
: Sun Oct 07 2007 - 07:59:12 EDT
|