1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Bug#13593865 - 64037: CRASH IN HA_PARTITION::CREATE_HANDLERS ON

ALTER TABLE AFTER DROP PARTITION
Bug#13608188 - 64038: CRASH IN HANDLER::HA_THD ON ALTER TABLE AFTER
                      REPAIR NON-EXISTING PARTITION

Backport of bug#13357766 from -trunk to -5.5.

The state of some partitions was not reset on failure, leading
to invalid states of partitions in consequent statements.

Fixed by reverting back to original state for all partitions
if not all partition names was resolved.

Also adding extra security by forcing tables to be reopened
in case of error in mysql_alter_table.

(There is also removal of \r at the end of some lines.)
This commit is contained in:
Mattias Jonsson
2012-02-02 12:47:17 +01:00
parent 225f0cd53d
commit 7ebeb1433e
6 changed files with 124 additions and 57 deletions

View File

@@ -4469,11 +4469,20 @@ error:
}
/*
Sets which partitions to be used in the command
/**
Sets which partitions to be used in the command.
@param alter_info Alter_info pointer holding partition names and flags.
@param tab_part_info partition_info holding all partitions.
@param part_state Which state to set for the named partitions.
@return Operation status
@retval false Success
@retval true Failure
*/
uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
enum partition_state part_state)
bool set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
enum partition_state part_state)
{
uint part_count= 0;
uint num_parts_found= 0;
@@ -4499,7 +4508,21 @@ uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
else
part_elem->part_state= PART_NORMAL;
} while (++part_count < tab_part_info->num_parts);
return num_parts_found;
if (num_parts_found != alter_info->partition_names.elements &&
!(alter_info->flags & ALTER_ALL_PARTITION))
{
/* Not all given partitions found, revert and return failure */
part_it.rewind();
part_count= 0;
do
{
partition_element *part_elem= part_it++;
part_elem->part_state= PART_NORMAL;
} while (++part_count < tab_part_info->num_parts);
return true;
}
return false;
}
@@ -5018,11 +5041,7 @@ that are reorganised.
}
else if (alter_info->flags & ALTER_REBUILD_PARTITION)
{
uint num_parts_found;
uint num_parts_opt= alter_info->partition_names.elements;
num_parts_found= set_part_state(alter_info, tab_part_info, PART_CHANGED);
if (num_parts_found != num_parts_opt &&
(!(alter_info->flags & ALTER_ALL_PARTITION)))
if (set_part_state(alter_info, tab_part_info, PART_CHANGED))
{
my_error(ER_DROP_PARTITION_NON_EXISTENT, MYF(0), "REBUILD");
goto err;