rename system_time columns
sys_trx_start -> row_start sys_trx_end -> row_end
This commit is contained in:
parent
cf1e5bef59
commit
b85efdc3af
@ -118,29 +118,29 @@ t CREATE TABLE `t` (
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end))
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end))
|
||||
with system versioning;
|
||||
select * from t for system_time all;
|
||||
a
|
||||
alter table t drop column sys_trx_start;
|
||||
alter table t drop column sys_trx_end;
|
||||
alter table t drop column row_start;
|
||||
alter table t drop column row_end;
|
||||
select * from t for system_time all;
|
||||
a
|
||||
alter table t drop column sys_trx_start;
|
||||
ERROR 42000: Can't DROP COLUMN `sys_trx_start`; check that it exists
|
||||
alter table t drop column sys_trx_end;
|
||||
ERROR 42000: Can't DROP COLUMN `sys_trx_end`; check that it exists
|
||||
alter table t drop column row_start;
|
||||
ERROR 42000: Can't DROP COLUMN `row_start`; check that it exists
|
||||
alter table t drop column row_end;
|
||||
ERROR 42000: Can't DROP COLUMN `row_end`; check that it exists
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end))
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end))
|
||||
with system versioning;
|
||||
select * from t for system_time all;
|
||||
a
|
||||
alter table t drop column sys_trx_start, drop column sys_trx_end;
|
||||
alter table t drop column row_start, drop column row_end;
|
||||
select * from t for system_time all;
|
||||
a
|
||||
create or replace table t(
|
||||
@ -172,10 +172,10 @@ a
|
||||
3
|
||||
2
|
||||
1
|
||||
select sys_trx_start from t where a=3 into @tm;
|
||||
select row_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
|
||||
select @tm=row_start from t where a=3;
|
||||
@tm=row_start
|
||||
1
|
||||
show create table t;
|
||||
Table Create Table
|
||||
@ -374,31 +374,31 @@ a b
|
||||
4 2
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end)
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end)
|
||||
) with system versioning;
|
||||
alter table t change column sys_trx_start asdf timestamp(6);
|
||||
ERROR HY000: Can not change system versioning field `sys_trx_start`
|
||||
alter table t change column row_start asdf timestamp(6);
|
||||
ERROR HY000: Can not change system versioning field `row_start`
|
||||
insert into t values (1);
|
||||
alter table t modify column sys_trx_start bigint unsigned;
|
||||
ERROR HY000: Can not change system versioning field `sys_trx_start`
|
||||
alter table t modify column row_start bigint unsigned;
|
||||
ERROR HY000: Can not change system versioning field `row_start`
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end)
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end)
|
||||
) with system versioning;
|
||||
select * from t;
|
||||
a
|
||||
alter table t drop system versioning;
|
||||
ERROR HY000: System versioning field `sys_trx_start` exists
|
||||
alter table t drop column sys_trx_start;
|
||||
ERROR HY000: System versioning field `row_start` exists
|
||||
alter table t drop column row_start;
|
||||
select * from t;
|
||||
a
|
||||
alter table t drop system versioning;
|
||||
ERROR HY000: System versioning field `sys_trx_end` exists
|
||||
alter table t drop column sys_trx_end;
|
||||
ERROR HY000: System versioning field `row_end` exists
|
||||
alter table t drop column row_end;
|
||||
select * from t;
|
||||
a
|
||||
alter table t drop system versioning;
|
||||
@ -450,20 +450,20 @@ alter table t drop column a;
|
||||
ERROR HY000: Table `t` must have at least one versioned column
|
||||
alter table t drop column a, drop column a;
|
||||
ERROR 42000: Can't DROP COLUMN `a`; check that it exists
|
||||
create or replace table t1 (sys_trx_start int);
|
||||
create or replace table t1 (row_start int);
|
||||
alter table t1 with system versioning;
|
||||
ERROR 42S21: Duplicate column name 'sys_trx_start'
|
||||
create or replace table t1 (sys_trx_end int);
|
||||
ERROR 42S21: Duplicate column name 'row_start'
|
||||
create or replace table t1 (row_end int);
|
||||
alter table t1 with system versioning;
|
||||
ERROR 42S21: Duplicate column name 'sys_trx_end'
|
||||
create or replace table t1 (a int, sys_trx_start int) with system versioning;
|
||||
ERROR 42S21: Duplicate column name 'sys_trx_start'
|
||||
ERROR 42S21: Duplicate column name 'row_end'
|
||||
create or replace table t1 (a int, row_start int) with system versioning;
|
||||
ERROR 42S21: Duplicate column name 'row_start'
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
set statement system_versioning_alter_history=keep for
|
||||
alter table t1 add column sys_trx_start int;
|
||||
ERROR 42S21: Duplicate column name 'sys_trx_start'
|
||||
alter table t1 add column row_start int;
|
||||
ERROR 42S21: Duplicate column name 'row_start'
|
||||
set statement system_versioning_alter_history=keep for
|
||||
alter table t1 add column sys_trx_start timestamp(6);
|
||||
ERROR 42S21: Duplicate column name 'sys_trx_start'
|
||||
alter table t1 add column row_start timestamp(6);
|
||||
ERROR 42S21: Duplicate column name 'row_start'
|
||||
drop database test;
|
||||
create database test;
|
||||
|
@ -211,7 +211,7 @@ t3 CREATE TABLE `t3` (
|
||||
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
|
||||
## For versioned table
|
||||
insert into t1 values (1);
|
||||
select sys_trx_start from t1 into @sys_trx_start;
|
||||
select row_start from t1 into @row_start;
|
||||
insert into t0 (y) values (2);
|
||||
select st from t0 into @st;
|
||||
create or replace table t2 with system versioning as select * from t1;
|
||||
@ -224,7 +224,7 @@ t2 CREATE TABLE `t2` (
|
||||
select * from t2;
|
||||
x23
|
||||
1
|
||||
select * from t2 where sys_trx_start <= @sys_trx_start;
|
||||
select * from t2 where row_start <= @row_start;
|
||||
x23
|
||||
### 2. source table with visible system fields, target with invisible
|
||||
create or replace table t3 with system versioning as select * from t0;
|
||||
@ -237,7 +237,7 @@ t3 CREATE TABLE `t3` (
|
||||
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
|
||||
select * from t3 where y > 2;
|
||||
y st en
|
||||
select y from t3 where st = @st and sys_trx_start > @st;
|
||||
select y from t3 where st = @st and row_start > @st;
|
||||
y
|
||||
2
|
||||
### 3. source and target table with visible system fields
|
||||
@ -269,13 +269,13 @@ t3 CREATE TABLE `t3` (
|
||||
select * from t3;
|
||||
x23
|
||||
1
|
||||
create or replace table t3 with system versioning select x23, sys_trx_start from t1;
|
||||
create or replace table t3 with system versioning select x23, row_start from t1;
|
||||
ERROR HY000: Wrong parameters for `t3`: missing 'AS ROW END'
|
||||
create or replace table t3 with system versioning select x23, sys_trx_end from t1;
|
||||
create or replace table t3 with system versioning select x23, row_end from t1;
|
||||
ERROR HY000: Wrong parameters for `t3`: missing 'AS ROW START'
|
||||
# Prepare checking for historical row
|
||||
delete from t1;
|
||||
select sys_trx_end from t1 for system_time all into @sys_trx_end;
|
||||
select row_end from t1 for system_time all into @row_end;
|
||||
delete from t0;
|
||||
select en from t0 for system_time all into @en;
|
||||
## Combinations of versioned + non-versioned
|
||||
@ -291,7 +291,7 @@ t3 CREATE TABLE `t3` (
|
||||
select * from t3 for system_time all;
|
||||
x23 y
|
||||
1 3
|
||||
select * from t3 for system_time all where sys_trx_start = @sys_trx_start and sys_trx_end = @sys_trx_end;
|
||||
select * from t3 for system_time all where row_start = @row_start and row_end = @row_end;
|
||||
x23 y
|
||||
create or replace table t2 like t0;
|
||||
insert into t2 (y) values (1), (2);
|
||||
@ -308,14 +308,14 @@ y
|
||||
## Default engine detection
|
||||
create or replace table t1 (x25 int) with system versioning engine NON_DEFAULT_ENGINE;
|
||||
create or replace table t2
|
||||
as select x25, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||
as select x25, row_start, row_end from t1 for system_time all;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`x25` int(11) DEFAULT NULL
|
||||
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1
|
||||
create or replace table t2 with system versioning
|
||||
as select x25, sys_trx_start, sys_trx_end from t1;
|
||||
as select x25, row_start, row_end from t1;
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
@ -333,7 +333,7 @@ ERROR HY000: `st` must be of type TIMESTAMP(6) for system-versioned table `t2`
|
||||
create or replace table t1 (x27 int, id int) with system versioning engine NON_DEFAULT_ENGINE;
|
||||
create or replace table t2 (b int, id int);
|
||||
create or replace table t3 with system versioning
|
||||
as select t2.b, t1.x27, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
|
||||
as select t2.b, t1.x27, t1.row_start, t1.row_end from t2 inner join t1 on t2.id=t1.id;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
@ -368,7 +368,7 @@ en SYS_DATATYPE as row end invisible,
|
||||
period for system_time (st, en)
|
||||
) with system versioning;
|
||||
create or replace table t3
|
||||
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
as select x30, y, row_start, row_end, st, en from t1, t2;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
@ -383,7 +383,7 @@ st SYS_DATATYPE as row start invisible,
|
||||
en SYS_DATATYPE as row end invisible,
|
||||
period for system_time (st, en)
|
||||
) with system versioning
|
||||
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
as select x30, y, row_start, row_end, st, en from t1, t2;
|
||||
show create table t3;
|
||||
Table Create Table
|
||||
t3 CREATE TABLE `t3` (
|
||||
|
@ -43,10 +43,10 @@ execute stmt;
|
||||
emp_id name mgr
|
||||
4 john 1
|
||||
drop prepare stmt;
|
||||
select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp;
|
||||
select emp_id from (select emp_id from emp where row_end>'2031-1-1') as tmp;
|
||||
emp_id
|
||||
4
|
||||
set @tmp= "select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp";
|
||||
set @tmp= "select emp_id from (select emp_id from emp where row_end>'2031-1-1') as tmp";
|
||||
prepare stmt from @tmp;
|
||||
execute stmt;
|
||||
emp_id
|
||||
@ -134,11 +134,11 @@ set @t0= now(6);
|
||||
delete from t1;
|
||||
insert into t1 values (2);
|
||||
insert into t2 values (10);
|
||||
select * from (select *, t1.sys_trx_end, t1.sys_trx_end as endo from t1) as s0;
|
||||
x sys_trx_end endo
|
||||
select * from (select *, t1.row_end, t1.row_end as endo from t1) as s0;
|
||||
x row_end endo
|
||||
2 # #
|
||||
select * from (select *, t1.sys_trx_end, t2.sys_trx_start from t1, t2) as s0;
|
||||
x y sys_trx_end sys_trx_start
|
||||
select * from (select *, t1.row_end, t2.row_start from t1, t2) as s0;
|
||||
x y row_end row_start
|
||||
2 10 # #
|
||||
# SYSTEM_TIME propagation from inner to outer
|
||||
select * from (select * from t1 for system_time as of timestamp @t0, t2) as s0;
|
||||
@ -148,11 +148,11 @@ with s1 as (select * from t1 for system_time as of timestamp @t0, t2) select * f
|
||||
x y
|
||||
1 10
|
||||
# leading table selection
|
||||
select * from (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) as s2;
|
||||
y x sys_trx_end
|
||||
select * from (select *, t1.row_end from t2, t1 for system_time as of timestamp @t0) as s2;
|
||||
y x row_end
|
||||
10 1 #
|
||||
with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) select * from s3;
|
||||
y x sys_trx_end
|
||||
with s3 as (select *, t1.row_end from t2, t1 for system_time as of timestamp @t0) select * from s3;
|
||||
y x row_end
|
||||
10 1 #
|
||||
### VIEW instead of t1
|
||||
set @q= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t0, "'");
|
||||
@ -211,12 +211,12 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Query A:
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(current_timestamp(6) as datetime(6)))
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`row_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t1`.`row_start` <= <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`row_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`row_start` <= <cache>(cast(current_timestamp(6) as datetime(6)))
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Query B:
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(current_timestamp(6) as datetime(6)))
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`row_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t1`.`row_start` <= <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`row_end` > <cache>(cast(current_timestamp(6) as datetime(6))) and `test`.`t2`.`row_start` <= <cache>(cast(current_timestamp(6) as datetime(6)))
|
||||
Fine result: queries A and B are equal.
|
||||
## LEFT JOIN: t1, t2 versioned
|
||||
select * from (
|
||||
|
@ -80,10 +80,10 @@ set @str= concat('
|
||||
engine ', engine);
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
insert into t1 values(1, 1, 1);
|
||||
select sys_trx_start, sys_trx_end from t1 into @sys_start, @sys_end;
|
||||
select row_start, row_end from t1 into @sys_start, @sys_end;
|
||||
select id, a, b from t1;
|
||||
insert into t1 values(2, 2, 2);
|
||||
select id, a, b, sys_trx_start > @sys_start as C, sys_trx_end = @sys_end as D from t1 where id = 2;
|
||||
select id, a, b, row_start > @sys_start as C, row_end = @sys_end as D from t1 where id = 2;
|
||||
drop table t1;
|
||||
end~~
|
||||
create procedure test_05(
|
||||
@ -306,18 +306,18 @@ x y current
|
||||
1 1 0
|
||||
create or replace table t1 (x int) with system versioning engine innodb;
|
||||
insert into t1 values (1), (2);
|
||||
insert into t1 (sys_trx_start) select sys_trx_end from t1;
|
||||
ERROR HY000: The value specified for generated column 'sys_trx_start' in table 't1' ignored
|
||||
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, 1);
|
||||
ERROR HY000: The value specified for generated column 'sys_trx_end' in table 't1' ignored
|
||||
insert into t1 (row_start) select row_end from t1;
|
||||
ERROR HY000: The value specified for generated column 'row_start' in table 't1' ignored
|
||||
insert into t1 (row_start, row_end) values (DEFAULT, 1);
|
||||
ERROR HY000: The value specified for generated column 'row_end' in table 't1' ignored
|
||||
select @@sql_mode into @saved_mode;
|
||||
set sql_mode= '';
|
||||
insert into t1 (x, sys_trx_start, sys_trx_end) values (3, 4, 5);
|
||||
insert into t1 (x, row_start, row_end) values (3, 4, 5);
|
||||
Warnings:
|
||||
Warning 1906 The value specified for generated column 'sys_trx_start' in table 't1' ignored
|
||||
Warning 1906 The value specified for generated column 'sys_trx_end' in table 't1' ignored
|
||||
Warning 1906 The value specified for generated column 'row_start' in table 't1' ignored
|
||||
Warning 1906 The value specified for generated column 'row_end' in table 't1' ignored
|
||||
set sql_mode= @saved_mode;
|
||||
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, DEFAULT);
|
||||
insert into t1 (row_start, row_end) values (DEFAULT, DEFAULT);
|
||||
select * from t1;
|
||||
x
|
||||
1
|
||||
|
@ -127,9 +127,9 @@ partition p0 history,
|
||||
partition pn current);
|
||||
set @now= now(6);
|
||||
insert into t1 values (1);
|
||||
set @str= concat('select x, sys_trx_start < @now as A, sys_trx_end > @now as B from t1 partition (p0)');
|
||||
set @str= concat('select x, row_start < @now as A, row_end > @now as B from t1 partition (p0)');
|
||||
prepare select_p0 from @str;
|
||||
set @str= concat('select x, sys_trx_start > @now as C, sys_trx_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
|
||||
set @str= concat('select x, row_start > @now as C, row_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
|
||||
prepare select_pn from @str;
|
||||
execute select_p0;
|
||||
x A B
|
||||
@ -140,7 +140,7 @@ x C D
|
||||
explain partitions select * from tN;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
N SIMPLE tN pn system NULL NULL NULL NULL N
|
||||
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts0');
|
||||
set @str= concat('select row_start from t1 partition (pn) into @ts0');
|
||||
prepare stmt from @str;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
@ -151,7 +151,7 @@ x A B
|
||||
1 1 1
|
||||
execute select_pn;
|
||||
x C D
|
||||
set @str= concat('select sys_trx_start from t1 partition (p0) into @ts1');
|
||||
set @str= concat('select row_start from t1 partition (p0) into @ts1');
|
||||
prepare stmt from @str;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
@ -166,7 +166,7 @@ x A B
|
||||
execute select_pn;
|
||||
x C D
|
||||
2 1 1
|
||||
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts0');
|
||||
set @str= concat('select row_start from t1 partition (pn) into @ts0');
|
||||
prepare stmt from @str;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
@ -181,15 +181,15 @@ x C D
|
||||
3 1 1
|
||||
drop prepare select_p0;
|
||||
drop prepare select_pn;
|
||||
set @str= concat('select sys_trx_start from t1 partition (p0) where x = 2 into @ts1');
|
||||
set @str= concat('select row_start from t1 partition (p0) where x = 2 into @ts1');
|
||||
prepare stmt from @str;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
set @str= concat('select sys_trx_end from t1 partition (p0) where x = 2 into @ts2');
|
||||
set @str= concat('select row_end from t1 partition (p0) where x = 2 into @ts2');
|
||||
prepare stmt from @str;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts3');
|
||||
set @str= concat('select row_start from t1 partition (pn) into @ts3');
|
||||
prepare stmt from @str;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
|
@ -1,7 +1,7 @@
|
||||
call create_table('t', 'x int');
|
||||
insert t values (1, 2);
|
||||
replace t values (1, 3);
|
||||
select *, current_row(sys_trx_end) as current from t for system_time all
|
||||
select *, current_row(row_end) as current from t for system_time all
|
||||
order by x;
|
||||
id x current
|
||||
1 2 0
|
||||
|
@ -153,21 +153,21 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`x` AS `IJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6)))
|
||||
Note 1003 select `test`.`t1`.`x` AS `IJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL join `test`.`t2` FOR SYSTEM_TIME ALL where `test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`row_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`row_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`row_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`row_start` <= <cache>(cast(@`t0` as datetime(6)))
|
||||
explain extended select * from (select t1.x as LJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 left join t2 on t1.x = t2.x)
|
||||
for system_time as of timestamp @t0 as t;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`x` AS `LJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL left join `test`.`t2` FOR SYSTEM_TIME ALL on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6)))) where 1
|
||||
Note 1003 select `test`.`t1`.`x` AS `LJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t1` FOR SYSTEM_TIME ALL left join `test`.`t2` FOR SYSTEM_TIME ALL on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t1`.`row_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`row_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`row_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`row_start` <= <cache>(cast(@`t0` as datetime(6)))) where 1
|
||||
explain extended select * from (select t1.x as RJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 right join t2 on t1.x = t2.x)
|
||||
for system_time as of timestamp @t0 as t;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`x` AS `RJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t2` FOR SYSTEM_TIME ALL left join `test`.`t1` FOR SYSTEM_TIME ALL on(`test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`sys_trx_start` <= <cache>(cast(@`t0` as datetime(6)))) where 1
|
||||
Note 1003 select `test`.`t1`.`x` AS `RJ2_x1`,`test`.`t1`.`y` AS `y1`,`test`.`t2`.`x` AS `x2`,`test`.`t2`.`y` AS `y2` from `test`.`t2` FOR SYSTEM_TIME ALL left join `test`.`t1` FOR SYSTEM_TIME ALL on(`test`.`t1`.`x` = `test`.`t2`.`x` and `test`.`t1`.`row_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t1`.`row_start` <= <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`row_end` > <cache>(cast(@`t0` as datetime(6))) and `test`.`t2`.`row_start` <= <cache>(cast(@`t0` as datetime(6)))) where 1
|
||||
select * from (select t1.x as IJ2_x1, t1.y as y1, t2.x as x2, t2.y as y2 from t1 inner join t2 on t1.x = t2.x)
|
||||
for system_time as of timestamp @t0 as t;
|
||||
IJ2_x1 y1 x2 y2
|
||||
@ -233,7 +233,7 @@ x x
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
insert into t1 values (1);
|
||||
create trigger read_end after update on t1
|
||||
for each row set @end = old.sys_trx_end;
|
||||
for each row set @end = old.row_end;
|
||||
update t1 set a=2;
|
||||
select @end;
|
||||
@end
|
||||
@ -397,14 +397,14 @@ ERROR 42S22: Unknown column 'now' in 'where clause'
|
||||
### Issue #405, NATURAL JOIN failure
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create or replace table t2 (b int);
|
||||
create or replace view v1 as select a, sys_trx_start, sys_trx_end from t1 where a > round(rand()*1000);
|
||||
create or replace view v1 as select a, row_start, row_end from t1 where a > round(rand()*1000);
|
||||
select * from v1 natural join t2;
|
||||
a b
|
||||
### Issue #406, MDEV-14633 Assertion on TRT read
|
||||
create or replace table t1 (pk int primary key, i int, t time, key (i)) with system versioning;
|
||||
insert into t1 values (1, 10, '15:01:53'), (2, 20, '00:00:00');
|
||||
delete from t1;
|
||||
select * from t1 where t = '00:00:00' and i > 0 and sys_trx_end <> '2012-12-12 00:00:00';
|
||||
select * from t1 where t = '00:00:00' and i > 0 and row_end <> '2012-12-12 00:00:00';
|
||||
pk i t
|
||||
drop view v1;
|
||||
drop table t1, t2;
|
||||
|
@ -287,7 +287,7 @@ x x
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
insert into t1 values (1);
|
||||
create trigger read_end after update on t1
|
||||
for each row set @end = old.sys_trx_end;
|
||||
for each row set @end = old.row_end;
|
||||
update t1 set a=2;
|
||||
select @end;
|
||||
@end
|
||||
|
@ -18,16 +18,16 @@ with system versioning;
|
||||
select now() into @ts_0;
|
||||
insert into dept (dept_id, name) values (10, "accounting");
|
||||
commit;
|
||||
select sys_trx_start into @ts_1 from dept where dept_id=10;
|
||||
select row_start into @ts_1 from dept where dept_id=10;
|
||||
insert into emp (emp_id, name, salary, dept_id) values (1, "bill", 1000, 10);
|
||||
commit;
|
||||
select sys_trx_start into @ts_2 from emp where name="bill";
|
||||
select row_start into @ts_2 from emp where name="bill";
|
||||
select * from emp;
|
||||
emp_id dept_id name salary
|
||||
1 10 bill 1000
|
||||
update emp set salary=2000 where name="bill";
|
||||
commit;
|
||||
select sys_trx_start into @ts_3 from emp where name="bill";
|
||||
select row_start into @ts_3 from emp where name="bill";
|
||||
select * from emp;
|
||||
emp_id dept_id name salary
|
||||
1 10 bill 2000
|
||||
|
@ -8,7 +8,7 @@ set @vt1= concat("create or replace view vt1 as select * from t1 for system_time
|
||||
prepare stmt from @vt1;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
set @vt2= concat("create or replace view vt2 as select *, sys_trx_end from t1 for system_time as of timestamp '", @t2, "'");
|
||||
set @vt2= concat("create or replace view vt2 as select *, row_end from t1 for system_time as of timestamp '", @t2, "'");
|
||||
prepare stmt from @vt2;
|
||||
execute stmt;
|
||||
drop prepare stmt;
|
||||
@ -17,7 +17,7 @@ x
|
||||
create or replace view vt1 as select * from t1;
|
||||
show create view vt1;
|
||||
View Create View character_set_client collation_connection
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`x` AS `x` from `t1` FOR SYSTEM_TIME ALL where `t1`.`sys_trx_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`x` AS `x` from `t1` FOR SYSTEM_TIME ALL where `t1`.`row_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
drop view vt1;
|
||||
drop view vt2;
|
||||
create or replace view vt1 as select * from t1 for system_time all;
|
||||
@ -69,7 +69,7 @@ create or replace table t1 (x int) with system versioning;
|
||||
create or replace view vt1(c) as select x from t1;
|
||||
show create view vt1;
|
||||
View Create View character_set_client collation_connection
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`x` AS `c` from `t1` FOR SYSTEM_TIME ALL where `t1`.`sys_trx_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`x` AS `c` from `t1` FOR SYSTEM_TIME ALL where `t1`.`row_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
# VIEW over JOIN of versioned tables [#153]
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create or replace table t2 (b int) with system versioning;
|
||||
@ -87,15 +87,15 @@ create or replace table t3 (x int);
|
||||
create or replace view vt1 as select * from t1, t2, t3;
|
||||
show create view vt1;
|
||||
View Create View character_set_client collation_connection
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,`t3`.`x` AS `x` from ((`t1` FOR SYSTEM_TIME ALL join `t2` FOR SYSTEM_TIME ALL) join `t3`) where `t1`.`sys_trx_end` = MAX_RESULT and `t2`.`sys_trx_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,`t3`.`x` AS `x` from ((`t1` FOR SYSTEM_TIME ALL join `t2` FOR SYSTEM_TIME ALL) join `t3`) where `t1`.`row_end` = MAX_RESULT and `t2`.`row_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
create or replace view vt1 as select * from t3, t2, t1;
|
||||
show create view vt1;
|
||||
View Create View character_set_client collation_connection
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t3`.`x` AS `x`,`t2`.`b` AS `b`,`t1`.`a` AS `a` from ((`t3` join `t2` FOR SYSTEM_TIME ALL) join `t1` FOR SYSTEM_TIME ALL) where `t2`.`sys_trx_end` = MAX_RESULT and `t1`.`sys_trx_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
create or replace view vt1 as select a, t2.sys_trx_end as endo from t3, t1, t2;
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t3`.`x` AS `x`,`t2`.`b` AS `b`,`t1`.`a` AS `a` from ((`t3` join `t2` FOR SYSTEM_TIME ALL) join `t1` FOR SYSTEM_TIME ALL) where `t2`.`row_end` = MAX_RESULT and `t1`.`row_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
create or replace view vt1 as select a, t2.row_end as endo from t3, t1, t2;
|
||||
show create view vt1;
|
||||
View Create View character_set_client collation_connection
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`sys_trx_end` AS `endo` from ((`t3` join `t1` FOR SYSTEM_TIME ALL) join `t2` FOR SYSTEM_TIME ALL) where `t1`.`sys_trx_end` = MAX_RESULT and `t2`.`sys_trx_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`row_end` AS `endo` from ((`t3` join `t1` FOR SYSTEM_TIME ALL) join `t2` FOR SYSTEM_TIME ALL) where `t1`.`row_end` = MAX_RESULT and `t2`.`row_end` = MAX_RESULT latin1 latin1_swedish_ci
|
||||
# VIEW over UNION [#269]
|
||||
create or replace view vt1 as select * from t1 union select * from t1;
|
||||
select * from vt1;
|
||||
|
@ -72,30 +72,30 @@ show create table t;
|
||||
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end))
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end))
|
||||
with system versioning;
|
||||
|
||||
select * from t for system_time all;
|
||||
alter table t drop column sys_trx_start;
|
||||
alter table t drop column sys_trx_end;
|
||||
alter table t drop column row_start;
|
||||
alter table t drop column row_end;
|
||||
select * from t for system_time all;
|
||||
|
||||
--error ER_CANT_DROP_FIELD_OR_KEY
|
||||
alter table t drop column sys_trx_start;
|
||||
alter table t drop column row_start;
|
||||
--error ER_CANT_DROP_FIELD_OR_KEY
|
||||
alter table t drop column sys_trx_end;
|
||||
alter table t drop column row_end;
|
||||
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end))
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end))
|
||||
with system versioning;
|
||||
|
||||
select * from t for system_time all;
|
||||
alter table t drop column sys_trx_start, drop column sys_trx_end;
|
||||
alter table t drop column row_start, drop column row_end;
|
||||
select * from t for system_time all;
|
||||
|
||||
create or replace table t(
|
||||
@ -111,9 +111,9 @@ 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;
|
||||
select row_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;
|
||||
select @tm=row_start from t where a=3;
|
||||
show create table t;
|
||||
select * from t;
|
||||
select * from t for system_time all;
|
||||
@ -253,32 +253,32 @@ select * from t for system_time all;
|
||||
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end)
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end)
|
||||
) with system versioning;
|
||||
--error ER_VERS_ALTER_SYSTEM_FIELD
|
||||
alter table t change column sys_trx_start asdf timestamp(6);
|
||||
alter table t change column row_start asdf timestamp(6);
|
||||
insert into t values (1);
|
||||
--error ER_VERS_ALTER_SYSTEM_FIELD
|
||||
alter table t modify column sys_trx_start bigint unsigned;
|
||||
alter table t modify column row_start bigint unsigned;
|
||||
|
||||
create or replace table t (
|
||||
a int,
|
||||
sys_trx_start timestamp(6) as row start invisible,
|
||||
sys_trx_end timestamp(6) as row end invisible,
|
||||
period for system_time(sys_trx_start, sys_trx_end)
|
||||
row_start timestamp(6) as row start invisible,
|
||||
row_end timestamp(6) as row end invisible,
|
||||
period for system_time(row_start, row_end)
|
||||
) with system versioning;
|
||||
select * from t;
|
||||
|
||||
--error ER_VERS_SYS_FIELD_EXISTS
|
||||
alter table t drop system versioning;
|
||||
alter table t drop column sys_trx_start;
|
||||
alter table t drop column row_start;
|
||||
select * from t;
|
||||
|
||||
--error ER_VERS_SYS_FIELD_EXISTS
|
||||
alter table t drop system versioning;
|
||||
alter table t drop column sys_trx_end;
|
||||
alter table t drop column row_end;
|
||||
select * from t;
|
||||
|
||||
alter table t drop system versioning;
|
||||
@ -311,17 +311,17 @@ select * from t for system_time all;
|
||||
|
||||
create or replace table non_empty (
|
||||
a int,
|
||||
sys_trx_start bigint(20) unsigned,
|
||||
sys_trx_end bigint(20) unsigned
|
||||
row_start bigint(20) unsigned,
|
||||
row_end bigint(20) unsigned
|
||||
) engine innodb;
|
||||
insert into non_empty values (1, 100, 200);
|
||||
|
||||
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
|
||||
alter table non_empty
|
||||
change column sys_trx_start sys_trx_start bigint(20) unsigned as row start invisible;
|
||||
change column row_start row_start bigint(20) unsigned as row start invisible;
|
||||
--error ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
|
||||
alter table non_empty
|
||||
change column sys_trx_end sys_trx_end bigint(20) unsigned as row end invisible;
|
||||
change column row_end row_end bigint(20) unsigned as row end invisible;
|
||||
drop table non_empty;
|
||||
|
||||
create or replace table t (a int primary key) with system versioning;
|
||||
@ -383,26 +383,26 @@ alter table t drop column a;
|
||||
--error ER_CANT_DROP_FIELD_OR_KEY
|
||||
alter table t drop column a, drop column a;
|
||||
|
||||
create or replace table t1 (sys_trx_start int);
|
||||
create or replace table t1 (row_start int);
|
||||
--error ER_DUP_FIELDNAME
|
||||
alter table t1 with system versioning;
|
||||
|
||||
create or replace table t1 (sys_trx_end int);
|
||||
create or replace table t1 (row_end int);
|
||||
--error ER_DUP_FIELDNAME
|
||||
alter table t1 with system versioning;
|
||||
|
||||
--error ER_DUP_FIELDNAME
|
||||
create or replace table t1 (a int, sys_trx_start int) with system versioning;
|
||||
create or replace table t1 (a int, row_start int) with system versioning;
|
||||
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
|
||||
--error ER_DUP_FIELDNAME
|
||||
set statement system_versioning_alter_history=keep for
|
||||
alter table t1 add column sys_trx_start int;
|
||||
alter table t1 add column row_start int;
|
||||
|
||||
--error ER_DUP_FIELDNAME
|
||||
set statement system_versioning_alter_history=keep for
|
||||
alter table t1 add column sys_trx_start timestamp(6);
|
||||
alter table t1 add column row_start timestamp(6);
|
||||
|
||||
drop database test;
|
||||
create database test;
|
||||
|
@ -209,7 +209,7 @@ show create table t3;
|
||||
|
||||
--echo ## For versioned table
|
||||
insert into t1 values (1);
|
||||
select sys_trx_start from t1 into @sys_trx_start;
|
||||
select row_start from t1 into @row_start;
|
||||
insert into t0 (y) values (2);
|
||||
select st from t0 into @st;
|
||||
|
||||
@ -218,14 +218,14 @@ create or replace table t2 with system versioning as select * from t1;
|
||||
show create table t2;
|
||||
--echo #### invisible fields are not copied
|
||||
select * from t2;
|
||||
select * from t2 where sys_trx_start <= @sys_trx_start;
|
||||
select * from t2 where row_start <= @row_start;
|
||||
|
||||
--echo ### 2. source table with visible system fields, target with invisible
|
||||
create or replace table t3 with system versioning as select * from t0;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE $sys_datatype_not_null SYS_DATATYPE $sys_datatype_default_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
select * from t3 where y > 2;
|
||||
select y from t3 where st = @st and sys_trx_start > @st;
|
||||
select y from t3 where st = @st and row_start > @st;
|
||||
|
||||
--echo ### 3. source and target table with visible system fields
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
@ -245,13 +245,13 @@ create or replace table t3 with system versioning select x23 from t1;
|
||||
show create table t3;
|
||||
select * from t3;
|
||||
--error ER_MISSING
|
||||
create or replace table t3 with system versioning select x23, sys_trx_start from t1;
|
||||
create or replace table t3 with system versioning select x23, row_start from t1;
|
||||
--error ER_MISSING
|
||||
create or replace table t3 with system versioning select x23, sys_trx_end from t1;
|
||||
create or replace table t3 with system versioning select x23, row_end from t1;
|
||||
|
||||
--echo # Prepare checking for historical row
|
||||
delete from t1;
|
||||
select sys_trx_end from t1 for system_time all into @sys_trx_end;
|
||||
select row_end from t1 for system_time all into @row_end;
|
||||
delete from t0;
|
||||
select en from t0 for system_time all into @en;
|
||||
|
||||
@ -262,7 +262,7 @@ create or replace table t3 with system versioning select * from t1 for system_ti
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t3;
|
||||
select * from t3 for system_time all;
|
||||
select * from t3 for system_time all where sys_trx_start = @sys_trx_start and sys_trx_end = @sys_trx_end;
|
||||
select * from t3 for system_time all where row_start = @row_start and row_end = @row_end;
|
||||
|
||||
create or replace table t2 like t0;
|
||||
insert into t2 (y) values (1), (2);
|
||||
@ -278,12 +278,12 @@ select y from t2 for system_time all where st = @st and en = @en;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
eval create or replace table t1 (x25 int) with system versioning engine $non_default_engine;
|
||||
create or replace table t2
|
||||
as select x25, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||
as select x25, row_start, row_end from t1 for system_time all;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE
|
||||
show create table t2;
|
||||
|
||||
create or replace table t2 with system versioning
|
||||
as select x25, sys_trx_start, sys_trx_end from t1;
|
||||
as select x25, row_start, row_end from t1;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
|
||||
show create table t2;
|
||||
|
||||
@ -301,7 +301,7 @@ as select * from t1;
|
||||
eval create or replace table t1 (x27 int, id int) with system versioning engine $non_default_engine;
|
||||
create or replace table t2 (b int, id int);
|
||||
create or replace table t3 with system versioning
|
||||
as select t2.b, t1.x27, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
|
||||
as select t2.b, t1.x27, t1.row_start, t1.row_end from t2 inner join t1 on t2.id=t1.id;
|
||||
--replace_result $non_default_engine NON_DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
|
||||
@ -339,7 +339,7 @@ eval create or replace table t2 (
|
||||
) with system versioning;
|
||||
|
||||
create or replace table t3
|
||||
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
as select x30, y, row_start, row_end, st, en from t1, t2;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE $sys_datatype_not_null SYS_DATATYPE $sys_datatype_default_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
|
||||
@ -350,7 +350,7 @@ eval create or replace table t3 (
|
||||
en $sys_datatype as row end invisible,
|
||||
period for system_time (st, en)
|
||||
) with system versioning
|
||||
as select x30, y, sys_trx_start, sys_trx_end, st, en from t1, t2;
|
||||
as select x30, y, row_start, row_end, st, en from t1, t2;
|
||||
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE $sys_datatype_null SYS_DATATYPE $sys_datatype_not_null SYS_DATATYPE $sys_datatype_default_null SYS_DATATYPE
|
||||
show create table t3;
|
||||
|
||||
|
@ -24,8 +24,8 @@ with recursive ancestors as (select * from emp) select * from ancestors;
|
||||
set @tmp= "with recursive ancestors as (select * from emp) select * from ancestors";
|
||||
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
||||
|
||||
select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp;
|
||||
set @tmp= "select emp_id from (select emp_id from emp where sys_trx_end>'2031-1-1') as tmp";
|
||||
select emp_id from (select emp_id from emp where row_end>'2031-1-1') as tmp;
|
||||
set @tmp= "select emp_id from (select emp_id from emp where row_end>'2031-1-1') as tmp";
|
||||
prepare stmt from @tmp; execute stmt; drop prepare stmt;
|
||||
|
||||
with recursive
|
||||
@ -100,18 +100,18 @@ insert into t1 values (2);
|
||||
insert into t2 values (10);
|
||||
|
||||
--replace_column 2 # 3 #
|
||||
select * from (select *, t1.sys_trx_end, t1.sys_trx_end as endo from t1) as s0;
|
||||
select * from (select *, t1.row_end, t1.row_end as endo from t1) as s0;
|
||||
--replace_column 3 # 4 #
|
||||
select * from (select *, t1.sys_trx_end, t2.sys_trx_start from t1, t2) as s0;
|
||||
select * from (select *, t1.row_end, t2.row_start from t1, t2) as s0;
|
||||
|
||||
--echo # SYSTEM_TIME propagation from inner to outer
|
||||
select * from (select * from t1 for system_time as of timestamp @t0, t2) as s0;
|
||||
with s1 as (select * from t1 for system_time as of timestamp @t0, t2) select * from s1;
|
||||
--echo # leading table selection
|
||||
--replace_column 3 #
|
||||
select * from (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) as s2;
|
||||
select * from (select *, t1.row_end from t2, t1 for system_time as of timestamp @t0) as s2;
|
||||
--replace_column 3 #
|
||||
with s3 as (select *, t1.sys_trx_end from t2, t1 for system_time as of timestamp @t0) select * from s3;
|
||||
with s3 as (select *, t1.row_end from t2, t1 for system_time as of timestamp @t0) select * from s3;
|
||||
|
||||
--echo ### VIEW instead of t1
|
||||
set @q= concat("create view vt1 as select * from t1 for system_time as of timestamp '", @t0, "'");
|
||||
|
@ -86,10 +86,10 @@ begin
|
||||
engine ', engine);
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
insert into t1 values(1, 1, 1);
|
||||
select sys_trx_start, sys_trx_end from t1 into @sys_start, @sys_end;
|
||||
select row_start, row_end from t1 into @sys_start, @sys_end;
|
||||
select id, a, b from t1;
|
||||
insert into t1 values(2, 2, 2);
|
||||
select id, a, b, sys_trx_start > @sys_start as C, sys_trx_end = @sys_end as D from t1 where id = 2;
|
||||
select id, a, b, row_start > @sys_start as C, row_end = @sys_end as D from t1 where id = 2;
|
||||
drop table t1;
|
||||
end~~
|
||||
|
||||
@ -209,14 +209,14 @@ select x, y, sys_trx_end = 18446744073709551615 as current from t1 for system_ti
|
||||
create or replace table t1 (x int) with system versioning engine innodb;
|
||||
insert into t1 values (1), (2);
|
||||
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
|
||||
insert into t1 (sys_trx_start) select sys_trx_end from t1;
|
||||
insert into t1 (row_start) select row_end from t1;
|
||||
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
|
||||
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, 1);
|
||||
insert into t1 (row_start, row_end) values (DEFAULT, 1);
|
||||
select @@sql_mode into @saved_mode;
|
||||
set sql_mode= '';
|
||||
insert into t1 (x, sys_trx_start, sys_trx_end) values (3, 4, 5);
|
||||
insert into t1 (x, row_start, row_end) values (3, 4, 5);
|
||||
set sql_mode= @saved_mode;
|
||||
insert into t1 (sys_trx_start, sys_trx_end) values (DEFAULT, DEFAULT);
|
||||
insert into t1 (row_start, row_end) values (DEFAULT, DEFAULT);
|
||||
select * from t1;
|
||||
|
||||
--echo # MDEV-14792 INSERT without column list into table with explicit versioning columns produces bad data
|
||||
|
@ -131,9 +131,9 @@ partition by system_time (
|
||||
|
||||
set @now= now(6);
|
||||
insert into t1 values (1);
|
||||
set @str= concat('select x, sys_trx_start < @now as A, sys_trx_end > @now as B from t1 partition (p0)');
|
||||
set @str= concat('select x, row_start < @now as A, row_end > @now as B from t1 partition (p0)');
|
||||
prepare select_p0 from @str;
|
||||
set @str= concat('select x, sys_trx_start > @now as C, sys_trx_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
|
||||
set @str= concat('select x, row_start > @now as C, row_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
|
||||
prepare select_pn from @str;
|
||||
|
||||
execute select_p0;
|
||||
@ -143,7 +143,7 @@ execute select_pn;
|
||||
--replace_regex /\d/N/ /ALL/system/ /Using where//
|
||||
explain partitions select * from t1;
|
||||
|
||||
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts0');
|
||||
set @str= concat('select row_start from t1 partition (pn) into @ts0');
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
|
||||
set @now= now(6);
|
||||
@ -151,7 +151,7 @@ delete from t1;
|
||||
execute select_p0;
|
||||
execute select_pn;
|
||||
|
||||
set @str= concat('select sys_trx_start from t1 partition (p0) into @ts1');
|
||||
set @str= concat('select row_start from t1 partition (p0) into @ts1');
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
|
||||
select @ts0 = @ts1;
|
||||
@ -161,7 +161,7 @@ insert into t1 values (2);
|
||||
execute select_p0;
|
||||
execute select_pn;
|
||||
|
||||
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts0');
|
||||
set @str= concat('select row_start from t1 partition (pn) into @ts0');
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
|
||||
set @now= now(6);
|
||||
@ -172,11 +172,11 @@ execute select_pn;
|
||||
drop prepare select_p0;
|
||||
drop prepare select_pn;
|
||||
|
||||
set @str= concat('select sys_trx_start from t1 partition (p0) where x = 2 into @ts1');
|
||||
set @str= concat('select row_start from t1 partition (p0) where x = 2 into @ts1');
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
set @str= concat('select sys_trx_end from t1 partition (p0) where x = 2 into @ts2');
|
||||
set @str= concat('select row_end from t1 partition (p0) where x = 2 into @ts2');
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts3');
|
||||
set @str= concat('select row_start from t1 partition (pn) into @ts3');
|
||||
prepare stmt from @str; execute stmt; drop prepare stmt;
|
||||
|
||||
select @ts0 = @ts1;
|
||||
|
@ -6,7 +6,7 @@ call create_table('t', 'x int');
|
||||
|
||||
insert t values (1, 2);
|
||||
replace t values (1, 3);
|
||||
select *, current_row(sys_trx_end) as current from t for system_time all
|
||||
select *, current_row(row_end) as current from t for system_time all
|
||||
order by x;
|
||||
|
||||
drop database test;
|
||||
|
@ -148,7 +148,7 @@ select * from (t1 as r left join t1 as u using (x)), t1;
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
insert into t1 values (1);
|
||||
create trigger read_end after update on t1
|
||||
for each row set @end = old.sys_trx_end;
|
||||
for each row set @end = old.row_end;
|
||||
update t1 set a=2;
|
||||
--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.999999" MAX_RESULT
|
||||
select @end;
|
||||
@ -272,7 +272,7 @@ select * from t1 for system_time as of now;
|
||||
--echo ### Issue #405, NATURAL JOIN failure
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
create or replace table t2 (b int);
|
||||
create or replace view v1 as select a, sys_trx_start, sys_trx_end from t1 where a > round(rand()*1000);
|
||||
create or replace view v1 as select a, row_start, row_end from t1 where a > round(rand()*1000);
|
||||
select * from v1 natural join t2;
|
||||
|
||||
--echo ### Issue #406, MDEV-14633 Assertion on TRT read
|
||||
@ -280,7 +280,7 @@ create or replace table t1 (pk int primary key, i int, t time, key (i)) with sys
|
||||
insert into t1 values (1, 10, '15:01:53'), (2, 20, '00:00:00');
|
||||
delete from t1;
|
||||
--disable_warnings
|
||||
select * from t1 where t = '00:00:00' and i > 0 and sys_trx_end <> '2012-12-12 00:00:00';
|
||||
select * from t1 where t = '00:00:00' and i > 0 and row_end <> '2012-12-12 00:00:00';
|
||||
--enable_warnings
|
||||
|
||||
drop view v1;
|
||||
|
@ -175,7 +175,7 @@ select * from (t1 as r left join t1 as u using (x)), t1;
|
||||
create or replace table t1 (a int) with system versioning;
|
||||
insert into t1 values (1);
|
||||
create trigger read_end after update on t1
|
||||
for each row set @end = old.sys_trx_end;
|
||||
for each row set @end = old.row_end;
|
||||
update t1 set a=2;
|
||||
--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.999999" MAX_RESULT
|
||||
select @end;
|
||||
|
@ -23,19 +23,19 @@ select now() into @ts_0;
|
||||
insert into dept (dept_id, name) values (10, "accounting");
|
||||
commit;
|
||||
|
||||
select sys_trx_start into @ts_1 from dept where dept_id=10;
|
||||
select row_start into @ts_1 from dept where dept_id=10;
|
||||
|
||||
insert into emp (emp_id, name, salary, dept_id) values (1, "bill", 1000, 10);
|
||||
commit;
|
||||
|
||||
select sys_trx_start into @ts_2 from emp where name="bill";
|
||||
select row_start into @ts_2 from emp where name="bill";
|
||||
|
||||
select * from emp;
|
||||
|
||||
update emp set salary=2000 where name="bill";
|
||||
commit;
|
||||
|
||||
select sys_trx_start into @ts_3 from emp where name="bill";
|
||||
select row_start into @ts_3 from emp where name="bill";
|
||||
|
||||
select * from emp;
|
||||
select * from emp for system_time as of timestamp @ts_2;
|
||||
|
@ -13,7 +13,7 @@ delete from t1;
|
||||
set @vt1= concat("create or replace view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'");
|
||||
prepare stmt from @vt1; execute stmt; drop prepare stmt;
|
||||
|
||||
set @vt2= concat("create or replace view vt2 as select *, sys_trx_end from t1 for system_time as of timestamp '", @t2, "'");
|
||||
set @vt2= concat("create or replace view vt2 as select *, row_end from t1 for system_time as of timestamp '", @t2, "'");
|
||||
prepare stmt from @vt2; execute stmt; drop prepare stmt;
|
||||
|
||||
select * from t1;
|
||||
@ -76,7 +76,7 @@ show create view vt1;
|
||||
create or replace view vt1 as select * from t3, t2, t1;
|
||||
--replace_result 18446744073709551615 MAX_RESULT "TIMESTAMP'2038-01-19 03:14:07.999999'" MAX_RESULT
|
||||
show create view vt1;
|
||||
create or replace view vt1 as select a, t2.sys_trx_end as endo from t3, t1, t2;
|
||||
create or replace view vt1 as select a, t2.row_end as endo from t3, t1, t2;
|
||||
--replace_result 18446744073709551615 MAX_RESULT "TIMESTAMP'2038-01-19 03:14:07.999999'" MAX_RESULT
|
||||
show create view vt1;
|
||||
|
||||
|
@ -6895,8 +6895,8 @@ static bool vers_create_sys_field(THD *thd, const char *field_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
const LString Vers_parse_info::default_start= "sys_trx_start";
|
||||
const LString Vers_parse_info::default_end= "sys_trx_end";
|
||||
const LString Vers_parse_info::default_start= "row_start";
|
||||
const LString Vers_parse_info::default_end= "row_end";
|
||||
|
||||
bool Vers_parse_info::fix_implicit(THD *thd, Alter_info *alter_info, int *added)
|
||||
{
|
||||
|
@ -13031,17 +13031,17 @@ int Rows_log_event::find_row(rpl_group_info *rgi)
|
||||
m_vers_from_plain= false;
|
||||
if (table->versioned())
|
||||
{
|
||||
Field *sys_trx_end= table->vers_end_field();
|
||||
Field *row_end= table->vers_end_field();
|
||||
DBUG_ASSERT(table->read_set);
|
||||
bitmap_set_bit(table->read_set, sys_trx_end->field_index);
|
||||
bitmap_set_bit(table->read_set, row_end->field_index);
|
||||
// check whether master table is unversioned
|
||||
if (sys_trx_end->val_int() == 0)
|
||||
if (row_end->val_int() == 0)
|
||||
{
|
||||
// sys_trx_start initialized with NULL when came from plain table.
|
||||
// row_start initialized with NULL when came from plain table.
|
||||
// Set it notnull() because record_compare() count NULLs.
|
||||
table->vers_start_field()->set_notnull();
|
||||
bitmap_set_bit(table->write_set, sys_trx_end->field_index);
|
||||
// Plain source table may have a PRIMARY KEY. And sys_trx_end is always
|
||||
bitmap_set_bit(table->write_set, row_end->field_index);
|
||||
// Plain source table may have a PRIMARY KEY. And row_end is always
|
||||
// a part of PRIMARY KEY. Set it to max value for engine to find it in
|
||||
// index. Needed for an UPDATE/DELETE cases.
|
||||
table->vers_end_field()->set_max();
|
||||
|
@ -90,7 +90,7 @@ typedef struct p_elem_val
|
||||
|
||||
struct st_ddl_log_memory_entry;
|
||||
|
||||
/* Used for collecting MIN/MAX stats on sys_trx_end for doing pruning
|
||||
/* Used for collecting MIN/MAX stats on row_end for doing pruning
|
||||
in SYSTEM_TIME partitiong. */
|
||||
class Vers_min_max_stats : public Sql_alloc
|
||||
{
|
||||
|
@ -975,11 +975,11 @@ bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add)
|
||||
else
|
||||
{
|
||||
/* Prepare part_field_list */
|
||||
Field *sys_trx_end= table->vers_end_field();
|
||||
part_field_list.push_back(sys_trx_end->field_name.str, thd->mem_root);
|
||||
Field *row_end= table->vers_end_field();
|
||||
part_field_list.push_back(row_end->field_name.str, thd->mem_root);
|
||||
DBUG_ASSERT(part_field_list.elements == num_columns);
|
||||
// needed in handle_list_of_fields()
|
||||
sys_trx_end->flags|= GET_FIXED_FIELDS_FLAG;
|
||||
row_end->flags|= GET_FIXED_FIELDS_FLAG;
|
||||
}
|
||||
|
||||
List_iterator<partition_element> it(partitions);
|
||||
@ -1090,7 +1090,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// scan table for min/max sys_trx_end
|
||||
// scan table for min/max row_end
|
||||
inline
|
||||
bool partition_info::vers_scan_min_max(THD *thd, partition_element *part)
|
||||
{
|
||||
|
@ -329,7 +329,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
||||
if (select_lex->vers_setup_conds(thd, table_list, &conds))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
// trx_sees() in InnoDB reads sys_trx_start
|
||||
// trx_sees() in InnoDB reads row_start
|
||||
if (!table->versioned(VERS_TIMESTAMP))
|
||||
{
|
||||
DBUG_ASSERT(table_list->vers_conditions.type == SYSTEM_TIME_BEFORE);
|
||||
|
@ -3161,19 +3161,19 @@ int vers_get_partition_id(partition_info *part_info,
|
||||
{
|
||||
DBUG_ENTER("vers_get_partition_id");
|
||||
DBUG_ASSERT(part_info);
|
||||
Field *sys_trx_end= part_info->part_field_array[STAT_TRX_END];
|
||||
DBUG_ASSERT(sys_trx_end);
|
||||
Field *row_end= part_info->part_field_array[STAT_TRX_END];
|
||||
DBUG_ASSERT(row_end);
|
||||
TABLE *table= part_info->table;
|
||||
DBUG_ASSERT(table);
|
||||
Vers_part_info *vers_info= part_info->vers_info;
|
||||
DBUG_ASSERT(vers_info);
|
||||
DBUG_ASSERT(vers_info->initialized());
|
||||
DBUG_ASSERT(sys_trx_end->table == table);
|
||||
DBUG_ASSERT(row_end->table == table);
|
||||
DBUG_ASSERT(table->versioned());
|
||||
DBUG_ASSERT(table->vers_end_field() == sys_trx_end);
|
||||
DBUG_ASSERT(table->vers_end_field() == row_end);
|
||||
|
||||
// new rows have NULL in sys_trx_end
|
||||
if (sys_trx_end->is_max() || sys_trx_end->is_null())
|
||||
// new rows have NULL in row_end
|
||||
if (row_end->is_max() || row_end->is_null())
|
||||
{
|
||||
*part_id= vers_info->now_part->id;
|
||||
}
|
||||
@ -3200,8 +3200,8 @@ int vers_get_partition_id(partition_info *part_info,
|
||||
mysql_mutex_unlock(&table->s->LOCK_rotation);
|
||||
// transaction is not yet pushed to VTQ, so we use now-time
|
||||
ulong sec_part;
|
||||
my_time_t end_ts= sys_trx_end->table->versioned(VERS_TRX_ID) ?
|
||||
my_time_t(0) : sys_trx_end->get_timestamp(&sec_part);
|
||||
my_time_t end_ts= row_end->table->versioned(VERS_TRX_ID) ?
|
||||
my_time_t(0) : row_end->get_timestamp(&sec_part);
|
||||
if (part_info->vers_limit_exceed() || part_info->vers_interval_exceed(end_ts))
|
||||
{
|
||||
part_info->vers_part_rotate(thd);
|
||||
|
@ -5381,7 +5381,7 @@ bool operator!=(const MYSQL_TIME &lhs, const MYSQL_TIME &rhs)
|
||||
lhs.time_type != rhs.time_type;
|
||||
}
|
||||
|
||||
// Sets sys_trx_end=MAX for rows with sys_trx_end=now(6)
|
||||
// Sets row_end=MAX for rows with row_end=now(6)
|
||||
static bool vers_reset_alter_copy(THD *thd, TABLE *table)
|
||||
{
|
||||
const MYSQL_TIME query_start= thd->query_start_TIME();
|
||||
@ -10172,7 +10172,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
bool make_versioned= !from->versioned() && to->versioned();
|
||||
bool make_unversioned= from->versioned() && !to->versioned();
|
||||
bool keep_versioned= from->versioned() && to->versioned();
|
||||
Field *to_sys_trx_start= NULL, *to_sys_trx_end= NULL, *from_sys_trx_end= NULL;
|
||||
Field *to_row_start= NULL, *to_row_end= NULL, *from_row_end= NULL;
|
||||
MYSQL_TIME query_start;
|
||||
DBUG_ENTER("copy_data_between_tables");
|
||||
|
||||
@ -10277,23 +10277,23 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
if (make_versioned)
|
||||
{
|
||||
query_start= thd->query_start_TIME();
|
||||
to_sys_trx_start= to->vers_start_field();
|
||||
to_sys_trx_end= to->vers_end_field();
|
||||
to_row_start= to->vers_start_field();
|
||||
to_row_end= to->vers_end_field();
|
||||
}
|
||||
else if (make_unversioned)
|
||||
{
|
||||
from_sys_trx_end= from->vers_end_field();
|
||||
from_row_end= from->vers_end_field();
|
||||
}
|
||||
else if (keep_versioned)
|
||||
{
|
||||
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
|
||||
{
|
||||
query_start= thd->query_start_TIME();
|
||||
from_sys_trx_end= from->vers_end_field();
|
||||
to_sys_trx_start= to->vers_start_field();
|
||||
from_row_end= from->vers_end_field();
|
||||
to_row_start= to->vers_start_field();
|
||||
} else if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_DROP)
|
||||
{
|
||||
from_sys_trx_end= from->vers_end_field();
|
||||
from_row_end= from->vers_end_field();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10352,32 +10352,32 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
||||
}
|
||||
|
||||
if (thd->variables.vers_alter_history == VERS_ALTER_HISTORY_DROP &&
|
||||
from_sys_trx_end && !from_sys_trx_end->is_max())
|
||||
from_row_end && !from_row_end->is_max())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (make_versioned)
|
||||
{
|
||||
to_sys_trx_start->set_notnull();
|
||||
to_sys_trx_start->store_time(&query_start);
|
||||
to_sys_trx_end->set_max();
|
||||
to_row_start->set_notnull();
|
||||
to_row_start->store_time(&query_start);
|
||||
to_row_end->set_max();
|
||||
}
|
||||
else if (make_unversioned)
|
||||
{
|
||||
if (!from_sys_trx_end->is_max())
|
||||
if (!from_row_end->is_max())
|
||||
continue; // Drop history rows.
|
||||
}
|
||||
else if (keep_versioned &&
|
||||
thd->variables.vers_alter_history == VERS_ALTER_HISTORY_SURVIVE)
|
||||
{
|
||||
if (!from_sys_trx_end->is_max())
|
||||
if (!from_row_end->is_max())
|
||||
continue; // Do not copy history rows.
|
||||
|
||||
store_record(from, record[1]);
|
||||
from->vers_end_field()->store_time(&query_start);
|
||||
from->file->ha_update_row(from->record[1], from->record[0]);
|
||||
to_sys_trx_start->store_time(&query_start);
|
||||
to_row_start->store_time(&query_start);
|
||||
}
|
||||
|
||||
prev_insert_id= to->file->next_insert_id;
|
||||
|
12
sql/vtmd.cc
12
sql/vtmd.cc
@ -51,7 +51,7 @@ VTMD_table::create(THD *thd)
|
||||
}
|
||||
|
||||
bool
|
||||
VTMD_table::find_record(ulonglong sys_trx_end, bool &found)
|
||||
VTMD_table::find_record(ulonglong row_end, bool &found)
|
||||
{
|
||||
int error;
|
||||
key_buf_t key;
|
||||
@ -62,9 +62,9 @@ VTMD_table::find_record(ulonglong sys_trx_end, bool &found)
|
||||
if (key.allocate(vtmd.table->s->max_unique_length))
|
||||
return true;
|
||||
|
||||
DBUG_ASSERT(sys_trx_end);
|
||||
DBUG_ASSERT(row_end);
|
||||
vtmd.table->vers_end_field()->set_notnull();
|
||||
vtmd.table->vers_end_field()->store(sys_trx_end, true);
|
||||
vtmd.table->vers_end_field()->store(row_end, true);
|
||||
key_copy(key, vtmd.table->record[0], vtmd.table->key_info + IDX_TRX_END, 0);
|
||||
|
||||
error= vtmd.table->file->ha_index_read_idx_map(vtmd.table->record[1], IDX_TRX_END,
|
||||
@ -199,7 +199,7 @@ VTMD_table::update(THD *thd, const char* archive_name)
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(thd->lex->sql_command == SQLCOM_ALTER_TABLE);
|
||||
ulonglong sys_trx_end= (ulonglong) vtmd.table->vers_start_field()->val_int();
|
||||
ulonglong row_end= (ulonglong) vtmd.table->vers_start_field()->val_int();
|
||||
store_record(vtmd.table, record[1]);
|
||||
vtmd.table->field[FLD_NAME]->store(TABLE_NAME_WITH_LEN(about), system_charset_info);
|
||||
vtmd.table->field[FLD_NAME]->set_notnull();
|
||||
@ -212,7 +212,7 @@ VTMD_table::update(THD *thd, const char* archive_name)
|
||||
while (true)
|
||||
{ // fill archive_name of last sequential renames
|
||||
bool found;
|
||||
if (find_record(sys_trx_end, found))
|
||||
if (find_record(row_end, found))
|
||||
goto quit;
|
||||
if (!found || !vtmd.table->field[FLD_ARCHIVE_NAME]->is_null())
|
||||
break;
|
||||
@ -225,7 +225,7 @@ VTMD_table::update(THD *thd, const char* archive_name)
|
||||
vtmd.table->vers_write= true;
|
||||
if (error)
|
||||
goto err;
|
||||
sys_trx_end= (ulonglong) vtmd.table->vers_start_field()->val_int();
|
||||
row_end= (ulonglong) vtmd.table->vers_start_field()->val_int();
|
||||
} // while (true)
|
||||
} // else (thd->lex->sql_command != SQLCOM_DROP_TABLE)
|
||||
} // if (!error)
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
}
|
||||
|
||||
bool create(THD *thd);
|
||||
bool find_record(ulonglong sys_trx_end, bool &found);
|
||||
bool find_record(ulonglong row_end, bool &found);
|
||||
bool open(THD *thd, Local_da &local_da, bool *created= NULL);
|
||||
bool update(THD *thd, const char* archive_name= NULL);
|
||||
bool setup_select(THD *thd);
|
||||
|
@ -239,9 +239,9 @@ row_lock_table_for_mysql(
|
||||
enum ins_mode_t {
|
||||
/* plain row (without versioning) */
|
||||
ROW_INS_NORMAL = 0,
|
||||
/* sys_trx_start = TRX_ID, sys_trx_end = MAX */
|
||||
/* row_start = TRX_ID, row_end = MAX */
|
||||
ROW_INS_VERSIONED,
|
||||
/* sys_trx_end = TRX_ID */
|
||||
/* row_end = TRX_ID */
|
||||
ROW_INS_HISTORICAL
|
||||
};
|
||||
|
||||
|
@ -1630,7 +1630,7 @@ row_ins_check_foreign_constraint(
|
||||
if (i < foreign->n_fields && dfield_is_null(field)) {
|
||||
goto exit_func;
|
||||
}
|
||||
/* System Versioning: if sys_trx_end != Inf, we
|
||||
/* System Versioning: if row_end != Inf, we
|
||||
suppress the foreign key check */
|
||||
if (field->type.vers_sys_end() && field->vers_history_row()) {
|
||||
goto exit_func;
|
||||
|
@ -1984,7 +1984,7 @@ row_update_for_mysql(row_prebuilt_t* prebuilt)
|
||||
run_again:
|
||||
if (vers_set_fields) {
|
||||
/* System Versioning: modify update vector to set
|
||||
sys_trx_start (or sys_trx_end in case of DELETE)
|
||||
row_start (or row_end in case of DELETE)
|
||||
to current trx_id. */
|
||||
dict_table_t* table = node->table;
|
||||
dict_index_t* clust_index = dict_table_get_first_index(table);
|
||||
@ -2120,7 +2120,7 @@ handle_error:
|
||||
|
||||
if (vers_set_fields && !prebuilt->versioned_write)
|
||||
{
|
||||
// FIXME: timestamp-based update of sys_trx_end in run_again
|
||||
// FIXME: timestamp-based update of row_end in run_again
|
||||
err = DB_UNSUPPORTED;
|
||||
trx->error_state = err;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user