diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2018-05-23 22:15:04 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2019-10-10 00:20:34 +0300 |
commit | 647a38818a44012c22128e0e1cad96739aa8a5c2 (patch) | |
tree | 72efc690af89c2e910720e9bec3bb59a9822e3f8 | |
parent | 75ba5c815d0272b35a28225d495a4a03fe63d29f (diff) | |
download | mariadb-git-647a38818a44012c22128e0e1cad96739aa8a5c2.tar.gz |
MDEV-16130 wrong error message adding AS ROW START to versioned table
-rw-r--r-- | mysql-test/suite/versioning/r/alter.result | 8 | ||||
-rw-r--r-- | mysql-test/suite/versioning/t/alter.test | 9 | ||||
-rw-r--r-- | sql/handler.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 6 |
4 files changed, 17 insertions, 12 deletions
diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index a453617d3b3..532412e3574 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -80,13 +80,17 @@ t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 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; show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL ) 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; show create table t; Table Create Table @@ -531,7 +535,7 @@ use test; # 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; 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 create or replace table t (a int) with system versioning; insert into t values (0), (1); diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index c8275a5d3f4..ff33f2cf95b 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -68,12 +68,17 @@ select row_start from t; alter table t drop system versioning; 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 system versioning; 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; show create table t; @@ -457,7 +462,7 @@ use test; --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; ---error ER_VERS_ALTER_SYSTEM_FIELD +--error ER_VERS_DUPLICATE_ROW_START_END alter table t1 modify s timestamp(6) as row start; --echo # ignore CHECK for historical rows diff --git a/sql/handler.cc b/sql/handler.cc index 587ec633245..1494060e24d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7301,13 +7301,15 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, return false; } + if (!(alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING)) { List_iterator_fast<Create_field> it(alter_info->create_list); 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; } } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b4cf6f61f60..c2c26222a82 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -8159,12 +8159,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, alter_ctx->datetime_field= def; 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) new_create_list.push_back(def, thd->mem_root); else |