Commit 93e8ee4a authored by Aleksey Midenkov's avatar Aleksey Midenkov Committed by Sergei Golubchik

MDEV-14923 Assertion upon INSERT into locked versioned partitioned table

parent fbed4ca4
...@@ -407,6 +407,14 @@ Warning 4112 Versioned table `test`.`t1`: partition `p2` is full, add more HISTO ...@@ -407,6 +407,14 @@ Warning 4112 Versioned table `test`.`t1`: partition `p2` is full, add more HISTO
delete from t1 where x = 2; delete from t1 where x = 2;
Warnings: Warnings:
Warning 4112 Versioned table `test`.`t1`: partition `p2` is full, add more HISTORY partitions Warning 4112 Versioned table `test`.`t1`: partition `p2` is full, add more HISTORY partitions
# MDEV-14923 Assertion upon INSERT into locked versioned partitioned table
create or replace table t1 (x int) with system versioning
partition by system_time (partition p1 history, partition pn current);
lock table t1 write;
alter table t1 add partition (partition p1 history);
ERROR HY000: Duplicate partition name p1
insert into t1 values (1);
unlock tables;
# Test cleanup # Test cleanup
drop database test; drop database test;
create database test; create database test;
...@@ -351,6 +351,15 @@ alter table t1 partition by system_time limit 1 ( ...@@ -351,6 +351,15 @@ alter table t1 partition by system_time limit 1 (
delete from t1 where x = 1; delete from t1 where x = 1;
delete from t1 where x = 2; delete from t1 where x = 2;
--echo # MDEV-14923 Assertion upon INSERT into locked versioned partitioned table
create or replace table t1 (x int) with system versioning
partition by system_time (partition p1 history, partition pn current);
lock table t1 write;
--error ER_SAME_NAME_PARTITION
alter table t1 add partition (partition p1 history);
insert into t1 values (1);
unlock tables;
--echo # Test cleanup --echo # Test cleanup
drop database test; drop database test;
create database test; create database test;
...@@ -1940,7 +1940,7 @@ static void warn_if_dir_in_part_elem(THD *thd, partition_element *part_elem) ...@@ -1940,7 +1940,7 @@ static void warn_if_dir_in_part_elem(THD *thd, partition_element *part_elem)
bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
handler *file, HA_CREATE_INFO *info, handler *file, HA_CREATE_INFO *info,
bool add_or_reorg_part) partition_info *add_or_reorg_part)
{ {
handlerton *table_engine= default_engine_type; handlerton *table_engine= default_engine_type;
uint i, tot_partitions; uint i, tot_partitions;
...@@ -2174,6 +2174,24 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, ...@@ -2174,6 +2174,24 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
goto end; goto end;
} }
if (hist_parts > 1)
{
if (unlikely(vers_info->limit == 0 && vers_info->interval == 0))
{
push_warning_printf(thd,
Sql_condition::WARN_LEVEL_WARN,
WARN_VERS_PARAMETERS,
ER_THD(thd, WARN_VERS_PARAMETERS),
"no rotation condition for multiple HISTORY partitions.");
}
}
if (unlikely(now_parts > 1))
{
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias);
goto end;
}
DBUG_ASSERT(table_engine != partition_hton && DBUG_ASSERT(table_engine != partition_hton &&
default_engine_type == table_engine); default_engine_type == table_engine);
if (eng_type) if (eng_type)
...@@ -2188,6 +2206,9 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, ...@@ -2188,6 +2206,9 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
if (add_or_reorg_part) if (add_or_reorg_part)
{ {
if (unlikely(part_type == VERSIONING_PARTITION &&
vers_setup_expression(thd, add_or_reorg_part->partitions.elements)))
goto end;
if (unlikely(((part_type == RANGE_PARTITION || part_type == VERSIONING_PARTITION) && if (unlikely(((part_type == RANGE_PARTITION || part_type == VERSIONING_PARTITION) &&
check_range_constants(thd)) || check_range_constants(thd)) ||
(part_type == LIST_PARTITION && (part_type == LIST_PARTITION &&
...@@ -2195,22 +2216,6 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, ...@@ -2195,22 +2216,6 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
goto end; goto end;
} }
if (hist_parts > 1)
{
if (vers_info->limit == 0 && vers_info->interval == 0)
{
push_warning_printf(thd,
Sql_condition::WARN_LEVEL_WARN,
WARN_VERS_PARAMETERS,
ER_THD(thd, WARN_VERS_PARAMETERS),
"no rotation condition for multiple HISTORY partitions.");
}
}
if (now_parts > 1)
{
my_error(ER_VERS_WRONG_PARTS, MYF(0), info->alias);
goto end;
}
result= FALSE; result= FALSE;
end: end:
DBUG_RETURN(result); DBUG_RETURN(result);
......
...@@ -348,7 +348,7 @@ class partition_info : public Sql_alloc ...@@ -348,7 +348,7 @@ class partition_info : public Sql_alloc
bool check_list_constants(THD *thd); bool check_list_constants(THD *thd);
bool check_partition_info(THD *thd, handlerton **eng_type, bool check_partition_info(THD *thd, handlerton **eng_type,
handler *file, HA_CREATE_INFO *info, handler *file, HA_CREATE_INFO *info,
bool check_partition_function); partition_info *add_or_reorg_part= NULL);
void print_no_partition_found(TABLE *table, myf errflag); void print_no_partition_found(TABLE *table, myf errflag);
void print_debug(const char *str, uint*); void print_debug(const char *str, uint*);
Item* get_column_item(Item *item, Field *field); Item* get_column_item(Item *item, Field *field);
......
...@@ -5436,13 +5436,8 @@ the generated partition syntax in a correct manner. ...@@ -5436,13 +5436,8 @@ the generated partition syntax in a correct manner.
tab_part_info->use_default_num_subpartitions= FALSE; tab_part_info->use_default_num_subpartitions= FALSE;
} }
if (alter_info->flags & Alter_info::ALTER_ADD_PARTITION &&
tab_part_info->part_type == VERSIONING_PARTITION &&
tab_part_info->vers_setup_expression(thd, alt_part_info->partitions.elements))
goto err;
if (tab_part_info->check_partition_info(thd, (handlerton**)NULL, if (tab_part_info->check_partition_info(thd, (handlerton**)NULL,
table->file, 0, TRUE)) table->file, 0, alt_part_info))
{ {
goto err; goto err;
} }
......
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