mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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
This commit is contained in:
@ -1741,8 +1741,7 @@ bool fix_partition_func(THD *thd, const char* name, TABLE *table,
|
|||||||
tables.db= db_name;
|
tables.db= db_name;
|
||||||
|
|
||||||
if (!is_create_table_ind ||
|
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,
|
if (partition_default_handling(table, part_info,
|
||||||
is_create_table_ind,
|
is_create_table_ind,
|
||||||
@ -3770,7 +3769,24 @@ bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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;
|
part_info= thd->work_part_info;
|
||||||
|
thd->free_list= NULL;
|
||||||
|
table->s->version= 0UL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
table->part_info= part_info;
|
table->part_info= part_info;
|
||||||
table->file->set_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 &&
|
if (part_info->use_default_no_partitions &&
|
||||||
part_info->no_parts &&
|
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;
|
uint i;
|
||||||
bool first= TRUE;
|
|
||||||
List_iterator<partition_element> part_it(part_info->partitions);
|
List_iterator<partition_element> part_it(part_info->partitions);
|
||||||
do
|
part_it++;
|
||||||
{
|
DBUG_ASSERT(thd->lex->sql_command != SQLCOM_CREATE_TABLE);
|
||||||
partition_element *part_elem= part_it++;
|
for (i= 1; i < part_info->partitions.elements; i++)
|
||||||
if (!first)
|
(part_it++)->part_state= PART_TO_BE_DROPPED;
|
||||||
part_elem->part_state= PART_TO_BE_DROPPED;
|
|
||||||
first= FALSE;
|
|
||||||
} while (++i < part_info->partitions.elements);
|
|
||||||
}
|
}
|
||||||
else if (part_info->is_sub_partitioned() &&
|
else if (part_info->is_sub_partitioned() &&
|
||||||
part_info->use_default_no_subpartitions &&
|
part_info->use_default_no_subpartitions &&
|
||||||
part_info->no_subparts &&
|
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);
|
part_info->no_subparts= file->get_default_no_partitions(0ULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user