From 1409b9d7ae030a80aec13939f008c50653b4a32a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Jan 2005 11:17:01 +0100 Subject: [PATCH 1/2] bug#7761 - ndb does not autocommit during alter table sql/sql_table.cc: Turn off transactions before locking (as locking will need to know) --- sql/sql_table.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 43f466282b1..52f178946c4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3447,6 +3447,19 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (!(copy= new Copy_field[to->fields])) DBUG_RETURN(-1); /* purecov: inspected */ + /* + Turn off recovery logging since rollback of an alter table is to + delete the new table so there is no need to log the changes to it. + + This needs to be done before external_lock + */ + error= ha_enable_transaction(thd,FALSE); + if (error) + { + DBUG_RETURN(-1); + } + + if (to->file->external_lock(thd, F_WRLCK)) DBUG_RETURN(-1); from->file->info(HA_STATUS_VARIABLE); @@ -3502,17 +3515,6 @@ copy_data_between_tables(TABLE *from,TABLE *to, goto err; }; - /* - Turn off recovery logging since rollback of an alter table is to - delete the new table so there is no need to log the changes to it. - */ - error= ha_enable_transaction(thd,FALSE); - if (error) - { - error= 1; - goto err; - } - /* Handler must be told explicitly to retrieve all columns, because this function does not set field->query_id in the columns to the current query id */ From 815f62223aa9892b19916724ca76514cb1d899b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Jan 2005 11:33:08 +0100 Subject: [PATCH 2/2] bug#7761 - ndb does not autcommit - postreview fixes sql/sql_table.cc: Move ha_enable to before new Copy, to ensure no memory is leaked --- sql/sql_table.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 52f178946c4..f9f635081cb 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3444,21 +3444,18 @@ copy_data_between_tables(TABLE *from,TABLE *to, ulong save_sql_mode; DBUG_ENTER("copy_data_between_tables"); - if (!(copy= new Copy_field[to->fields])) - DBUG_RETURN(-1); /* purecov: inspected */ - /* Turn off recovery logging since rollback of an alter table is to delete the new table so there is no need to log the changes to it. This needs to be done before external_lock */ - error= ha_enable_transaction(thd,FALSE); + error= ha_enable_transaction(thd, FALSE); if (error) - { DBUG_RETURN(-1); - } - + + if (!(copy= new Copy_field[to->fields])) + DBUG_RETURN(-1); /* purecov: inspected */ if (to->file->external_lock(thd, F_WRLCK)) DBUG_RETURN(-1);