1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-28 17:36:30 +03:00
Files
mariadb/mysql-test/suite/versioning/t/alter.test

245 lines
7.1 KiB
Plaintext

create table t(
a int
);
show create table t;
--error ER_VERS_WRONG_PARAMS
alter table t without system versioning;
--error ER_VERS_WRONG_PARAMS
alter table t with system versioning without system versioning;
alter table t with system versioning;
show create table t;
alter table t without system versioning;
show create table t;
--error ER_VERS_FIELD_WRONG_TYPE
alter table t
add column trx_start bigint(20) unsigned generated always as row start,
add column trx_end bigint(20) unsigned generated always as row end,
add period for system_time(trx_start, trx_end),
with system versioning;
--error ER_VERS_FIELD_WRONG_TYPE
alter table t
add column trx_start timestamp generated always as row start,
add column trx_end timestamp generated always as row end,
add period for system_time(trx_start, trx_end),
with system versioning;
--error ER_PARSE_ERROR
alter table t
add column trx_start timestamp(6) not null generated always as row start,
add column trx_end timestamp(6) not null generated always as row end,
add period for system_time(trx_start, trx_end),
with system versioning;
alter table t
add column trx_start timestamp(6) generated always as row start,
add column trx_end timestamp(6) generated always as row end,
add period for system_time(trx_start, trx_end),
with system versioning;
show create table t;
alter table t without system versioning;
show create table t;
alter table t with system versioning;
show create table t;
alter table t add column b int;
show create table t;
alter table t add column c int;
show create table t;
alter table t add column d int first;
show create table t;
alter table t add column e int after d;
show create table t;
alter table t drop column a;
show create table t;
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;
select * from t for system_time all;
alter table t drop column sys_trx_start;
alter table t drop column sys_trx_end;
select * from t for system_time all;
--error ER_CANT_DROP_FIELD_OR_KEY
alter table t drop column sys_trx_start;
--error ER_CANT_DROP_FIELD_OR_KEY
alter table t drop column sys_trx_end;
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;
select * from t for system_time all;
alter table t drop column sys_trx_start, drop column sys_trx_end;
select * from t for system_time all;
create or replace table t(
a int
);
insert into t values(1);
alter table t with system versioning;
show create table t;
insert into t values(2);
select * from t for system_time all;
select * from t;
update t set a=3 where a=1;
select * from t;
select * from t for system_time all;
select sys_trx_start from t where a=3 into @tm;
alter table t add column b int;
select @tm=sys_trx_start from t where a=3;
show create table t;
select * from t;
select * from t for system_time all;
alter table t without system versioning;
select * from t;
show create table t;
--error ER_VERS_WRONG_PARAMS
alter table t modify a int with system versioning;
--error ER_VERS_WRONG_PARAMS
alter table t modify a int with system versioning with system versioning;
--error ER_VERS_WRONG_PARAMS
alter table t modify a int with system versioning without system versioning;
alter table t with system versioning;
alter table t modify a int without system versioning;
show create table t;
alter table t modify a int with system versioning;
show create table t;
-- source suite/versioning/common.inc
create or replace table t(
a int
) engine=innodb;
insert into t values(1);
select * from t;
--error ER_VERS_FIELD_WRONG_TYPE
alter table t
add column trx_start timestamp(6) generated always as row start,
add column trx_end timestamp(6) generated always as row end,
add period for system_time(trx_start, trx_end),
with system versioning;
alter table t
add column trx_start bigint(20) unsigned generated always as row start,
add column trx_end bigint(20) unsigned generated always as row end,
add period for system_time(trx_start, trx_end),
with system versioning;
show create table t;
alter table t without system versioning;
alter table t with system versioning, algorithm=copy;
show create table t;
update t set a=2;
select * from t for system_time all;
alter table t add column b int, algorithm=copy;
show create table t;
select * from t;
alter table t drop column b, algorithm=copy;
show create table t;
select * from t for system_time all;
alter table t add column b int, algorithm=inplace;
show create table t;
select * from t;
alter table t drop column b, algorithm=inplace;
show create table t;
select * from t for system_time all;
alter table t without system versioning, algorithm=copy;
show create table t;
create or replace table t (a int) with system versioning engine=innodb;
insert into t values (1), (2), (3);
delete from t where a<3;
alter table t add b int auto_increment unique;
select * from t for system_time all;
insert into t values (4, NULL);
select * from t for system_time all;
create or replace table t (a int) with system versioning;
insert into t values (1), (2), (3);
delete from t where a<3;
alter table t add b int auto_increment unique;
select * from t for system_time all;
insert into t values (4, NULL);
select * from t for system_time all;
create or replace table t (a int) with system versioning engine=innodb;
insert into t values (1), (2), (3);
delete from t where a<3;
alter table t add b tinyint auto_increment unique;
select * from t for system_time all;
insert into t values (4, NULL);
select * from t for system_time all;
create or replace table t (a int) with system versioning;
insert into t values (1), (2), (3);
delete from t where a<3;
alter table t add b tinyint auto_increment unique;
select * from t for system_time all;
insert into t values (4, NULL);
select * from t for system_time all;
create or replace table t (a int) engine innodb;
insert into t values (1);
alter table t with system versioning, algorithm=inplace;
select * from t for system_time all;
update t set a=2;
select * from t for system_time all;
alter table t add column b int, algorithm=inplace;
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;
-- source suite/versioning/common_finish.inc