diff --git a/mysql-test/suite/versioning/r/alter.result b/mysql-test/suite/versioning/r/alter.result index 882d15f7b88..3bb6f235056 100644 --- a/mysql-test/suite/versioning/r/alter.result +++ b/mysql-test/suite/versioning/r/alter.result @@ -77,9 +77,9 @@ show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t add column c int; @@ -87,10 +87,10 @@ show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t add column d int first; @@ -99,10 +99,10 @@ Table Create Table t CREATE TABLE `t` ( `d` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t add column e int after d; @@ -112,26 +112,22 @@ t CREATE TABLE `t` ( `d` int(11) DEFAULT NULL, `e` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING -alter table t add column f int after sys_trx_start; -ERROR HY000: Wrong parameters for `t`: Can not put new field after system versioning field -alter table t add column f int after sys_trx_end; -ERROR HY000: Wrong parameters for `t`: Can not put new field after system versioning field alter table t drop column a; show create table t; Table Create Table t CREATE TABLE `t` ( `d` int(11) DEFAULT NULL, `e` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, - `c` int(11) DEFAULT NULL, `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING alter table t drop column sys_trx_start; @@ -179,9 +175,9 @@ show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, `sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START, `sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING select * from t; @@ -339,9 +335,9 @@ show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING select * from t; @@ -366,9 +362,9 @@ show create table t; Table Create Table t CREATE TABLE `t` ( `a` int(11) DEFAULT NULL, - `b` int(11) DEFAULT NULL, `sys_trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START, `sys_trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END, + `b` int(11) DEFAULT NULL, PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING select * from t; diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index b6ffb41f33b..af297d2ba03 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -59,11 +59,6 @@ show create table t; alter table t add column e int after d; show create table t; ---error ER_VERS_WRONG_PARAMS -alter table t add column f int after sys_trx_start; ---error ER_VERS_WRONG_PARAMS -alter table t add column f int after sys_trx_end; - alter table t drop column a; show create table t; diff --git a/sql/handler.cc b/sql/handler.cc index 1d21d499dde..f2e74d936fd 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6874,31 +6874,11 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info, if (alter_info->create_list.elements) { - DBUG_ASSERT(share->fields > 2); - const char *after_this= share->field[share->fields - 3]->field_name; - List_iterator it(alter_info->create_list); + List_iterator_fast it(alter_info->create_list); while (Create_field *f= it++) { if (f->versioning == Column_definition::WITHOUT_VERSIONING) f->flags|= VERS_OPTIMIZED_UPDATE_FLAG; - - if (f->change) - continue; - - if (f->after) - { - if (is_trx_start(f->after) || is_trx_end(f->after)) - { - my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name, - "Can not put new field after system versioning field"); - return true; - } - - continue; - } - - // TODO: ALTER_COLUMN_ORDER? - f->after= after_this; } }