mirror of
https://github.com/MariaDB/server.git
synced 2025-12-07 17:42:39 +03:00
0.5: basic support for ALTER TABLE for InnoDB and other storage engines [closes #57]
This commit is contained in:
364
mysql-test/suite/versioning/r/alter.result
Normal file
364
mysql-test/suite/versioning/r/alter.result
Normal file
@@ -0,0 +1,364 @@
|
||||
create table t(
|
||||
a int
|
||||
);
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t without system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: table is not versioned
|
||||
alter table t with system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: Versioning specified more than once for the same table
|
||||
alter table t with system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`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`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
alter table t without system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
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 HY000: `trx_start` must be of type `TIMESTAMP(6)` for versioned table `t`
|
||||
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 HY000: `trx_start` must be of type `TIMESTAMP(6)` for versioned table `t`
|
||||
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;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'generated always as row start,
|
||||
add column trx_end timestamp(6) not null generate' at line 2
|
||||
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;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`trx_start` timestamp(6) NOT NULL GENERATED ALWAYS AS ROW START,
|
||||
`trx_end` timestamp(6) NOT NULL GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
alter table t without system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t with system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`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`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
alter table t add column b int;
|
||||
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,
|
||||
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;
|
||||
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,
|
||||
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;
|
||||
show create table t;
|
||||
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,
|
||||
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;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
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,
|
||||
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 versioned table `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 versioned table `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,
|
||||
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;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: Can not drop system versioning field
|
||||
alter table t drop column sys_trx_end;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: Can not drop system versioning field
|
||||
create or replace table t(
|
||||
a int
|
||||
);
|
||||
insert into t values(1);
|
||||
alter table t with system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`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`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
insert into t values(2);
|
||||
select * from t for system_time all;
|
||||
a
|
||||
1
|
||||
2
|
||||
select * from t;
|
||||
a
|
||||
1
|
||||
2
|
||||
update t set a=3 where a=1;
|
||||
select * from t;
|
||||
a
|
||||
3
|
||||
2
|
||||
select * from t for system_time all;
|
||||
a
|
||||
3
|
||||
2
|
||||
1
|
||||
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;
|
||||
@tm=sys_trx_start
|
||||
1
|
||||
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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
select * from t;
|
||||
a b
|
||||
3 NULL
|
||||
2 NULL
|
||||
select * from t for system_time all;
|
||||
a b
|
||||
3 NULL
|
||||
2 NULL
|
||||
1 NULL
|
||||
alter table t without system versioning;
|
||||
select * from t;
|
||||
a b
|
||||
3 NULL
|
||||
2 NULL
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t modify a int with system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: Can not change fields versioning mode in a non-versioned table
|
||||
alter table t modify a int with system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: Versioning specified more than once for the same field
|
||||
alter table t modify a int with system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: Versioning specified more than once for the same field
|
||||
alter table t with system versioning;
|
||||
alter table t modify a int without system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
|
||||
`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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
alter table t modify a int with system versioning;
|
||||
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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
set @@session.time_zone='+00:00';
|
||||
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
|
||||
create procedure if not exists verify_vtq()
|
||||
begin
|
||||
set @i= 0;
|
||||
select
|
||||
@i:= @i + 1 as No,
|
||||
trx_id > 0 as A,
|
||||
commit_id >= trx_id as B,
|
||||
begin_ts > '1-1-1 0:0:0' as C,
|
||||
commit_ts > begin_ts as D
|
||||
from information_schema.innodb_vtq
|
||||
where trx_id > @start_trx_id;
|
||||
select ifnull(max(trx_id), 0)
|
||||
into @start_trx_id
|
||||
from information_schema.innodb_vtq;
|
||||
end~~
|
||||
create or replace table t(
|
||||
a int
|
||||
) engine=innodb;
|
||||
insert into t values(1);
|
||||
select * from t;
|
||||
a
|
||||
1
|
||||
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;
|
||||
ERROR HY000: `trx_start` must be of type `BIGINT(20) UNSIGNED` for versioned table `t`
|
||||
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;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`trx_start` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
|
||||
`trx_end` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`trx_start`, `trx_end`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
alter table t without system versioning;
|
||||
alter table t with system versioning, algorithm=inplace;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
|
||||
alter table t with system versioning, algorithm=copy;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` 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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
update t set a=2;
|
||||
select * from t for system_time all;
|
||||
a
|
||||
2
|
||||
1
|
||||
alter table t add column b int, algorithm=copy;
|
||||
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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
select * from t;
|
||||
a b
|
||||
2 NULL
|
||||
1 NULL
|
||||
alter table t drop column b, algorithm=copy;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` 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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
select * from t for system_time all;
|
||||
a
|
||||
2
|
||||
1
|
||||
alter table t add column b int, algorithm=inplace;
|
||||
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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
select * from t;
|
||||
a b
|
||||
2 NULL
|
||||
1 NULL
|
||||
alter table t drop column b, algorithm=inplace;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` 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,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
select * from t for system_time all;
|
||||
a
|
||||
2
|
||||
1
|
||||
alter table t without system versioning, algorithm=inplace;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
|
||||
alter table t without system versioning, algorithm=copy;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
call verify_vtq;
|
||||
No A B C D
|
||||
1 1 1 1 1
|
||||
2 1 1 1 1
|
||||
3 1 1 1 1
|
||||
4 1 1 1 1
|
||||
5 1 1 1 1
|
||||
drop table t;
|
||||
drop procedure verify_vtq;
|
||||
@@ -88,35 +88,35 @@ Sys_start int generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: `Sys_start` must be of type `TIMESTAMP` for versioned table `t1`
|
||||
ERROR HY000: `Sys_start` must be of type `TIMESTAMP(6)` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end int generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: `Sys_end` must be of type `TIMESTAMP` for versioned table `t1`
|
||||
ERROR HY000: `Sys_end` must be of type `TIMESTAMP(6)` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end bigint generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning engine innodb;
|
||||
ERROR HY000: `Sys_start` must be of type `BIGINT UNSIGNED` for versioned table `t1`
|
||||
ERROR HY000: `Sys_start` must be of type `BIGINT(20) UNSIGNED` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start bigint generated always as row start,
|
||||
Sys_end bigint generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning engine innodb;
|
||||
ERROR HY000: `Sys_start` must be of type `BIGINT UNSIGNED` for versioned table `t1`
|
||||
ERROR HY000: `Sys_start` must be of type `BIGINT(20) UNSIGNED` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start bigint unsigned generated always as row start,
|
||||
Sys_end bigint generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning engine innodb;
|
||||
ERROR HY000: `Sys_end` must be of type `BIGINT UNSIGNED` for versioned table `t1`
|
||||
ERROR HY000: `Sys_end` must be of type `BIGINT(20) UNSIGNED` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
B int
|
||||
@@ -195,4 +195,32 @@ create or replace table t1 (
|
||||
A int without system versioning
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t1`: versioned fields missing
|
||||
create or replace table t1 (
|
||||
A int without system versioning with system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same field
|
||||
create or replace table t1 (
|
||||
A int with system versioning without system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same field
|
||||
create table t(
|
||||
a int
|
||||
) without system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t`: 'WITHOUT SYSTEM VERSIONING' is not allowed
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) without system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) with system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) with system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) without system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for versioned table `t1`: Versioning specified more than once for the same table
|
||||
drop table t1;
|
||||
|
||||
170
mysql-test/suite/versioning/t/alter.test
Normal file
170
mysql-test/suite/versioning/t/alter.test
Normal file
@@ -0,0 +1,170 @@
|
||||
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;
|
||||
|
||||
--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;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
alter table t drop column sys_trx_start;
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
alter table t drop column sys_trx_end;
|
||||
|
||||
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;
|
||||
|
||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
||||
alter table t with system versioning, algorithm=inplace;
|
||||
|
||||
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;
|
||||
|
||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED
|
||||
alter table t without system versioning, algorithm=inplace;
|
||||
|
||||
alter table t without system versioning, algorithm=copy;
|
||||
show create table t;
|
||||
|
||||
call verify_vtq;
|
||||
drop table t;
|
||||
drop procedure verify_vtq;
|
||||
@@ -169,4 +169,39 @@ create or replace table t1 (
|
||||
A int without system versioning
|
||||
) with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int without system versioning with system versioning
|
||||
);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int with system versioning without system versioning
|
||||
);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create table t(
|
||||
a int
|
||||
) without system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) without system versioning with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) with system versioning without system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) with system versioning with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
) without system versioning without system versioning;
|
||||
|
||||
drop table t1;
|
||||
|
||||
Reference in New Issue
Block a user