2016-10-18 09:05:49 +00:00
drop table if exists t1;
create table t1 (
2017-03-24 16:00:42 +03:00
x1 int unsigned,
2017-12-19 16:12:56 +03:00
Sys_start SYS_DATATYPE as row start invisible comment 'start',
Sys_end SYS_DATATYPE as row end invisible comment 'end',
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2017-03-24 16:00:42 +03:00
`x1` int(10) unsigned DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`Sys_start` SYS_DATATYPE GENERATED ALWAYS AS ROW START INVISIBLE COMMENT 'start',
`Sys_end` SYS_DATATYPE GENERATED ALWAYS AS ROW END INVISIBLE COMMENT 'end',
2016-10-18 09:05:49 +00:00
PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`)
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2018-01-09 19:06:21 +01:00
select table_catalog,table_schema,table_name,table_type,version,table_rows,avg_row_length,data_free,auto_increment,check_time,table_collation,checksum,create_options,table_comment from information_schema.tables where table_name='t1';
table_catalog def
table_schema test
table_name t1
table_type SYSTEM VERSIONED
version 10
table_rows 0
avg_row_length 0
data_free 0
auto_increment NULL
check_time NULL
table_collation latin1_swedish_ci
checksum NULL
create_options
table_comment
2018-01-12 14:47:33 +01:00
select table_catalog,table_schema,table_name,column_name,ordinal_position,column_default,character_maximum_length,character_octet_length,character_set_name,collation_name,column_key,extra,column_comment,is_generated,generation_expression from information_schema.columns where table_name='t1';
2018-01-09 19:06:21 +01:00
table_catalog def
table_schema test
table_name t1
column_name x1
ordinal_position 1
column_default NULL
character_maximum_length NULL
character_octet_length NULL
character_set_name NULL
collation_name NULL
column_key
extra
column_comment
is_generated NEVER
generation_expression NULL
table_catalog def
table_schema test
table_name t1
column_name Sys_start
ordinal_position 2
column_default NULL
character_maximum_length NULL
character_octet_length NULL
character_set_name NULL
collation_name NULL
column_key
extra INVISIBLE
column_comment start
is_generated ALWAYS
generation_expression ROW START
table_catalog def
table_schema test
table_name t1
column_name Sys_end
ordinal_position 3
column_default NULL
character_maximum_length NULL
character_octet_length NULL
character_set_name NULL
collation_name NULL
column_key
extra INVISIBLE
column_comment end
is_generated ALWAYS
generation_expression ROW END
2016-10-18 09:05:49 +00:00
# Implicit fields test
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x2 int unsigned
2016-10-18 09:05:49 +00:00
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2017-12-19 16:12:56 +03:00
`x2` int(10) unsigned DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x3 int unsigned,
2018-02-21 21:45:59 +01:00
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
2017-12-06 14:45:54 +03:00
period for system_time (x, Sys_end)
2016-10-18 09:05:49 +00:00
) with system versioning;
2017-12-06 14:45:54 +03:00
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x4 int unsigned,
2018-02-21 21:45:59 +01:00
Sys_start timestamp(6) as row start invisible,
Sys_end2 timestamp(6) as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
) with system versioning;
2017-12-04 18:41:07 +01:00
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end2`
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x5 int unsigned,
2018-02-21 21:45:59 +01:00
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
2017-12-06 14:45:54 +03:00
period for system_time (Sys_start, x)
2016-10-18 09:05:49 +00:00
) with system versioning;
2017-12-06 14:45:54 +03:00
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x6 int unsigned,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
) with system versioning;
2017-06-29 19:35:08 +03:00
ERROR HY000: Wrong parameters for `t1`: missing 'AS ROW START'
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x7 int unsigned,
2018-02-21 21:45:59 +01:00
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
);
2017-08-08 17:12:16 +03:00
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x8 int unsigned,
2018-02-21 21:45:59 +01:00
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (sys_insert, sys_remove)
) with system versioning;
2017-12-04 18:41:07 +01:00
ERROR HY000: PERIOD FOR SYSTEM_TIME must use columns `Sys_start` and `Sys_end`
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x9 int unsigned,
2018-02-21 21:45:59 +01:00
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
);
2017-06-29 19:35:08 +03:00
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x10 int unsigned,
2018-02-21 21:45:59 +01:00
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_start)
);
2017-08-08 17:12:16 +03:00
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x11 int unsigned,
2017-12-19 16:12:56 +03:00
Sys_start bigint unsigned as row start invisible,
Sys_end timestamp(6) as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
) with system versioning;
2017-03-24 16:00:42 +03:00
Got one of the listed errors
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x12 int unsigned,
2017-12-19 16:12:56 +03:00
Sys_start timestamp(6) as row start invisible,
Sys_end bigint unsigned as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
) with system versioning;
2017-03-24 16:00:42 +03:00
Got one of the listed errors
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x13 int unsigned,
2017-12-19 16:12:56 +03:00
Sys_start bigint as row start invisible,
Sys_end bigint unsigned as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
2017-12-18 19:11:14 +03:00
ERROR HY000: `Sys_start` must be of type TIMESTAMP(6) for system-versioned table `t1`
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-03-24 16:00:42 +03:00
x14 int unsigned,
2017-12-19 16:12:56 +03:00
Sys_start bigint unsigned as row start invisible,
Sys_end bigint as row end invisible,
2016-10-18 09:05:49 +00:00
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
2017-12-18 19:11:14 +03:00
ERROR HY000: `Sys_end` must be of type BIGINT(20) UNSIGNED for system-versioned table `t1`
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x15 int with system versioning,
2016-10-18 09:05:49 +00:00
B int
);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2017-12-18 19:03:51 +03:00
`x15` int(11) DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x16 int with system versioning,
2016-10-18 09:05:49 +00:00
B int
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2017-12-18 19:03:51 +03:00
`x16` int(11) DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`B` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x17 int,
2016-10-18 09:05:49 +00:00
B int without system versioning
);
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x18 int,
2016-10-18 09:05:49 +00:00
B int without system versioning
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2017-12-18 19:03:51 +03:00
`x18` int(11) DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x19 int with system versioning,
2016-10-18 09:05:49 +00:00
B int without system versioning
);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2017-12-18 19:03:51 +03:00
`x19` int(11) DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x20 int with system versioning,
2016-10-18 09:05:49 +00:00
B int without system versioning
) with system versioning;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2017-12-18 19:03:51 +03:00
`x20` int(11) DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2016-10-18 09:05:49 +00:00
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x21 int without system versioning
2016-10-18 09:05:49 +00:00
);
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x22 int without system versioning
2016-10-18 09:05:49 +00:00
) with system versioning;
2017-12-27 15:16:17 +01:00
ERROR HY000: Table `t1` must have at least one versioned column
2017-03-04 23:05:45 +03:00
create or replace table t1 (a int) with system versioning;
2017-03-06 15:53:53 +03:00
create table tt1 like t1;
show create table tt1;
Table Create Table
tt1 CREATE TABLE `tt1` (
2017-12-19 16:12:56 +03:00
`a` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2017-03-06 15:53:53 +03:00
drop table tt1;
2017-12-01 10:08:57 +03:00
create temporary table tt1 like t1;
Warnings:
Warning 1105 System versioning is stripped from temporary `test.tt1`
# Temporary is stripped from versioning
show create table tt1;
Table Create Table
tt1 CREATE TEMPORARY TABLE `tt1` (
`a` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
# CREATE TABLE ... SELECT
2017-12-18 19:03:51 +03:00
create or replace table t1 (x23 int) with system versioning;
2017-07-03 17:38:59 +03:00
create or replace table t0(
2017-03-24 16:00:42 +03:00
y int,
2018-02-21 21:45:59 +01:00
st timestamp(6) as row start,
en timestamp(6) as row end,
2017-03-24 16:00:42 +03:00
period for system_time (st, en)
) with system versioning;
2017-12-12 21:30:49 +03:00
## For non-versioned table:
2017-12-24 01:48:21 +01:00
### 1. invisible fields are not included
2017-07-03 17:38:59 +03:00
create or replace table t2 as select * from t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
2017-12-18 19:03:51 +03:00
`x23` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
2017-12-24 01:48:21 +01:00
### 2. all visible fields are included
2017-07-03 17:38:59 +03:00
create or replace table t3 as select * from t0;
2017-12-12 21:30:49 +03:00
select * from t0;
y st en
2017-07-03 17:38:59 +03:00
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
2017-12-12 21:30:49 +03:00
`y` int(11) DEFAULT NULL,
2018-02-21 21:45:59 +01:00
`st` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
`en` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
## For versioned table
2017-07-03 17:38:59 +03:00
insert into t1 values (1);
2018-01-08 18:03:55 +01:00
select row_start from t1 into @row_start;
2017-12-19 16:12:56 +03:00
insert into t0 (y) values (2);
2017-12-12 21:30:49 +03:00
select st from t0 into @st;
2017-07-03 17:38:59 +03:00
create or replace table t2 with system versioning as select * from t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
2017-12-19 16:12:56 +03:00
`x23` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2017-12-24 01:48:21 +01:00
#### invisible fields are not copied
select * from t2;
2017-12-18 19:03:51 +03:00
x23
2017-07-03 17:38:59 +03:00
1
2018-01-08 18:03:55 +01:00
select * from t2 where row_start <= @row_start;
2017-12-24 01:48:21 +01:00
x23
### 2. source table with visible system fields, target with invisible
2017-07-03 17:38:59 +03:00
create or replace table t3 with system versioning as select * from t0;
2017-03-24 16:00:42 +03:00
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
2018-02-21 21:45:59 +01:00
`st` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
`en` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2017-07-03 17:38:59 +03:00
select * from t3 where y > 2;
y st en
2018-01-08 18:03:55 +01:00
select y from t3 where st = @st and row_start > @st;
2017-12-12 21:30:49 +03:00
y
2
2017-12-24 01:48:21 +01:00
### 3. source and target table with visible system fields
2017-12-12 21:30:49 +03:00
create or replace table t3 (
2018-02-21 21:45:59 +01:00
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
2017-12-12 21:30:49 +03:00
period for system_time (st, en)
) with system versioning as select * from t0;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`y` int(11) DEFAULT NULL,
2018-02-21 21:45:59 +01:00
`st` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE,
`en` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
2017-12-12 21:30:49 +03:00
PERIOD FOR SYSTEM_TIME (`st`, `en`)
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2017-12-24 01:48:21 +01:00
select y from t3;
2017-12-12 21:30:49 +03:00
y
2
2017-12-24 01:48:21 +01:00
select y from t3 where st = @st;
y
2017-12-12 21:30:49 +03:00
### 4. system fields not or wrongly selected
2017-12-18 19:03:51 +03:00
create or replace table t3 with system versioning select x23 from t1;
2017-12-12 21:30:49 +03:00
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
2017-12-19 16:12:56 +03:00
`x23` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
select * from t3;
2017-12-18 19:03:51 +03:00
x23
2017-12-12 21:30:49 +03:00
1
2018-01-08 18:03:55 +01:00
create or replace table t3 with system versioning select x23, row_start from t1;
2017-12-12 21:30:49 +03:00
ERROR HY000: Wrong parameters for `t3`: missing 'AS ROW END'
2018-01-08 18:03:55 +01:00
create or replace table t3 with system versioning select x23, row_end from t1;
2017-12-12 21:30:49 +03:00
ERROR HY000: Wrong parameters for `t3`: missing 'AS ROW START'
# Prepare checking for historical row
delete from t1;
2018-01-08 18:03:55 +01:00
select row_end from t1 for system_time all into @row_end;
2017-07-03 17:38:59 +03:00
delete from t0;
2017-12-12 21:30:49 +03:00
select en from t0 for system_time all into @en;
## Combinations of versioned + non-versioned
2017-07-03 17:38:59 +03:00
create or replace table t2 (y int);
2017-12-12 21:30:49 +03:00
insert into t2 values (3);
2017-07-03 17:38:59 +03:00
create or replace table t3 with system versioning select * from t1 for system_time all, t2;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
2017-12-18 19:03:51 +03:00
`x23` int(11) DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`y` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2017-12-24 01:48:21 +01:00
select * from t3 for system_time all;
2017-12-18 19:03:51 +03:00
x23 y
2017-12-12 21:30:49 +03:00
1 3
2018-01-08 18:03:55 +01:00
select * from t3 for system_time all where row_start = @row_start and row_end = @row_end;
2017-12-24 01:48:21 +01:00
x23 y
2017-12-12 21:30:49 +03:00
create or replace table t2 like t0;
2017-12-19 16:12:56 +03:00
insert into t2 (y) values (1), (2);
2017-03-24 16:00:42 +03:00
delete from t2 where y = 2;
create or replace table t3 select * from t2 for system_time all;
2017-12-12 21:30:49 +03:00
select st, en from t3 where y = 1 into @st, @en;
2017-03-24 16:00:42 +03:00
select y from t2 for system_time all where st = @st and en = @en;
y
1
2017-12-12 21:30:49 +03:00
select st, en from t3 where y = 2 into @st, @en;
2017-03-24 16:00:42 +03:00
select y from t2 for system_time all where st = @st and en = @en;
y
2
2017-12-12 21:30:49 +03:00
## Default engine detection
2017-12-18 19:03:51 +03:00
create or replace table t1 (x25 int) with system versioning engine NON_DEFAULT_ENGINE;
2017-12-12 21:30:49 +03:00
create or replace table t2
2018-01-08 18:03:55 +01:00
as select x25, row_start, row_end from t1 for system_time all;
2017-12-12 21:30:49 +03:00
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
2017-12-19 16:12:56 +03:00
`x25` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
create or replace table t2 with system versioning
2018-01-08 18:03:55 +01:00
as select x25, row_start, row_end from t1;
2017-12-12 21:30:49 +03:00
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
2017-12-19 16:12:56 +03:00
`x25` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=NON_DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2017-12-18 19:03:51 +03:00
create or replace table t1 (
x26 int,
2018-01-01 13:41:50 +03:00
st bigint unsigned as row start,
en bigint unsigned as row end,
2017-12-18 19:03:51 +03:00
period for system_time (st, en)
) with system versioning engine innodb;
create or replace table t2 with system versioning engine myisam
as select * from t1;
2017-12-18 19:11:14 +03:00
ERROR HY000: `st` must be of type TIMESTAMP(6) for system-versioned table `t2`
2017-12-18 19:03:51 +03:00
create or replace table t1 (x27 int, id int) with system versioning engine NON_DEFAULT_ENGINE;
2017-06-27 12:22:52 +03:00
create or replace table t2 (b int, id int);
2017-12-12 21:30:49 +03:00
create or replace table t3 with system versioning
2018-01-08 18:03:55 +01:00
as select t2.b, t1.x27, t1.row_start, t1.row_end from t2 inner join t1 on t2.id=t1.id;
2017-12-12 21:30:49 +03:00
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`b` int(11) DEFAULT NULL,
2017-12-19 16:12:56 +03:00
`x27` int(11) DEFAULT NULL
2017-12-12 21:30:49 +03:00
) ENGINE=NON_DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
## Errors
2017-12-18 19:03:51 +03:00
create or replace temporary table t (x28 int) with system versioning;
2017-12-29 16:28:13 +03:00
ERROR HY000: System versioning prohibited for TEMPORARY tables
2017-12-06 14:45:54 +03:00
create or replace table t1 (
2017-12-18 19:03:51 +03:00
x29 int unsigned,
2017-12-19 16:12:56 +03:00
Sys_start0 timestamp(6) as row start invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
2017-12-06 14:45:54 +03:00
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Duplicate ROW START column `Sys_start`
2017-12-23 12:23:04 +01:00
create or replace table t1 (
x29 int unsigned,
Sys_end0 timestamp(6) as row end invisible,
Sys_start timestamp(6) as row start invisible,
Sys_end timestamp(6) as row end invisible,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Duplicate ROW END column `Sys_end`
2017-12-12 21:30:49 +03:00
## System fields detection
2017-12-18 19:03:51 +03:00
create or replace table t1 (x30 int) with system versioning;
2017-12-12 21:30:49 +03:00
create or replace table t2 (
y int,
2018-02-21 21:45:59 +01:00
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
2017-12-12 21:30:49 +03:00
period for system_time (st, en)
) with system versioning;
create or replace table t3
2018-01-08 18:03:55 +01:00
as select x30, y, row_start, row_end, st, en from t1, t2;
2017-12-12 21:30:49 +03:00
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
2017-12-18 19:03:51 +03:00
`x30` int(11) DEFAULT NULL,
2017-12-12 21:30:49 +03:00
`y` int(11) DEFAULT NULL,
2018-02-21 21:45:59 +01:00
`st` timestamp(6) NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000',
`en` timestamp(6) NOT NULL INVISIBLE DEFAULT '0000-00-00 00:00:00.000000'
2017-12-12 21:30:49 +03:00
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
create or replace table t3 (
y int,
2018-02-21 21:45:59 +01:00
st timestamp(6) as row start invisible,
en timestamp(6) as row end invisible,
2017-12-12 21:30:49 +03:00
period for system_time (st, en)
) with system versioning
2018-01-08 18:03:55 +01:00
as select x30, y, row_start, row_end, st, en from t1, t2;
2017-12-12 21:30:49 +03:00
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
2017-12-18 19:03:51 +03:00
`x30` int(11) DEFAULT NULL,
2017-12-12 21:30:49 +03:00
`y` int(11) DEFAULT NULL,
2018-02-21 21:45:59 +01:00
`st` timestamp(6) GENERATED ALWAYS AS ROW START INVISIBLE,
`en` timestamp(6) GENERATED ALWAYS AS ROW END INVISIBLE,
2017-12-12 21:30:49 +03:00
PERIOD FOR SYSTEM_TIME (`st`, `en`)
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
2018-01-02 15:28:50 +03:00
# MDEV-14828 Server crashes in JOIN::prepare / setup_fields on 2nd execution of PS [#437]
create or replace table t1 (x int) with system versioning;
prepare bad from 'create or replace table t2 with system versioning as select * from t1';
execute bad;
execute bad;
execute bad;
execute bad;
execute bad;
execute bad;
execute bad;
execute bad;
# bad is good.
2017-07-03 17:38:59 +03:00
drop database test;
create database test;