summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorNisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com>2014-06-24 10:15:53 +0530
committerNisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com>2014-06-24 10:15:53 +0530
commit24756e8e3fc4461d2818ebfdd5929e171c625a0a (patch)
treec5d3e66d0017459f3b4bba37b940fd67ca644888 /sql/sql_partition.cc
parent01fd5d0d0e527ed5da5d6d2dcf91f74162bb4ad1 (diff)
downloadmariadb-git-24756e8e3fc4461d2818ebfdd5929e171c625a0a.tar.gz
BUG#18618561: FAILED ALTER TABLE ENGINE CHANGE WITH PARTITIONS
CORRUPTS FRM Analysis: --------- ALTER TABLE on a partitioned table resulted in the wrong engine being written into the table's FRM file and displayed in SHOW CREATE TABLE. The prep_alter_part_table() modifies the partition_info object for TABLE instance representing the old version of table. If the ALTER TABLE ENGINE statement fails, the partition_info object for the TABLE contains the altered storage engine name. The SHOW CREATE TABLE uses the TABLE object to display the table information, hence displays incorrect storage engine for the table. Also a subsequent successful ALTER TABLE operation will write the incorrect engine information into the FRM file. Fix: --- A copy of the partition_info object is created before modification so that any changes would not cause the the original partition_info object to be modified if the ALTER TABLE fails.(Backported part of the code provided as fix for bug#14156617 in mysql-5.6.6).
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index d7d362dbdfb..c615ee96d03 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, 2014, 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
@@ -5573,7 +5573,9 @@ the generated partition syntax in a correct manner.
There was no partitioning before and no partitioning defined.
Obviously no work needed.
*/
- if (table->part_info)
+ partition_info *tab_part_info= table->part_info;
+
+ if (tab_part_info)
{
if (alter_info->flags & ALTER_REMOVE_PARTITIONING)
{
@@ -5581,7 +5583,7 @@ the generated partition syntax in a correct manner.
if (!(create_info->used_fields & HA_CREATE_USED_ENGINE))
{
DBUG_PRINT("info", ("No explicit engine used"));
- create_info->db_type= table->part_info->default_engine_type;
+ create_info->db_type= tab_part_info->default_engine_type;
}
DBUG_PRINT("info", ("New engine type: %s",
ha_resolve_storage_engine_name(create_info->db_type)));
@@ -5593,16 +5595,20 @@ the generated partition syntax in a correct manner.
/*
Retain partitioning but possibly with a new storage engine
beneath.
+
+ Create a copy of TABLE::part_info to be able to modify it freely.
*/
- thd->work_part_info= table->part_info;
+ if (!(tab_part_info= tab_part_info->get_clone()))
+ DBUG_RETURN(TRUE);
+ thd->work_part_info= tab_part_info;
if (create_info->used_fields & HA_CREATE_USED_ENGINE &&
- create_info->db_type != table->part_info->default_engine_type)
+ create_info->db_type != tab_part_info->default_engine_type)
{
/*
Make sure change of engine happens to all partitions.
*/
DBUG_PRINT("info", ("partition changed"));
- if (table->part_info->is_auto_partitioned)
+ if (tab_part_info->is_auto_partitioned)
{
/*
If the user originally didn't specify partitioning to be
@@ -5630,7 +5636,7 @@ the generated partition syntax in a correct manner.
Need to cater for engine types that can handle partition without
using the partition handler.
*/
- if (part_info != table->part_info)
+ if (part_info != tab_part_info)
{
if (part_info->fix_parser_data(thd))
{
@@ -5658,8 +5664,8 @@ the generated partition syntax in a correct manner.
part_info->default_engine_type= create_info->db_type;
else
{
- if (table->part_info)
- part_info->default_engine_type= table->part_info->default_engine_type;
+ if (tab_part_info)
+ part_info->default_engine_type= tab_part_info->default_engine_type;
else
part_info->default_engine_type= create_info->db_type;
}