Skip to content

Commit 04bed58

Browse files
committed
SQL: partitioning CREATE, ALTER fixes
MDEV-14688 Assertion `tab_part_info->part_type == LIST_PARTITION' failed in prep_alter_part_table MDEV-14673 Assertion `part_elem->type() == partition_element::AS_OF_NOW' failed in check_partition_info
1 parent b0d9dc4 commit 04bed58

File tree

5 files changed

+50
-21
lines changed

5 files changed

+50
-21
lines changed

mysql-test/suite/versioning/r/partition.result

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ x
3232
create or replace table t1 (i int) engine=DEFAULT_ENGINE with system versioning partition by hash(i);
3333
alter table t1 engine=NON_DEFAULT_ENGINE;
3434
ERROR HY000: Not allowed for system-versioned `test`.`t1`. Change to/from native system versioning engine is prohibited.
35-
# Check server-level partitioning
36-
## create errors
35+
## CREATE TABLE
3736
create or replace table t1 (x int)
3837
partition by system_time (
3938
partition p0 history,
@@ -49,34 +48,40 @@ create or replace table t1 (x int)
4948
with system versioning
5049
partition by system_time (
5150
partition p0 current);
52-
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
51+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
5352
create or replace table t1 (x int)
5453
with system versioning
5554
partition by system_time (
5655
partition p0 current,
5756
partition p1 current);
58-
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
57+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
5958
create or replace table t1 (x int)
6059
with system versioning
6160
partition by system_time (
6261
partition p0 history,
6362
partition p1 history);
64-
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
63+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
6564
create or replace table t1 (x int)
6665
with system versioning
6766
partition by system_time (
6867
partition pn current,
6968
partition p0 history);
70-
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
69+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
70+
create or replace table t1 (x int)
71+
with system versioning
72+
partition by system_time (
73+
partition p0,
74+
partition pn current);
75+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
7176
create or replace table t1 (x int)
7277
with system versioning
7378
partition by system_time (
7479
partition p0 history,
7580
partition pn current);
76-
## alter table
81+
## ALTER TABLE
7782
alter table t1 add partition (
7883
partition p1 current);
79-
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
84+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
8085
alter table t1 add partition (
8186
partition p1 history);
8287
Warnings:
@@ -95,10 +100,10 @@ t1 CREATE TABLE `t1` (
95100
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
96101
insert into t1 values (1), (2);
97102
alter table t1 drop partition pn;
98-
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
103+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
99104
alter table t1 drop partition p1;
100105
alter table t1 drop partition p0;
101-
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one HISTORY and exactly one last CURRENT
106+
ERROR HY000: Wrong partitions for `t1`: must have at least one HISTORY and exactly one last CURRENT
102107
select x from t1;
103108
x
104109
1
@@ -110,7 +115,10 @@ partition by system_time limit 1 (
110115
partition p0 history,
111116
partition pn current);
112117
alter table t1 change x big int;
113-
## insert, delete, update
118+
create or replace table t1 (i int) engine myisam partition by hash(i) partitions 2;
119+
alter table t1 add partition (partition px history);
120+
ERROR HY000: Wrong partitioning type, expected type: `SYSTEM_TIME`
121+
## INSERT, UPDATE, DELETE
114122
create or replace table t1 (x int)
115123
with system versioning
116124
partition by system_time (

mysql-test/suite/versioning/t/partition.test

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ eval create or replace table t1 (i int) engine=$default_engine with system versi
2727
--error ER_VERS_ALTER_ENGINE_PROHIBITED
2828
eval alter table t1 engine=$non_default_engine;
2929

30-
--echo # Check server-level partitioning
31-
--echo ## create errors
30+
31+
--echo ## CREATE TABLE
32+
3233
--error ER_VERS_ENGINE_UNSUPPORTED
3334
create or replace table t1 (x int)
3435
partition by system_time (
@@ -69,13 +70,22 @@ partition by system_time (
6970
partition pn current,
7071
partition p0 history);
7172

73+
--error ER_VERS_WRONG_PARTS
74+
create or replace table t1 (x int)
75+
with system versioning
76+
partition by system_time (
77+
partition p0,
78+
partition pn current);
79+
7280
create or replace table t1 (x int)
7381
with system versioning
7482
partition by system_time (
7583
partition p0 history,
7684
partition pn current);
7785

78-
--echo ## alter table
86+
87+
--echo ## ALTER TABLE
88+
7989
--error ER_VERS_WRONG_PARTS
8090
alter table t1 add partition (
8191
partition p1 current);
@@ -104,7 +114,13 @@ partition by system_time limit 1 (
104114
partition pn current);
105115
alter table t1 change x big int;
106116

107-
--echo ## insert, delete, update
117+
create or replace table t1 (i int) engine myisam partition by hash(i) partitions 2;
118+
--error ER_PARTITION_WRONG_TYPE
119+
alter table t1 add partition (partition px history);
120+
121+
122+
--echo ## INSERT, UPDATE, DELETE
123+
108124
create or replace table t1 (x int)
109125
with system versioning
110126
partition by system_time (

sql/share/errmsg-utf8.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7834,7 +7834,7 @@ ER_NON_VERSIONED_FIELD_IN_VERSIONED_QUERY
78347834
eng "Attempt to read non-temporal field %`s in historical query"
78357835

78367836
ER_PARTITION_WRONG_TYPE
7837-
eng "Wrong partition type, expected type: %`s"
7837+
eng "Wrong partitioning type, expected type: %`s"
78387838

78397839
WARN_VERS_PART_FULL
78407840
eng "Versioned table %`s.%`s: partition %`s is full, add more HISTORY partitions"
@@ -7897,7 +7897,7 @@ ER_PART_WRONG_VALUE
78977897
eng "Wrong parameters for partitioned %`s: wrong value for '%s'"
78987898

78997899
ER_VERS_WRONG_PARTS
7900-
eng "Wrong partitions consistency for %`s: must have at least one HISTORY and exactly one last CURRENT"
7900+
eng "Wrong partitions for %`s: must have at least one HISTORY and exactly one last CURRENT"
79017901

79027902
ER_VERS_HISTORY_LOCK
79037903
eng "Versioned SELECT write-locking of history rows"

sql/sql_partition.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4737,6 +4737,10 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
47374737
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
47384738
"LIST", "IN");
47394739
}
4740+
else if (thd->work_part_info->part_type == VERSIONING_PARTITION)
4741+
{
4742+
my_error(ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME");
4743+
}
47404744
else if (tab_part_info->part_type == RANGE_PARTITION)
47414745
{
47424746
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),

sql/sql_yacc.yy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5430,6 +5430,9 @@ opt_part_values:
54305430
if (part_info->part_type == LIST_PARTITION)
54315431
my_yyabort_error((ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
54325432
"LIST", "IN"));
5433+
if (part_info->part_type == VERSIONING_PARTITION)
5434+
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0),
5435+
lex->create_last_non_select_table->table_name));
54335436
}
54345437
else
54355438
part_info->part_type= HASH_PARTITION;
@@ -5470,8 +5473,7 @@ opt_part_values:
54705473
if (! lex->is_partition_management())
54715474
{
54725475
if (part_info->part_type != VERSIONING_PARTITION)
5473-
my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0),
5474-
"BY SYSTEM_TIME"));
5476+
my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME"));
54755477
}
54765478
else
54775479
{
@@ -5497,8 +5499,7 @@ opt_part_values:
54975499
if (! lex->is_partition_management())
54985500
{
54995501
if (part_info->part_type != VERSIONING_PARTITION)
5500-
my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0),
5501-
"BY SYSTEM_TIME"));
5502+
my_yyabort_error((ER_PARTITION_WRONG_TYPE, MYF(0), "SYSTEM_TIME"));
55025503
}
55035504
else
55045505
{

0 commit comments

Comments
 (0)