1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

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).
This commit is contained in:
Nisha Gopalakrishnan
2014-06-24 10:15:53 +05:30
parent 7141ae8561
commit 0e947e88b1
3 changed files with 59 additions and 9 deletions

View File

@@ -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;
}