Commit fb1d0319 authored by unknown's avatar unknown

BUG#16806: ALTER TABLE with new field in before position fails

Review fixes


sql/sql_partition.cc:
  Review fixes
sql/sql_table.cc:
  Review fixes
parent 0ab09307
......@@ -1741,8 +1741,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table,
tables.db= db_name;
if (!is_create_table_ind ||
(is_create_table_ind &&
thd->lex->sql_command != SQLCOM_CREATE_TABLE))
thd->lex->sql_command != SQLCOM_CREATE_TABLE)
{
if (partition_default_handling(table, part_info,
is_create_table_ind,
......@@ -3770,7 +3769,24 @@ bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
}
}
else
{
/*
When we come here we are doing a create table. In this case we
have already done some preparatory work on the old part_info
object. We don't really need this new partition_info object.
Thus we go back to the old partition info object.
We need to free any memory objects allocated on item_free_list
by the parser since we are keeping the old info from the first
parser call in CREATE TABLE.
We'll ensure that this object isn't put into table cache also
just to ensure we don't get into strange situations with the
item objects.
*/
free_items(thd->free_list);
part_info= thd->work_part_info;
thd->free_list= NULL;
table->s->version= 0UL;
}
}
table->part_info= part_info;
table->file->set_part_info(part_info);
......
......@@ -2154,24 +2154,22 @@ bool mysql_create_table_internal(THD *thd,
*/
if (part_info->use_default_no_partitions &&
part_info->no_parts &&
part_info->no_parts != file->get_default_no_partitions(0ULL))
(int)part_info->no_parts != file->get_default_no_partitions(0ULL))
{
uint i= 0;
bool first= TRUE;
uint i;
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);
part_it++;
DBUG_ASSERT(thd->lex->sql_command != SQLCOM_CREATE_TABLE);
for (i= 1; i < part_info->partitions.elements; i++)
(part_it++)->part_state= PART_TO_BE_DROPPED;
}
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))
(int)part_info->no_subparts !=
file->get_default_no_partitions(0ULL))
{
DBUG_ASSERT(thd->lex->sql_command != SQLCOM_CREATE_TABLE);
part_info->no_subparts= file->get_default_no_partitions(0ULL);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment