summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2010-10-05 14:57:51 +0200
committerMattias Jonsson <mattias.jonsson@oracle.com>2010-10-05 14:57:51 +0200
commitf3e2b3df18918550ee49021d0e16ea8cb5272085 (patch)
tree03fb3ff555edd8ed2c423b67d536331b522ee627 /sql/sql_partition.cc
parentfa97a2f1b7d61de6dbd767b560e44f1399c263bf (diff)
downloadmariadb-git-f3e2b3df18918550ee49021d0e16ea8cb5272085.tar.gz
Bug#55091: Server crashes on ADD PARTITION after a failed attempt
In case of failure in ALTER ... PARTITION under LOCK TABLE the server could crash, due to it had modified the locked table object, which was not reverted in case of failure, resulting in a bad table definition used after the failed command. Solved by always closing the LOCKED TABLE, even in case of error. Note: this is a 5.1-only fix, bug#56172 fixed it in 5.5+
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 76caa2b0c8d..7b0c47865d8 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -5935,6 +5935,12 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
if (lpt->thd->locked_tables)
{
/*
+ Close the table if open, to remove/destroy the already altered
+ table->part_info object, so that it is not reused.
+ */
+ if (lpt->table->db_stat)
+ abort_and_upgrade_lock_and_close_table(lpt);
+ /*
When we have the table locked, it is necessary to reopen the table
since all table objects were closed and removed as part of the
ALTER TABLE of partitioning structure.
@@ -6436,7 +6442,20 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
table, table_list, FALSE, NULL,
written_bin_log));
err:
- close_thread_tables(thd);
+ if (thd->locked_tables)
+ {
+ /*
+ table->part_info was altered in prep_alter_part_table and must be
+ destroyed and recreated, since otherwise it will be reused, since
+ we are under LOCK TABLE.
+ */
+ alter_partition_lock_handling(lpt);
+ }
+ else
+ {
+ /* Force the table to be closed to avoid reuse of the table->part_info */
+ close_thread_tables(thd);
+ }
DBUG_RETURN(TRUE);
}
#endif