Commit 647a3881 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-16130 wrong error message adding AS ROW START to versioned table

parent 75ba5c81
...@@ -80,13 +80,17 @@ t CREATE TABLE `t` ( ...@@ -80,13 +80,17 @@ t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t add column trx_start timestamp(6) as row start; alter table t add column trx_start timestamp(6) as row start;
ERROR HY000: Table `t` is not system-versioned ERROR HY000: Duplicate ROW START column `trx_start`
alter table t add system versioning; alter table t add system versioning;
show create table t; show create table t;
Table Create Table Table Create Table
t CREATE TABLE `t` ( t CREATE TABLE `t` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
alter table t add column trx_start timestamp(6) as row start;
ERROR HY000: Duplicate ROW START column `trx_start`
alter table t modify a int as row start;
ERROR HY000: Duplicate ROW START column `a`
alter table t add column b int; alter table t add column b int;
show create table t; show create table t;
Table Create Table Table Create Table
...@@ -531,7 +535,7 @@ use test; ...@@ -531,7 +535,7 @@ use test;
# MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column
create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning;
alter table t1 modify s timestamp(6) as row start; alter table t1 modify s timestamp(6) as row start;
ERROR HY000: Can not change system versioning field `s` ERROR HY000: Duplicate ROW START column `s`
# ignore CHECK for historical rows # ignore CHECK for historical rows
create or replace table t (a int) with system versioning; create or replace table t (a int) with system versioning;
insert into t values (0), (1); insert into t values (0), (1);
......
...@@ -68,12 +68,17 @@ select row_start from t; ...@@ -68,12 +68,17 @@ select row_start from t;
alter table t drop system versioning; alter table t drop system versioning;
show create table t; show create table t;
--error ER_VERS_NOT_VERSIONED --error ER_VERS_DUPLICATE_ROW_START_END
alter table t add column trx_start timestamp(6) as row start; alter table t add column trx_start timestamp(6) as row start;
alter table t add system versioning; alter table t add system versioning;
show create table t; show create table t;
--error ER_VERS_DUPLICATE_ROW_START_END
alter table t add column trx_start timestamp(6) as row start;
--error ER_VERS_DUPLICATE_ROW_START_END
alter table t modify a int as row start;
alter table t add column b int; alter table t add column b int;
show create table t; show create table t;
...@@ -457,7 +462,7 @@ use test; ...@@ -457,7 +462,7 @@ use test;
--echo # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column --echo # MDEV-15956 Strange ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN upon ALTER on versioning column
create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning; create or replace table t1 (i int, j int as (i), s timestamp(6) as row start, e timestamp(6) as row end, period for system_time(s,e)) with system versioning;
--error ER_VERS_ALTER_SYSTEM_FIELD --error ER_VERS_DUPLICATE_ROW_START_END
alter table t1 modify s timestamp(6) as row start; alter table t1 modify s timestamp(6) as row start;
--echo # ignore CHECK for historical rows --echo # ignore CHECK for historical rows
......
...@@ -7301,13 +7301,15 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, ...@@ -7301,13 +7301,15 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info,
return false; return false;
} }
if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING))
{ {
List_iterator_fast<Create_field> it(alter_info->create_list); List_iterator_fast<Create_field> it(alter_info->create_list);
while (Create_field *f= it++) while (Create_field *f= it++)
{ {
if (f->change.length && f->flags & VERS_SYSTEM_FIELD) if (f->flags & VERS_SYSTEM_FIELD)
{ {
my_error(ER_VERS_ALTER_SYSTEM_FIELD, MYF(0), f->field_name.str); my_error(ER_VERS_DUPLICATE_ROW_START_END, MYF(0),
f->flags & VERS_SYS_START_FLAG ? "START" : "END", f->field_name.str);
return true; return true;
} }
} }
......
...@@ -8159,12 +8159,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, ...@@ -8159,12 +8159,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
alter_ctx->datetime_field= def; alter_ctx->datetime_field= def;
alter_ctx->error_if_not_empty= TRUE; alter_ctx->error_if_not_empty= TRUE;
} }
if (def->flags & VERS_SYSTEM_FIELD &&
!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING))
{
my_error(ER_VERS_NOT_VERSIONED, MYF(0), table->s->table_name.str);
goto err;
}
if (!def->after.str) if (!def->after.str)
new_create_list.push_back(def, thd->mem_root); new_create_list.push_back(def, thd->mem_root);
else else
......
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