Commit f8b62569 authored by Eugene Kosov's avatar Eugene Kosov

SQL: disallow ALTER CHANGE of system fields [fixes #213]

parent 909867d0
......@@ -495,6 +495,22 @@ alter table t without system versioning, algorithm=inplace;
select * from t;
a b
2 NULL
create or replace table t (
a int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
alter table t change column sys_trx_start asdf bigint unsigned;
ERROR HY000: Can not change system versioning field 'sys_trx_start'
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine myisam;
alter table t change column sys_trx_start asdf timestamp(6);
ERROR HY000: Can not change system versioning field 'sys_trx_start'
call verify_vtq;
No A B C D
1 1 1 1 1
......
......@@ -220,6 +220,24 @@ select * from t for system_time all;
alter table t without system versioning, algorithm=inplace;
select * from t;
create or replace table t (
a int,
sys_trx_start bigint(20) unsigned generated always as row start,
sys_trx_end bigint(20) unsigned generated always as row end,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine innodb;
--error ER_VERS_ALTER_SYSTEM_FIELD
alter table t change column sys_trx_start asdf bigint unsigned;
create or replace table t (
a int,
sys_trx_start timestamp(6) generated always as row start,
sys_trx_end timestamp(6) generated always as row end,
period for system_time(sys_trx_start, sys_trx_end)
) with system versioning engine myisam;
--error ER_VERS_ALTER_SYSTEM_FIELD
alter table t change column sys_trx_start asdf timestamp(6);
call verify_vtq;
drop table t;
......
......@@ -6869,6 +6869,12 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
{
if (f->versioning == Column_definition::WITHOUT_VERSIONING)
f->flags|= VERS_OPTIMIZED_UPDATE_FLAG;
if (f->change && (!strcmp(f->change, start) || !strcmp(f->change, end)))
{
my_error(ER_VERS_ALTER_SYSTEM_FIELD, MYF(0), f->change);
return true;
}
}
}
......
......@@ -7591,3 +7591,6 @@ ER_VERS_HISTORY_LOCK
ER_WRONG_TABLESPACE_NAME 42000
eng "Incorrect tablespace name `%-.192s`"
ER_VERS_ALTER_SYSTEM_FIELD
eng "Can not change system versioning field '%s'"
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