mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
@@ -15,3 +15,4 @@
|
||||
--innodb-sys-tables
|
||||
--innodb-sys-virtual
|
||||
--innodb-vtq
|
||||
--vers-hide=implicit
|
||||
|
@@ -1,226 +1,281 @@
|
||||
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 function if not exists default_engine()
|
||||
returns varchar(255)
|
||||
deterministic
|
||||
begin
|
||||
declare e varchar(255);
|
||||
select lower(engine) from information_schema.engines where support='DEFAULT' into e;
|
||||
return e;
|
||||
end~~
|
||||
create function if not exists sys_datatype()
|
||||
returns varchar(255)
|
||||
deterministic
|
||||
begin
|
||||
if default_engine() = 'innodb' then
|
||||
return 'bigint unsigned';
|
||||
elseif default_engine() = 'myisam' then
|
||||
return 'timestamp(6)';
|
||||
end if;
|
||||
return NULL;
|
||||
end~~
|
||||
create function if not exists sys_commit_ts(sys_field varchar(255))
|
||||
returns varchar(255)
|
||||
deterministic
|
||||
begin
|
||||
if default_engine() = 'innodb' then
|
||||
return concat('vtq_commit_ts(', sys_field, ')');
|
||||
elseif default_engine() = 'myisam' then
|
||||
return sys_field;
|
||||
end if;
|
||||
return NULL;
|
||||
end~~
|
||||
create procedure if not exists innodb_verify_vtq(recs int)
|
||||
begin
|
||||
declare i int default 1;
|
||||
if default_engine() = 'innodb' then
|
||||
call verify_vtq;
|
||||
elseif default_engine() = 'myisam' then
|
||||
create temporary table tmp (No int, A bool, B bool, C bool, D bool);
|
||||
while i <= recs do
|
||||
insert into tmp values (i, 1, 1, 1, 1);
|
||||
set i= i + 1;
|
||||
end while;
|
||||
select * from tmp;
|
||||
drop table tmp;
|
||||
end if;
|
||||
end~~
|
||||
drop table if exists t1;
|
||||
create table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
x1 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`XNo` int(10) unsigned DEFAULT NULL,
|
||||
`Sys_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
`Sys_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
`x1` int(10) unsigned DEFAULT NULL,
|
||||
`Sys_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`Sys_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
# Implicit fields test
|
||||
create or replace table t1 (
|
||||
XNo int unsigned
|
||||
x2 int unsigned
|
||||
) with system versioning;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`XNo` int(10) unsigned DEFAULT NULL,
|
||||
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
`x2` int(10) unsigned DEFAULT NULL,
|
||||
`sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_start2 timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
x3 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_start2 SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW START'
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end2 timestamp(6) generated always as row end,
|
||||
x4 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end2 SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
Sys_end2 timestamp(6) generated always as row end,
|
||||
x5 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
Sys_end2 SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
x6 int unsigned,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: 'GENERATED AS ROW START' column missing
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
Sys_end2 timestamp(6) generated always as row end,
|
||||
x7 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
Sys_end2 SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
x8 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (sys_insert, sys_remove)
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
x9 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
x10 int unsigned,
|
||||
Sys_start SYS_TRX_TYPE generated always as row start,
|
||||
Sys_end SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (Sys_start, Sys_start)
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' columns must be different
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start int generated always as row start,
|
||||
x11 int unsigned,
|
||||
Sys_start bigint unsigned 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(6)` for versioned table `t1`
|
||||
Got one of the listed errors
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
x12 int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end int generated always as row end,
|
||||
Sys_end bigint unsigned 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(6)` for versioned table `t1`
|
||||
Got one of the listed errors
|
||||
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(20) UNSIGNED` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
x13 int unsigned,
|
||||
Sys_start bigint generated always as row start,
|
||||
Sys_end bigint generated always as row end,
|
||||
Sys_end bigint unsigned 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(20) UNSIGNED` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
x14 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(20) UNSIGNED` for versioned table `t1`
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A1 int with system versioning,
|
||||
B int
|
||||
);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`A` int(11) DEFAULT NULL,
|
||||
`A1` int(11) DEFAULT NULL,
|
||||
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
|
||||
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
`sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A2 int with system versioning,
|
||||
B int
|
||||
) with system versioning;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`A` int(11) DEFAULT NULL,
|
||||
`A2` 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,
|
||||
`sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t1 (
|
||||
A int,
|
||||
A3 int,
|
||||
B int without system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
|
||||
create or replace table t1 (
|
||||
A int,
|
||||
A4 int,
|
||||
B int without system versioning
|
||||
) with system versioning;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`A` int(11) DEFAULT NULL,
|
||||
`A4` int(11) DEFAULT NULL,
|
||||
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
|
||||
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
`sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A5 int with system versioning,
|
||||
B int without system versioning
|
||||
);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`A` int(11) DEFAULT NULL,
|
||||
`A5` int(11) DEFAULT NULL,
|
||||
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
|
||||
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
`sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A6 int with system versioning,
|
||||
B int without system versioning
|
||||
) with system versioning;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`A` int(11) DEFAULT NULL,
|
||||
`A6` int(11) DEFAULT NULL,
|
||||
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
|
||||
`sys_trx_start` timestamp(6) GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` timestamp(6) GENERATED ALWAYS AS ROW END,
|
||||
`sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t1 (
|
||||
A int without system versioning
|
||||
A7 int without system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
|
||||
create or replace table t1 (
|
||||
A int without system versioning
|
||||
A8 int without system versioning
|
||||
) with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: versioned fields missing
|
||||
ERROR HY000: Wrong parameters for `t1`: no columns defined with system versioning!
|
||||
create or replace table t1 (
|
||||
A int without system versioning with system versioning
|
||||
A9 int without system versioning with system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
|
||||
create or replace table t1 (
|
||||
A int with system versioning without system versioning
|
||||
A10 int with system versioning without system versioning
|
||||
);
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
|
||||
create table t(
|
||||
a int
|
||||
a11 int
|
||||
) without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t`: 'WITHOUT SYSTEM VERSIONING' is not allowed
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A12 int
|
||||
) without system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A13 int
|
||||
) with system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A14 int
|
||||
) with system versioning with system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A15 int
|
||||
) without system versioning without system versioning;
|
||||
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
@@ -231,9 +286,53 @@ show create table tt1;
|
||||
Table Create Table
|
||||
tt1 CREATE TABLE `tt1` (
|
||||
`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,
|
||||
`sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
drop table tt1;
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
create or replace table t2 (y int);
|
||||
create or replace table t3 select * from t1 for system_time all, t2;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`x` int(11) DEFAULT NULL,
|
||||
`y` int(11) DEFAULT NULL
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1
|
||||
create or replace table t2 (
|
||||
y int,
|
||||
st SYS_TRX_TYPE generated always as row start,
|
||||
en SYS_TRX_TYPE generated always as row end,
|
||||
period for system_time (st, en)
|
||||
) with system versioning;
|
||||
create or replace table t3 select * from t2;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
`y` int(11) DEFAULT NULL,
|
||||
`st` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
|
||||
`en` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
|
||||
PERIOD FOR SYSTEM_TIME (`st`, `en`)
|
||||
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t3 select x, y, t1.sys_trx_start, t2.en from t1, t2;
|
||||
ERROR HY000: Wrong parameters for `t3`: system fields selected from different tables
|
||||
insert into t2 values (1), (2);
|
||||
delete from t2 where y = 2;
|
||||
create or replace table t3 select * from t2 for system_time all;
|
||||
select st, en from t2 where y = 1 into @st, @en;
|
||||
select y from t2 for system_time all where st = @st and en = @en;
|
||||
y
|
||||
1
|
||||
select st, en from t2 for system_time all where y = 2 into @st, @en;
|
||||
select y from t2 for system_time all where st = @st and en = @en;
|
||||
y
|
||||
2
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
drop procedure verify_vtq;
|
||||
drop procedure innodb_verify_vtq;
|
||||
drop function default_engine;
|
||||
drop function sys_commit_ts;
|
||||
drop function sys_datatype;
|
||||
|
88
mysql-test/suite/versioning/r/sysvars.result
Normal file
88
mysql-test/suite/versioning/r/sysvars.result
Normal file
@@ -0,0 +1,88 @@
|
||||
create table t (a int) with system versioning;
|
||||
insert into t values (1);
|
||||
update t set a= 2;
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
show variables where variable_name = "temporal_current_timestamp";
|
||||
Variable_name Value
|
||||
temporal_current_timestamp now
|
||||
set global temporal_current_timestamp = '2031-1-1 0:0:0';
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
set global temporal_current_timestamp = '2011-1-1 0:0:0';
|
||||
select * from t;
|
||||
a
|
||||
set global temporal_current_timestamp = 'all';
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
1
|
||||
show variables where Variable_name like "temporal_current_timestamp%";
|
||||
Variable_name Value
|
||||
temporal_current_timestamp all
|
||||
create view vt as select * from t;
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
1
|
||||
drop view vt;
|
||||
select * from (select * from t) as tt;
|
||||
a
|
||||
2
|
||||
1
|
||||
set session temporal_current_timestamp = 'now';
|
||||
ERROR HY000: Variable 'temporal_current_timestamp' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
set global temporal_current_timestamp = 'now';
|
||||
show variables where variable_name = "vers_hide";
|
||||
Variable_name Value
|
||||
vers_hide IMPLICIT
|
||||
select * from t for system_time all;
|
||||
a
|
||||
2
|
||||
1
|
||||
set global vers_hide= AUTO;
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
select * from t for system_time as of timestamp current_timestamp(6);
|
||||
a
|
||||
2
|
||||
select * from t for system_time all;
|
||||
a sys_trx_start sys_trx_end
|
||||
2 TIMESTAMP TIMESTAMP
|
||||
1 TIMESTAMP TIMESTAMP
|
||||
select * from t for system_time timestamp from '0-0-0' to current_timestamp(6);
|
||||
a sys_trx_start sys_trx_end
|
||||
2 TIMESTAMP TIMESTAMP
|
||||
1 TIMESTAMP TIMESTAMP
|
||||
select * from t for system_time timestamp between '0-0-0' and current_timestamp(6);
|
||||
a sys_trx_start sys_trx_end
|
||||
2 TIMESTAMP TIMESTAMP
|
||||
1 TIMESTAMP TIMESTAMP
|
||||
set global vers_hide= NEVER;
|
||||
select * from t;
|
||||
a sys_trx_start sys_trx_end
|
||||
2 TIMESTAMP TIMESTAMP
|
||||
set global vers_hide= FULL;
|
||||
create or replace table t (
|
||||
x int,
|
||||
st timestamp(6) generated always as row start,
|
||||
en timestamp(6) generated always as row end,
|
||||
period for system_time (st, en))
|
||||
with system versioning;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`x` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
insert into t values (1);
|
||||
delete from t;
|
||||
select * from t;
|
||||
x
|
||||
select * from t for system_time all;
|
||||
x
|
||||
1
|
||||
drop table t;
|
||||
set global vers_hide= IMPLICIT;
|
@@ -1,38 +0,0 @@
|
||||
create table t (a int) with system versioning;
|
||||
insert into t values (1);
|
||||
update t set a=2;
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
show variables where Variable_name like "temporal_current_timestamp%";
|
||||
Variable_name Value
|
||||
temporal_current_timestamp now
|
||||
set global temporal_current_timestamp = '2031-1-1 0:0:0';
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
set global temporal_current_timestamp = '2011-1-1 0:0:0';
|
||||
select * from t;
|
||||
a
|
||||
set global temporal_current_timestamp = 'all';
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
1
|
||||
show variables where Variable_name like "temporal_current_timestamp%";
|
||||
Variable_name Value
|
||||
temporal_current_timestamp all
|
||||
create view vt as select * from t;
|
||||
select * from t;
|
||||
a
|
||||
2
|
||||
1
|
||||
drop view vt;
|
||||
select * from (select * from t) as tt;
|
||||
a
|
||||
2
|
||||
1
|
||||
set session temporal_current_timestamp = 'now';
|
||||
ERROR HY000: Variable 'temporal_current_timestamp' is a GLOBAL variable and should be set with SET GLOBAL
|
||||
drop table t;
|
||||
set global temporal_current_timestamp = 'now';
|
5
mysql-test/suite/versioning/t/create.combinations
Normal file
5
mysql-test/suite/versioning/t/create.combinations
Normal file
@@ -0,0 +1,5 @@
|
||||
[innodb]
|
||||
default-storage-engine=innodb
|
||||
|
||||
[myisam]
|
||||
default-storage-engine=myisam
|
@@ -1,215 +1,264 @@
|
||||
-- source include/have_innodb.inc
|
||||
-- source suite/versioning/common.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
create table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
--let $sys_datatype= `select sys_datatype()`
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
eval create table t1 (
|
||||
x1 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_end $sys_datatype generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t1;
|
||||
|
||||
--echo # Implicit fields test
|
||||
create or replace table t1 (
|
||||
XNo int unsigned
|
||||
x2 int unsigned
|
||||
) with system versioning;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t1;
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_start2 timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
eval create or replace table t1 (
|
||||
x3 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_start2 $sys_datatype generated always as row start,
|
||||
Sys_end $sys_datatype generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
eval create or replace table t1 (
|
||||
x4 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_end2 $sys_datatype generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
eval create or replace table t1 (
|
||||
x5 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_end $sys_datatype generated always as row end,
|
||||
Sys_end2 $sys_datatype generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end2 timestamp(6) generated always as row end,
|
||||
x6 int unsigned,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
Sys_end2 timestamp(6) generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
Sys_end2 timestamp(6) generated always as row end,
|
||||
eval create or replace table t1 (
|
||||
x7 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_end $sys_datatype generated always as row end,
|
||||
Sys_end2 $sys_datatype generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
);
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
eval create or replace table t1 (
|
||||
x8 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_end $sys_datatype generated always as row end,
|
||||
period for system_time (sys_insert, sys_remove)
|
||||
) with system versioning;
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
eval create or replace table t1 (
|
||||
x9 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_end $sys_datatype generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
);
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end timestamp(6) generated always as row end,
|
||||
eval create or replace table t1 (
|
||||
x10 int unsigned,
|
||||
Sys_start $sys_datatype generated always as row start,
|
||||
Sys_end $sys_datatype generated always as row end,
|
||||
period for system_time (Sys_start, Sys_start)
|
||||
);
|
||||
|
||||
--error ER_VERS_FIELD_WRONG_TYPE
|
||||
--error ER_VERS_FIELD_WRONG_TYPE, ER_VERS_FIELD_WRONG_TYPE
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
Sys_start int generated always as row start,
|
||||
x11 int unsigned,
|
||||
Sys_start bigint unsigned 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 ER_VERS_FIELD_WRONG_TYPE
|
||||
--error ER_VERS_FIELD_WRONG_TYPE, ER_VERS_FIELD_WRONG_TYPE
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
x12 int unsigned,
|
||||
Sys_start timestamp(6) generated always as row start,
|
||||
Sys_end int generated always as row end,
|
||||
Sys_end bigint unsigned generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning;
|
||||
|
||||
--error ER_VERS_FIELD_WRONG_TYPE
|
||||
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 ER_VERS_FIELD_WRONG_TYPE
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
x13 int unsigned,
|
||||
Sys_start bigint generated always as row start,
|
||||
Sys_end bigint generated always as row end,
|
||||
Sys_end bigint unsigned generated always as row end,
|
||||
period for system_time (Sys_start, Sys_end)
|
||||
) with system versioning engine innodb;
|
||||
|
||||
--error ER_VERS_FIELD_WRONG_TYPE
|
||||
create or replace table t1 (
|
||||
XNo int unsigned,
|
||||
x14 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;
|
||||
|
||||
# columns with/without system versioning
|
||||
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A1 int with system versioning,
|
||||
B int
|
||||
);
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A2 int with system versioning,
|
||||
B int
|
||||
) with system versioning;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t1;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int,
|
||||
A3 int,
|
||||
B int without system versioning
|
||||
);
|
||||
|
||||
create or replace table t1 (
|
||||
A int,
|
||||
A4 int,
|
||||
B int without system versioning
|
||||
) with system versioning;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A5 int with system versioning,
|
||||
B int without system versioning
|
||||
);
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t1;
|
||||
|
||||
create or replace table t1 (
|
||||
A int with system versioning,
|
||||
A6 int with system versioning,
|
||||
B int without system versioning
|
||||
) with system versioning;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t1;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int without system versioning
|
||||
A7 int without system versioning
|
||||
);
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int without system versioning
|
||||
A8 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
|
||||
A9 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
|
||||
A10 int with system versioning without system versioning
|
||||
);
|
||||
|
||||
# table with/without system versioning
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create table t(
|
||||
a int
|
||||
a11 int
|
||||
) without system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A12 int
|
||||
) without system versioning with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A13 int
|
||||
) with system versioning without system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A14 int
|
||||
) with system versioning with system versioning;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t1 (
|
||||
A int
|
||||
A15 int
|
||||
) without system versioning without system versioning;
|
||||
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create temporary table tmp with system versioning select * from t1;
|
||||
|
||||
# CREATE TABLE ... LIKE
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create table tt1 like t1;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table tt1;
|
||||
drop table tt1;
|
||||
|
||||
# CREATE TABLE ... SELECT
|
||||
create or replace table t1 (x int) with system versioning;
|
||||
create or replace table t2 (y int);
|
||||
create or replace table t3 select * from t1 for system_time all, t2;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t3;
|
||||
|
||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
eval create or replace table t2 (
|
||||
y int,
|
||||
st $sys_datatype generated always as row start,
|
||||
en $sys_datatype generated always as row end,
|
||||
period for system_time (st, en)
|
||||
) with system versioning;
|
||||
create or replace table t3 select * from t2;
|
||||
--replace_result InnoDB INNODB_OR_MYISAM MyISAM INNODB_OR_MYISAM "bigint(20) unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||
show create table t3;
|
||||
|
||||
--error ER_VERS_WRONG_PARAMS
|
||||
create or replace table t3 select x, y, t1.sys_trx_start, t2.en from t1, t2;
|
||||
|
||||
insert into t2 values (1), (2);
|
||||
delete from t2 where y = 2;
|
||||
|
||||
create or replace table t3 select * from t2 for system_time all;
|
||||
select st, en from t2 where y = 1 into @st, @en;
|
||||
select y from t2 for system_time all where st = @st and en = @en;
|
||||
select st, en from t2 for system_time all where y = 2 into @st, @en;
|
||||
select y from t2 for system_time all where st = @st and en = @en;
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
|
||||
-- source suite/versioning/common_finish.inc
|
||||
|
1
mysql-test/suite/versioning/t/derived_tables.opt
Normal file
1
mysql-test/suite/versioning/t/derived_tables.opt
Normal file
@@ -0,0 +1 @@
|
||||
--vers-hide=implicit
|
1
mysql-test/suite/versioning/t/foreign.opt
Normal file
1
mysql-test/suite/versioning/t/foreign.opt
Normal file
@@ -0,0 +1 @@
|
||||
--vers-hide=implicit
|
1
mysql-test/suite/versioning/t/partition.opt
Normal file
1
mysql-test/suite/versioning/t/partition.opt
Normal file
@@ -0,0 +1 @@
|
||||
--vers-hide=implicit
|
1
mysql-test/suite/versioning/t/rpl_test.opt
Normal file
1
mysql-test/suite/versioning/t/rpl_test.opt
Normal file
@@ -0,0 +1 @@
|
||||
--vers-hide=implicit
|
1
mysql-test/suite/versioning/t/sysvars.opt
Normal file
1
mysql-test/suite/versioning/t/sysvars.opt
Normal file
@@ -0,0 +1 @@
|
||||
--vers-hide=implicit
|
62
mysql-test/suite/versioning/t/sysvars.test
Normal file
62
mysql-test/suite/versioning/t/sysvars.test
Normal file
@@ -0,0 +1,62 @@
|
||||
create table t (a int) with system versioning;
|
||||
insert into t values (1);
|
||||
update t set a= 2;
|
||||
|
||||
select * from t;
|
||||
show variables where variable_name = "temporal_current_timestamp";
|
||||
|
||||
set global temporal_current_timestamp = '2031-1-1 0:0:0';
|
||||
select * from t;
|
||||
|
||||
set global temporal_current_timestamp = '2011-1-1 0:0:0';
|
||||
select * from t;
|
||||
|
||||
set global temporal_current_timestamp = 'all';
|
||||
select * from t;
|
||||
show variables where Variable_name like "temporal_current_timestamp%";
|
||||
|
||||
create view vt as select * from t;
|
||||
select * from t;
|
||||
drop view vt;
|
||||
|
||||
select * from (select * from t) as tt;
|
||||
|
||||
--error ER_GLOBAL_VARIABLE
|
||||
set session temporal_current_timestamp = 'now';
|
||||
|
||||
set global temporal_current_timestamp = 'now';
|
||||
|
||||
show variables where variable_name = "vers_hide";
|
||||
select * from t for system_time all;
|
||||
|
||||
set global vers_hide= AUTO;
|
||||
select * from t;
|
||||
select * from t for system_time as of timestamp current_timestamp(6);
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/
|
||||
select * from t for system_time all;
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/
|
||||
select * from t for system_time timestamp from '0-0-0' to current_timestamp(6);
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/
|
||||
select * from t for system_time timestamp between '0-0-0' and current_timestamp(6);
|
||||
|
||||
set global vers_hide= NEVER;
|
||||
--replace_regex /\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}/TIMESTAMP/
|
||||
select * from t;
|
||||
|
||||
set global vers_hide= FULL;
|
||||
create or replace table t (
|
||||
x int,
|
||||
st timestamp(6) generated always as row start,
|
||||
en timestamp(6) generated always as row end,
|
||||
period for system_time (st, en))
|
||||
with system versioning;
|
||||
|
||||
show create table t;
|
||||
insert into t values (1);
|
||||
delete from t;
|
||||
|
||||
select * from t;
|
||||
select * from t for system_time all;
|
||||
|
||||
drop table t;
|
||||
set global vers_hide= IMPLICIT;
|
1
mysql-test/suite/versioning/t/truncate_history.opt
Normal file
1
mysql-test/suite/versioning/t/truncate_history.opt
Normal file
@@ -0,0 +1 @@
|
||||
--vers-hide=implicit
|
@@ -1,28 +0,0 @@
|
||||
create table t (a int) with system versioning;
|
||||
insert into t values (1);
|
||||
update t set a=2;
|
||||
|
||||
select * from t;
|
||||
show variables where Variable_name like "temporal_current_timestamp%";
|
||||
|
||||
set global temporal_current_timestamp = '2031-1-1 0:0:0';
|
||||
select * from t;
|
||||
|
||||
set global temporal_current_timestamp = '2011-1-1 0:0:0';
|
||||
select * from t;
|
||||
|
||||
set global temporal_current_timestamp = 'all';
|
||||
select * from t;
|
||||
show variables where Variable_name like "temporal_current_timestamp%";
|
||||
|
||||
create view vt as select * from t;
|
||||
select * from t;
|
||||
drop view vt;
|
||||
|
||||
select * from (select * from t) as tt;
|
||||
|
||||
--error ER_GLOBAL_VARIABLE
|
||||
set session temporal_current_timestamp = 'now';
|
||||
|
||||
drop table t;
|
||||
set global temporal_current_timestamp = 'now';
|
1
mysql-test/suite/versioning/t/view.opt
Normal file
1
mysql-test/suite/versioning/t/view.opt
Normal file
@@ -0,0 +1 @@
|
||||
--vers-hide=implicit
|
@@ -30,7 +30,7 @@ static int forced_versioning_init(void *p __attribute__ ((unused)))
|
||||
|
||||
DBUG_ENTER("forced_versioning_init");
|
||||
vers_force= true;
|
||||
vers_hide= true;
|
||||
vers_hide= VERS_HIDE_FULL;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ static int forced_versioning_deinit(void *p __attribute__ ((unused)))
|
||||
{
|
||||
DBUG_ENTER("forced_versioning_deinit");
|
||||
vers_force= false;
|
||||
vers_hide= false;
|
||||
vers_hide= VERS_HIDE_AUTO;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
102
sql/handler.cc
102
sql/handler.cc
@@ -6599,6 +6599,14 @@ bool Vers_parse_info::is_trx_end(const char *name) const
|
||||
DBUG_ASSERT(name);
|
||||
return generated_as_row.end && !strcmp(generated_as_row.end->c_ptr(), name);
|
||||
}
|
||||
bool Vers_parse_info::is_trx_start(const Create_field &f) const
|
||||
{
|
||||
return f.flags & VERS_SYS_START_FLAG;
|
||||
}
|
||||
bool Vers_parse_info::is_trx_end(const Create_field &f) const
|
||||
{
|
||||
return f.flags & VERS_SYS_END_FLAG;
|
||||
}
|
||||
|
||||
static bool create_string(MEM_ROOT *mem_root, String **s, const char *value)
|
||||
{
|
||||
@@ -6675,12 +6683,28 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
bool integer_fields=
|
||||
create_info->db_type->flags & HTON_SUPPORTS_SYS_VERSIONING;
|
||||
|
||||
if (vers_force) {
|
||||
SELECT_LEX &slex= thd->lex->select_lex;
|
||||
int vers_tables= 0;
|
||||
bool from_select= slex.item_list.elements ? true : false;
|
||||
|
||||
if (from_select)
|
||||
{
|
||||
for (TABLE_LIST *table= slex.table_list.first; table; table= table->next_local)
|
||||
{
|
||||
if (table->table && table->table->versioned())
|
||||
vers_tables++;
|
||||
}
|
||||
}
|
||||
|
||||
// CREATE ... SELECT: if at least one table in SELECT is versioned,
|
||||
// then created table will be versioned.
|
||||
if (vers_force || vers_tables > 0)
|
||||
{
|
||||
declared_with_system_versioning= true;
|
||||
create_info->options|= HA_VERSIONED_TABLE;
|
||||
}
|
||||
|
||||
if (!need_to_check())
|
||||
if (!need_check())
|
||||
return false;
|
||||
|
||||
if (declared_without_system_versioning)
|
||||
@@ -6697,11 +6721,43 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
return true;
|
||||
}
|
||||
|
||||
TABLE *orig_table= NULL;
|
||||
List_iterator<Create_field> it(alter_info->create_list);
|
||||
while (Create_field *f= it++)
|
||||
{
|
||||
if (is_trx_start(f->field_name) || is_trx_end(f->field_name))
|
||||
if (is_trx_start(*f))
|
||||
{
|
||||
if (!generated_as_row.start) // not inited in CREATE ... SELECT
|
||||
{
|
||||
DBUG_ASSERT(vers_tables > 0);
|
||||
if (orig_table && orig_table != f->field->orig_table)
|
||||
{
|
||||
err_different_tables:
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"system fields selected from different tables");
|
||||
return true;
|
||||
}
|
||||
orig_table= f->field->orig_table;
|
||||
generated_as_row.start= new (thd->mem_root) String(f->field_name, system_charset_info);
|
||||
period_for_system_time.start= generated_as_row.start;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (is_trx_end(*f))
|
||||
{
|
||||
if (!generated_as_row.end)
|
||||
{
|
||||
DBUG_ASSERT(vers_tables > 0);
|
||||
if (orig_table && orig_table != f->field->orig_table)
|
||||
{
|
||||
goto err_different_tables;
|
||||
}
|
||||
orig_table= f->field->orig_table;
|
||||
generated_as_row.end= new (thd->mem_root) String(f->field_name, system_charset_info);
|
||||
period_for_system_time.end= generated_as_row.end;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((f->versioning == Column_definition::VERSIONING_NOT_SET &&
|
||||
!declared_with_system_versioning) ||
|
||||
@@ -6711,32 +6767,50 @@ bool Vers_parse_info::check_and_fix_implicit(
|
||||
}
|
||||
}
|
||||
|
||||
if (fix_implicit(thd, alter_info, integer_fields))
|
||||
if (vers_tables > 0)
|
||||
{
|
||||
if (!generated_as_row.start && !generated_as_row.end)
|
||||
{
|
||||
declared_with_system_versioning= false;
|
||||
create_info->options&= ~HA_VERSIONED_TABLE;
|
||||
return false;
|
||||
}
|
||||
if (!generated_as_row.start || !generated_as_row.end)
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"both ROW START and ROW END system fields required in SELECT resultset");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (fix_implicit(thd, alter_info, integer_fields))
|
||||
return true;
|
||||
|
||||
int not_set= 0;
|
||||
int with= 0;
|
||||
int plain_cols= 0; // column doesn't have WITH or WITHOUT SYSTEM VERSIONING
|
||||
int vers_cols= 0; // column has WITH SYSTEM VERSIONING
|
||||
it.rewind();
|
||||
while (const Create_field *f= it++)
|
||||
{
|
||||
if (is_trx_start(f->field_name) || is_trx_end(f->field_name))
|
||||
if (is_trx_start(*f) || is_trx_end(*f))
|
||||
continue;
|
||||
|
||||
if (f->versioning == Column_definition::VERSIONING_NOT_SET)
|
||||
not_set++;
|
||||
plain_cols++;
|
||||
else if (f->versioning == Column_definition::WITH_VERSIONING)
|
||||
with++;
|
||||
vers_cols++;
|
||||
}
|
||||
|
||||
bool table_with_system_versioning=
|
||||
generated_as_row.start || generated_as_row.end ||
|
||||
period_for_system_time.start || period_for_system_time.end;
|
||||
|
||||
if (!thd->lex->tmp_table() && with == 0 &&
|
||||
(not_set == 0 || !table_with_system_versioning))
|
||||
if (!thd->lex->tmp_table() &&
|
||||
// CREATE from SELECT (Create_fields are not yet added)
|
||||
!from_select &&
|
||||
vers_cols == 0 &&
|
||||
(plain_cols == 0 || !table_with_system_versioning))
|
||||
{
|
||||
my_error(ER_VERS_WRONG_PARAMS, MYF(0), table_name,
|
||||
"versioned fields missing");
|
||||
"no columns defined with system versioning!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6762,7 +6836,7 @@ bool Vers_parse_info::check_and_fix_alter(THD *thd, Alter_info *alter_info,
|
||||
create_info->db_type->flags & HTON_SUPPORTS_SYS_VERSIONING;
|
||||
const char *table_name= share->table_name.str;
|
||||
|
||||
if (!need_to_check() && !share->versioned)
|
||||
if (!need_check() && !share->versioned)
|
||||
return false;
|
||||
|
||||
if (declared_without_system_versioning)
|
||||
@@ -6934,7 +7008,7 @@ bool Vers_parse_info::check_generated_type(const char *table_name,
|
||||
List_iterator<Create_field> it(alter_info->create_list);
|
||||
while (Create_field *f= it++)
|
||||
{
|
||||
if (is_trx_start(f->field_name) || is_trx_end(f->field_name))
|
||||
if (is_trx_start(*f) || is_trx_end(*f))
|
||||
{
|
||||
if (integer_fields)
|
||||
{
|
||||
|
@@ -1670,6 +1670,7 @@ struct Schema_specification_st
|
||||
}
|
||||
};
|
||||
|
||||
class Create_field;
|
||||
|
||||
struct Vers_parse_info
|
||||
{
|
||||
@@ -1701,8 +1702,10 @@ struct Vers_parse_info
|
||||
private:
|
||||
bool is_trx_start(const char *name) const;
|
||||
bool is_trx_end(const char *name) const;
|
||||
bool is_trx_start(const Create_field &f) const;
|
||||
bool is_trx_end(const Create_field &f) const;
|
||||
bool fix_implicit(THD *thd, Alter_info *alter_info, bool integer_fields);
|
||||
bool need_to_check() const
|
||||
bool need_check() const
|
||||
{
|
||||
return
|
||||
has_versioned_fields ||
|
||||
|
@@ -784,7 +784,7 @@ char *opt_logname, *opt_slow_logname, *opt_bin_logname;
|
||||
/* System Versioning */
|
||||
char *temporal_current_timestamp;
|
||||
my_bool vers_force= false;
|
||||
my_bool vers_hide= false;
|
||||
ulong vers_hide= VERS_HIDE_AUTO;
|
||||
|
||||
/* Static variables */
|
||||
|
||||
|
@@ -177,7 +177,13 @@ extern const char *log_output_str;
|
||||
extern const char *log_backup_output_str;
|
||||
extern char *temporal_current_timestamp;
|
||||
extern my_bool vers_force;
|
||||
extern my_bool vers_hide;
|
||||
enum vers_hide_enum {
|
||||
VERS_HIDE_AUTO= 0,
|
||||
VERS_HIDE_IMPLICIT,
|
||||
VERS_HIDE_FULL,
|
||||
VERS_HIDE_NEVER
|
||||
};
|
||||
extern ulong vers_hide;
|
||||
extern char *mysql_home_ptr, *pidfile_name_ptr;
|
||||
extern MYSQL_PLUGIN_IMPORT char glob_hostname[FN_REFLEN];
|
||||
extern char mysql_home[FN_REFLEN];
|
||||
|
@@ -7586,10 +7586,27 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
||||
{
|
||||
Item_field *f= static_cast<Item_field *>(item);
|
||||
DBUG_ASSERT(f->field);
|
||||
if (f->field->flags & HIDDEN_FLAG)
|
||||
uint32 fl= f->field->flags;
|
||||
bool sys_field= fl & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG);
|
||||
SELECT_LEX *slex= thd->lex->current_select;
|
||||
TABLE *table= f->field->table;
|
||||
DBUG_ASSERT(table && table->pos_in_table_list);
|
||||
TABLE_LIST *tl= table->pos_in_table_list;
|
||||
vers_range_type_t vers_type=
|
||||
tl->vers_conditions.type == FOR_SYSTEM_TIME_UNSPECIFIED ?
|
||||
slex->vers_conditions.type : tl->vers_conditions.type;
|
||||
|
||||
if ((sys_field && vers_hide == VERS_HIDE_FULL &&
|
||||
thd->lex->sql_command != SQLCOM_CREATE_TABLE) ||
|
||||
((fl & HIDDEN_FLAG) && (
|
||||
!sys_field ||
|
||||
vers_hide == VERS_HIDE_IMPLICIT ||
|
||||
(vers_hide == VERS_HIDE_AUTO && (
|
||||
vers_type == FOR_SYSTEM_TIME_UNSPECIFIED ||
|
||||
vers_type == FOR_SYSTEM_TIME_AS_OF)))))
|
||||
continue;
|
||||
}
|
||||
if (item->type() == Item::REF_ITEM)
|
||||
else if (item->type() == Item::REF_ITEM)
|
||||
{
|
||||
Item *i= item;
|
||||
while (i->type() == Item::REF_ITEM)
|
||||
|
@@ -4164,6 +4164,12 @@ static TABLE *create_table_from_items(THD *thd,
|
||||
alter_info->create_list.push_back(cr_field, thd->mem_root);
|
||||
}
|
||||
|
||||
if (create_info->vers_info.check_and_fix_implicit(
|
||||
thd, alter_info, create_info, create_table->table_name))
|
||||
{
|
||||
DBUG_RETURN(NULL);
|
||||
}
|
||||
|
||||
DEBUG_SYNC(thd,"create_table_select_before_create");
|
||||
|
||||
/* Check if LOCK TABLES + CREATE OR REPLACE of existing normal table*/
|
||||
|
@@ -3876,13 +3876,6 @@ mysql_execute_command(THD *thd)
|
||||
if (!(create_info.used_fields & HA_CREATE_USED_ENGINE))
|
||||
create_info.use_default_db_type(thd);
|
||||
|
||||
if (!create_info.like() &&
|
||||
create_info.vers_info.check_and_fix_implicit(
|
||||
thd, &alter_info, &create_info, create_table->table_name))
|
||||
{
|
||||
goto end_with_restore_list;
|
||||
}
|
||||
|
||||
/*
|
||||
If we are using SET CHARSET without DEFAULT, add an implicit
|
||||
DEFAULT to not confuse old users. (This may change).
|
||||
@@ -4069,6 +4062,11 @@ mysql_execute_command(THD *thd)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (create_info.vers_info.check_and_fix_implicit(
|
||||
thd, &alter_info, &create_info, create_table->table_name))
|
||||
{
|
||||
goto end_with_restore_list;
|
||||
}
|
||||
/*
|
||||
In STATEMENT format, we probably have to replicate also temporary
|
||||
tables, like mysql replication does. Also check if the requested
|
||||
|
@@ -16173,7 +16173,12 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
|
||||
item->result_field= new_field;
|
||||
else
|
||||
new_field->field_name= name;
|
||||
new_field->flags|= (org_field->flags & NO_DEFAULT_VALUE_FLAG);
|
||||
new_field->flags|= (org_field->flags & (
|
||||
NO_DEFAULT_VALUE_FLAG |
|
||||
HIDDEN_FLAG |
|
||||
VERS_SYS_START_FLAG |
|
||||
VERS_SYS_END_FLAG |
|
||||
VERS_OPTIMIZED_UPDATE_FLAG));
|
||||
if (org_field->maybe_null() || (item && item->maybe_null))
|
||||
new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join
|
||||
if (org_field->type() == MYSQL_TYPE_VAR_STRING ||
|
||||
|
@@ -2064,7 +2064,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
{
|
||||
uint flags = field->flags;
|
||||
|
||||
if (vers_hide &&
|
||||
if (vers_hide == VERS_HIDE_FULL &&
|
||||
(flags & (VERS_SYS_START_FLAG | VERS_SYS_END_FLAG)))
|
||||
continue;
|
||||
|
||||
@@ -2233,7 +2233,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
hton->index_options);
|
||||
}
|
||||
|
||||
if (table->versioned() && !vers_hide)
|
||||
if (table->versioned() && vers_hide != VERS_HIDE_FULL)
|
||||
{
|
||||
const Field *fs = table->vers_start_field();
|
||||
const Field *fe = table->vers_end_field();
|
||||
@@ -2282,7 +2282,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||
add_table_options(thd, table, create_info_arg,
|
||||
table_list->schema_table != 0, 0, packet);
|
||||
|
||||
if (table->versioned() && !vers_hide)
|
||||
if (table->versioned() && vers_hide != VERS_HIDE_FULL)
|
||||
{
|
||||
packet->append(STRING_WITH_LEN(" WITH SYSTEM VERSIONING"));
|
||||
}
|
||||
|
@@ -391,9 +391,14 @@ static Sys_var_mybool Sys_vers_force(
|
||||
"vers_force", "Force system versioning for all created tables",
|
||||
GLOBAL_VAR(vers_force), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
||||
|
||||
static Sys_var_mybool Sys_vers_hide(
|
||||
"vers_hide", "Hide system versioning from being displayed in table info",
|
||||
GLOBAL_VAR(vers_hide), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
||||
static const char *vers_hide_keywords[]= {"AUTO", "IMPLICIT", "FULL", "NEVER", NullS};
|
||||
static Sys_var_enum Sys_vers_hide(
|
||||
"vers_hide", "Hide system versioning from being displayed in table info. "
|
||||
"AUTO: hide implicit system fields only in non-versioned and AS OF queries; "
|
||||
"IMPLICIT: hide implicit system fields in all queries; "
|
||||
"FULL: hide any system fields in all queries and hide versioning info in SHOW commands; "
|
||||
"NEVER: don't hide system fields",
|
||||
GLOBAL_VAR(vers_hide), CMD_LINE(OPT_ARG), vers_hide_keywords, DEFAULT(VERS_HIDE_AUTO));
|
||||
|
||||
static Sys_var_ulonglong Sys_binlog_cache_size(
|
||||
"binlog_cache_size", "The size of the transactional cache for "
|
||||
|
@@ -2563,8 +2563,8 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
|
||||
DBUG_PRINT("info", ("Columns with system versioning: [%d, %d]", row_start, row_end));
|
||||
versioned= true;
|
||||
vers_init();
|
||||
row_start_field = row_start;
|
||||
row_end_field = row_end;
|
||||
row_start_field= row_start;
|
||||
row_end_field= row_end;
|
||||
vers_start_field()->flags|= VERS_SYS_START_FLAG;
|
||||
vers_end_field()->flags|= VERS_SYS_END_FLAG;
|
||||
} // if (system_period == NULL)
|
||||
|
@@ -8717,9 +8717,10 @@ no_commit:
|
||||
|
||||
innobase_srv_conc_enter_innodb(m_prebuilt);
|
||||
|
||||
vers_set_fields = table->versioned() &&
|
||||
vers_set_fields = table->versioned() && (
|
||||
(sql_command != SQLCOM_DELETE ||
|
||||
(m_int_table_flags & HA_INNOPART_DISABLED_TABLE_FLAGS)) ?
|
||||
(m_int_table_flags & HA_INNOPART_DISABLED_TABLE_FLAGS)) &&
|
||||
sql_command != SQLCOM_CREATE_TABLE) ?
|
||||
ROW_INS_VERSIONED :
|
||||
ROW_INS_NORMAL;
|
||||
|
||||
|
@@ -1498,7 +1498,7 @@ row_insert_for_mysql(
|
||||
if (ins_mode == ROW_INS_HISTORICAL) {
|
||||
set_tuple_col_8(node->row, table->vers_row_end, trx->id, node->entry_sys_heap);
|
||||
}
|
||||
else {
|
||||
else /* ROW_INS_VERSIONED */ {
|
||||
set_tuple_col_8(node->row, table->vers_row_end, IB_UINT64_MAX, node->entry_sys_heap);
|
||||
int8store(&mysql_rec[t->mysql_col_offset], IB_UINT64_MAX);
|
||||
t = &prebuilt->mysql_template[table->vers_row_start];
|
||||
|
Reference in New Issue
Block a user