mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
BUG #16806: ALTER TABLE fails when creating new field not last in table
Moved some code to else path to avoid delete, create, delete, create scenarios. Fixed up the partition info object for some cases where we move from default partitioning in NDB to default partitioning using partitioning. sql/sql_partition.cc: Added a new parameter for partition default handling This is to avoid calling get_no_parts on tables not yet created. Ensure that we don't reuse the old part_info object for any other operation than CREATE TABLE after reading up the frm file. sql/sql_table.cc: Moved some code to else path to avoid delete, create, delete, create scenarios. Fixed up the partition info object for some cases where we move from default partitioning in NDB to default partitioning using partitioning.
This commit is contained in:
@ -2130,15 +2130,6 @@ bool mysql_create_table_internal(THD *thd,
|
||||
goto err;
|
||||
part_info->part_info_string= part_syntax_buf;
|
||||
part_info->part_info_len= syntax_len;
|
||||
if (create_info->db_type != engine_type)
|
||||
{
|
||||
delete file;
|
||||
if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, engine_type)))
|
||||
{
|
||||
mem_alloc_error(sizeof(handler));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
if ((!(engine_type->partition_flags &&
|
||||
engine_type->partition_flags() & HA_CAN_PARTITION)) ||
|
||||
create_info->db_type == &partition_hton)
|
||||
@ -2155,6 +2146,43 @@ bool mysql_create_table_internal(THD *thd,
|
||||
{
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
If we have default number of partitions or subpartitions we
|
||||
might require to set-up the part_info object such that it
|
||||
creates a proper .par file. The current part_info object is
|
||||
only used to create the frm-file and .par-file.
|
||||
*/
|
||||
if (part_info->use_default_no_partitions &&
|
||||
part_info->no_parts &&
|
||||
part_info->no_parts != file->get_default_no_partitions(0ULL))
|
||||
{
|
||||
uint i= 0;
|
||||
bool first= TRUE;
|
||||
List_iterator<partition_element> part_it(part_info->partitions);
|
||||
do
|
||||
{
|
||||
partition_element *part_elem= part_it++;
|
||||
if (!first)
|
||||
part_elem->part_state= PART_TO_BE_DROPPED;
|
||||
first= FALSE;
|
||||
} while (++i < part_info->partitions.elements);
|
||||
}
|
||||
else if (part_info->is_sub_partitioned() &&
|
||||
part_info->use_default_no_subpartitions &&
|
||||
part_info->no_subparts &&
|
||||
part_info->no_subparts != file->get_default_no_partitions(0ULL))
|
||||
{
|
||||
part_info->no_subparts= file->get_default_no_partitions(0ULL);
|
||||
}
|
||||
}
|
||||
else if (create_info->db_type != engine_type)
|
||||
{
|
||||
delete file;
|
||||
if (!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, engine_type)))
|
||||
{
|
||||
mem_alloc_error(sizeof(handler));
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user