Skip to content

Commit

Permalink
MDEV-22112 Assertion `tab_part_info->part_type == RANGE_PARTITION || …
Browse files Browse the repository at this point in the history
…tab_part_info->part_type == LIST_PARTITION' failed in prep_alter_part_table

Incorrect syntax for SYSTEM_TIME partition. work_part_info is detected
as HASH partition. We cannot add partition of different type neither
we cannot reorganize SYSTEM_TIME into/from different type
partitioning.

The sidefix for version until 10.5 corrects the message:
"For LIST partitions each partition must be defined"
  • Loading branch information
midenok committed Jun 4, 2020
1 parent 8300f63 commit 05693cf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
10 changes: 10 additions & 0 deletions mysql-test/suite/versioning/r/partition.result
Expand Up @@ -673,4 +673,14 @@ delete from v1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
drop view v1;
drop table t1;
#
# MDEV-22112 Assertion `tab_part_info->part_type == RANGE_PARTITION || tab_part_info->part_type == LIST_PARTITION' failed in prep_alter_part_table
#
create table t1 (a int) with system versioning partition by system_time;
ERROR HY000: For SYSTEM_TIME partitions each partition must be defined
create table t1 (a int) with system versioning partition by system_time
(partition p1 history, partition pn current);
alter table t1 add partition (partition p2);
ERROR HY000: Wrong partitioning type, expected type: `SYSTEM_TIME`
drop table t1;
# End of 10.3 tests
17 changes: 17 additions & 0 deletions mysql-test/suite/versioning/t/partition.test
Expand Up @@ -635,6 +635,23 @@ delete from v1;
drop view v1;
drop table t1;

--echo #
--echo # MDEV-22112 Assertion `tab_part_info->part_type == RANGE_PARTITION || tab_part_info->part_type == LIST_PARTITION' failed in prep_alter_part_table
--echo #

### TMP: Please remove this error check in 10.5 (MDEV-19903)
--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
create table t1 (a int) with system versioning partition by system_time;
### TMP end

create table t1 (a int) with system versioning partition by system_time
(partition p1 history, partition pn current);
--error ER_PARTITION_WRONG_TYPE
alter table t1 add partition (partition p2);

# Cleanup
drop table t1;

--echo # End of 10.3 tests

--source suite/versioning/common_finish.inc
2 changes: 2 additions & 0 deletions sql/partition_info.cc
Expand Up @@ -451,6 +451,8 @@ bool partition_info::set_up_default_partitions(THD *thd, handler *file,
const char *error_string;
if (part_type == RANGE_PARTITION)
error_string= "RANGE";
else if (part_type == VERSIONING_PARTITION)
error_string= "SYSTEM_TIME";
else
error_string= "LIST";
my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), error_string);
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_partition.cc
Expand Up @@ -5135,7 +5135,8 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"LIST", "IN");
}
else if (thd->work_part_info->part_type == VERSIONING_PARTITION)
else if (thd->work_part_info->part_type == VERSIONING_PARTITION ||
tab_part_info->part_type == VERSIONING_PARTITION)
{
my_error(ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME");
}
Expand Down

0 comments on commit 05693cf

Please sign in to comment.